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 a418bf4 commit 1375b8f
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 12 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/*
es/*
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
10 changes: 7 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@
"description": "Plugin for `graphql-compose` which provide a connection resolver for types.",
"files": [
"lib",
"mjs",
"README.md"
],
"main": "lib/index.js",
"module": "mjs/index.js",
"repository": {
"type": "git",
"url": "https://github.com/graphql-compose/graphql-compose-connection.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__ -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 && npm run build-flow",
"build-cjs": "rimraf lib && BABEL_ENV=cjs babel src --ignore __tests__,__mocks__ -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",
"lint": "eslint --ext .js ./src",
Expand Down

0 comments on commit 1375b8f

Please sign in to comment.