File tree Expand file tree Collapse file tree 2 files changed +30
-3
lines changed Expand file tree Collapse file tree 2 files changed +30
-3
lines changed Original file line number Diff line number Diff line change
1
+ #! /bin/bash
2
+
3
+ # This script defines the type of exports in the dist directory using minimal
4
+ # package.json files. Setting the type in the main package.json file does not
5
+ # work because we want to support both CommonJS and ES Module exports in the
6
+ # same package.
7
+
8
+ cat > dist/cjs/package.json << !EOF
9
+ {
10
+ "type": "commonjs"
11
+ }
12
+ !EOF
13
+ echo " Exports type set to CommonJS in dist/cjs/package.json"
14
+
15
+ cat > dist/esm/package.json << !EOF
16
+ {
17
+ "type": "module"
18
+ }
19
+ !EOF
20
+ echo " Exports type set to ES Module in dist/esm/package.json"
Original file line number Diff line number Diff line change 5
5
"main" : " dist/cjs/index.js" ,
6
6
"module" : " dist/esm/index.js" ,
7
7
"types" : " dist/esm/index.d.ts" ,
8
+ "exports" : {
9
+ "." : {
10
+ "require" : " ./dist/cjs/index.js" ,
11
+ "import" : " ./dist/esm/index.js" ,
12
+ "types" : " ./dist/esm/index.d.ts"
13
+ }
14
+ },
8
15
"scripts" : {
9
- "build" : " rimraf dist && npm run build:esm && npm run build:cjs" ,
16
+ "build" : " rimraf dist && npm run build:esm && npm run build:cjs && ./fix-exports-type.sh " ,
10
17
"build:esm" : " tsc -p tsconfig.esm.json" ,
11
18
"build:cjs" : " tsc -p tsconfig.json" ,
12
19
"test" : " karma start" ,
13
- "types" : " tsc -p tsconfig.json" ,
20
+ "types" : " tsc -p tsconfig.esm. json" ,
14
21
"lint" : " eslint . --ext .ts,.tsx" ,
15
22
"lint:fix" : " eslint . --ext .ts,.tsx --fix" ,
16
23
"docs:generate" : " rimraf documentation-website/* && typedoc" ,
17
24
"docs:serve" : " live-server ./documentation-website"
18
25
},
19
- "author" : " " ,
26
+ "author" : " DittoLive Inc. " ,
20
27
"license" : " ISC" ,
21
28
"repository" : {
22
29
"type" : " git" ,
You can’t perform that action at this time.
0 commit comments