Skip to content

Commit

Permalink
feat: add mjs build (es6 modules)
Browse files Browse the repository at this point in the history
  • Loading branch information
nodkz committed Jun 26, 2018
1 parent 2d366f0 commit b3d67ee
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 5 deletions.
16 changes: 15 additions & 1 deletion .babelrc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"transform-flow-strip-types",
],
"env": {
"lib": {
"cjs": {
"plugins": [
["transform-runtime", { "polyfill": false }]
],
Expand All @@ -16,6 +16,20 @@
}]
]
},
"mjs": {
"presets": [
[
"env",
{
"targets": {
"node": "8.0.0"
},
"loose": true,
"modules": false
}
]
]
},
"es": {
},
"node8": {
Expand Down
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
lib/*
es/*
mjs/*
node8/*
flow-typed
2 changes: 1 addition & 1 deletion .flowconfig
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<PROJECT_ROOT>/lib/.*
<PROJECT_ROOT>/es/.*
<PROJECT_ROOT>/node8/.*
<PROJECT_ROOT>/dist/.*
<PROJECT_ROOT>/mjs/.*
.*/node_modules/ajv.*
.*/node_modules/acorn.*
.*/node_modules/async.*
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ node_modules
/es
/lib
/node8
/mjs

coverage
.nyc_output
10 changes: 7 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@
"files": [
"lib",
"node8",
"es"
"es",
"mjs"
],
"main": "lib/index.js",
"module": "mjs/index.mjs",
"repository": {
"type": "git",
"url": "https://github.com/graphql-compose/graphql-compose-mongoose.git"
Expand Down Expand Up @@ -76,10 +78,12 @@
]
},
"scripts": {
"build": "npm run build-lib && npm run build-es && npm run build-node8",
"build-lib": "rimraf lib && BABEL_ENV=lib babel src --ignore __tests__,__mocks__ -d lib && COPY_TO_FOLDER=lib npm run build-flow",
"build": "npm run build-lib && npm run build-mjs && npm run build-es && npm run build-node8",
"build-lib": "rimraf lib && BABEL_ENV=cjs babel src --ignore __tests__,__mocks__ -d lib && COPY_TO_FOLDER=lib npm run build-flow",
"build-es": "rimraf es && BABEL_ENV=es babel src --ignore __tests__,__mocks__ -d es && COPY_TO_FOLDER=es npm run build-flow",
"build-node8": "rimraf node8 && BABEL_ENV=node8 babel src --ignore __tests__,__mocks__ -d node8 && COPY_TO_FOLDER=node8 npm run build-flow",
"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",
"build-mjs-rename": "find ./mjs -name \"*.js\" -exec bash -c 'mv \"$1\" \"${1%.js}\".mjs' - '{}' \\;",
"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",
"watch": "jest --watch",
"coverage": "jest --coverage --maxWorkers 2",
Expand Down

0 comments on commit b3d67ee

Please sign in to comment.