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 94b16a2 commit b93cecf
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 13 deletions.
45 changes: 37 additions & 8 deletions .babelrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,42 @@
"plugins": [
"transform-object-rest-spread",
"transform-flow-strip-types",
["transform-runtime", { "polyfill": false }]
],
"presets": [
["env", {
"targets": {
"node": 4
},
}]
],
"env": {
"cjs": {
"plugins": [
["transform-runtime", { "polyfill": false }]
],
"presets": [
["env", {
"targets": {
"node": 4
},
}]
],
},
"mjs": {
"presets": [
[
"env",
{
"targets": {
"node": "8.0.0"
},
"loose": true,
"modules": false
}
]
]
},
"test": {
"presets": [
["env", {
"targets": {
"node": "current"
},
}]
]
}
}
}
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
lib/*
flow-typed
mjs/*
2 changes: 1 addition & 1 deletion .flowconfig
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
.*/coverage/.*
.*/resources/.*
<PROJECT_ROOT>/lib/.*
<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 @@ -41,6 +41,7 @@ node_modules
# Transpiled code
/es
/lib
/mjs

coverage
.nyc_output
12 changes: 8 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
"version": "0.0.0-semantically-released",
"description": "This is a plugin for `graphql-compose`, which generates GraphQLTypes from any JSON.",
"files": [
"lib"
"lib",
"mjs"
],
"main": "lib/index.js",
"module": "mjs/index.js",
"repository": {
"type": "git",
"url": "https://github.com/graphql-compose/graphql-compose-json.git"
Expand Down Expand Up @@ -63,9 +65,11 @@
]
},
"scripts": {
"build": "npm run build-cjs && npm run build-flow",
"build-cjs": "rimraf lib && babel src --ignore __tests__,__mocks__,__fixtures__ -d lib",
"build-flow": "find ./src -name '*.js' -not -path '*/__*' | while read filepath; do cp $filepath `echo $filepath | sed 's/\\/src\\//\\/lib\\//g'`.flow; done",
"build": "npm run build-cjs && npm run build-mjs",
"build-cjs": "rimraf lib && babel src --ignore __tests__,__mocks__,__fixtures__ -d lib && COPY_TO_FOLDER=lib 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": "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",
"lint": "eslint --ext .js ./src",
Expand Down

0 comments on commit b93cecf

Please sign in to comment.