File tree Expand file tree Collapse file tree 2 files changed +42
-13
lines changed Expand file tree Collapse file tree 2 files changed +42
-13
lines changed Original file line number Diff line number Diff line change 11
11
"files" : [
12
12
" /dist"
13
13
],
14
- "main" : " dist/" ,
15
- "module" : " dist/index.js" ,
14
+ "exports" : {
15
+ "." : {
16
+ "require" : " ./dist/index.cjs" ,
17
+ "default" : " ./dist/index.mjs"
18
+ }
19
+ },
16
20
"keywords" : [
17
21
" "
18
22
],
61
65
"build" : " NODE_ENV=production webpack" ,
62
66
"lint" : " eslint lib --max-warnings 0 && prettier lib --check" ,
63
67
"test" : " jest" ,
64
- "prepublishOnly" : " npm run build"
68
+ "prepublishOnly" : " npm run build" ,
69
+ "webpack" : " webpack"
65
70
},
66
71
"repository" : " git@github.com:freeCodeCamp/curriculum-helpers.git" ,
67
72
"jest" : {
Original file line number Diff line number Diff line change 1
1
const path = require ( "path" ) ;
2
2
3
3
console . info ( "Building in " + process . env . NODE_ENV + " mode." ) ;
4
- module . exports = {
5
- mode : process . env . NODE_ENV ? "production" : "development" ,
4
+ const baseConfig = {
5
+ mode : process . env . NODE_ENV ,
6
6
entry : {
7
7
index : "./lib/index.ts" ,
8
8
} ,
9
- devtool : process . env . NODE_ENV ? "source-map" : "inline-source-map" ,
10
- output : {
11
- globalObject : 'this' ,
12
- library : {
13
- name : "helpers" ,
14
- type : "umd" ,
15
- } ,
16
- } ,
9
+ devtool :
10
+ process . env . NODE_ENV === "production" ? "source-map" : "inline-source-map" ,
17
11
module : {
18
12
rules : [
19
13
{
@@ -30,3 +24,33 @@ module.exports = {
30
24
} ,
31
25
} ,
32
26
} ;
27
+
28
+ const nodeConfig = {
29
+ ...baseConfig ,
30
+ target : "node" ,
31
+ output : {
32
+ library : {
33
+ type : "commonjs" ,
34
+ } ,
35
+ filename : "index.cjs" ,
36
+ path : path . resolve ( __dirname , "dist" ) ,
37
+ } ,
38
+ } ;
39
+
40
+ const browserConfig = {
41
+ ...baseConfig ,
42
+ target : "web" ,
43
+ experiments : {
44
+ outputModule : true ,
45
+ } ,
46
+ output : {
47
+ library : {
48
+ type : "module" ,
49
+ // type: "commonjs-static",
50
+ } ,
51
+ filename : "index.mjs" ,
52
+ path : path . resolve ( __dirname , "dist" ) ,
53
+ } ,
54
+ } ;
55
+
56
+ module . exports = [ nodeConfig , browserConfig ] ;
You can’t perform that action at this time.
0 commit comments