Skip to content

Commit b3d67ee

Browse files
committed
feat: add mjs build (es6 modules)
1 parent 2d366f0 commit b3d67ee

File tree

5 files changed

+25
-5
lines changed

5 files changed

+25
-5
lines changed

.babelrc

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"transform-flow-strip-types",
55
],
66
"env": {
7-
"lib": {
7+
"cjs": {
88
"plugins": [
99
["transform-runtime", { "polyfill": false }]
1010
],
@@ -16,6 +16,20 @@
1616
}]
1717
]
1818
},
19+
"mjs": {
20+
"presets": [
21+
[
22+
"env",
23+
{
24+
"targets": {
25+
"node": "8.0.0"
26+
},
27+
"loose": true,
28+
"modules": false
29+
}
30+
]
31+
]
32+
},
1933
"es": {
2034
},
2135
"node8": {

.eslintignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
lib/*
22
es/*
3+
mjs/*
34
node8/*
45
flow-typed

.flowconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<PROJECT_ROOT>/lib/.*
55
<PROJECT_ROOT>/es/.*
66
<PROJECT_ROOT>/node8/.*
7-
<PROJECT_ROOT>/dist/.*
7+
<PROJECT_ROOT>/mjs/.*
88
.*/node_modules/ajv.*
99
.*/node_modules/acorn.*
1010
.*/node_modules/async.*

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ node_modules
4242
/es
4343
/lib
4444
/node8
45+
/mjs
4546

4647
coverage
4748
.nyc_output

package.json

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@
55
"files": [
66
"lib",
77
"node8",
8-
"es"
8+
"es",
9+
"mjs"
910
],
1011
"main": "lib/index.js",
12+
"module": "mjs/index.mjs",
1113
"repository": {
1214
"type": "git",
1315
"url": "https://github.com/graphql-compose/graphql-compose-mongoose.git"
@@ -76,10 +78,12 @@
7678
]
7779
},
7880
"scripts": {
79-
"build": "npm run build-lib && npm run build-es && npm run build-node8",
80-
"build-lib": "rimraf lib && BABEL_ENV=lib babel src --ignore __tests__,__mocks__ -d lib && COPY_TO_FOLDER=lib npm run build-flow",
81+
"build": "npm run build-lib && npm run build-mjs && npm run build-es && npm run build-node8",
82+
"build-lib": "rimraf lib && BABEL_ENV=cjs babel src --ignore __tests__,__mocks__ -d lib && COPY_TO_FOLDER=lib npm run build-flow",
8183
"build-es": "rimraf es && BABEL_ENV=es babel src --ignore __tests__,__mocks__ -d es && COPY_TO_FOLDER=es npm run build-flow",
8284
"build-node8": "rimraf node8 && BABEL_ENV=node8 babel src --ignore __tests__,__mocks__ -d node8 && COPY_TO_FOLDER=node8 npm run build-flow",
85+
"build-mjs": "rimraf mjs && BABEL_ENV=mjs babel src --ignore __tests__,__mocks__ -d mjs && yarn build-mjs-rename && COPY_TO_FOLDER=mjs npm run build-flow",
86+
"build-mjs-rename": "find ./mjs -name \"*.js\" -exec bash -c 'mv \"$1\" \"${1%.js}\".mjs' - '{}' \\;",
8387
"build-flow": "echo `$1` && find ./src -name '*.js' -not -path '*/__*' | while read filepath; do cp $filepath `echo ./${COPY_TO_FOLDER:-lib}$filepath | sed 's/.\\/src\\//\\//g'`.flow; done",
8488
"watch": "jest --watch",
8589
"coverage": "jest --coverage --maxWorkers 2",

0 commit comments

Comments
 (0)