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 3977ced commit 6516977
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 17 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
14 changes: 9 additions & 5 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": "Plugin for `graphql-compose` which wraps graphql types with Relay specific logic.",
"files": [
"lib"
"lib",
"mjs"
],
"main": "lib/index.js",
"module": "mjs/index.mjs",
"repository": {
"type": "git",
"url": "https://github.com/graphql-compose/graphql-compose-relay.git"
Expand Down Expand Up @@ -41,7 +43,7 @@
"eslint-plugin-prettier": "^2.6.1",
"flow-bin": "^0.75.0",
"graphql": "0.13.2",
"graphql-compose": "^4.4.0",
"graphql-compose": "^4.4.1",
"jest": "^23.2.0",
"prettier": "^1.13.6",
"rimraf": "^2.6.2",
Expand All @@ -61,9 +63,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",
"build-cjs": "rimraf lib && 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
6 changes: 3 additions & 3 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2397,9 +2397,9 @@ graceful-fs@^4.1.4:
version "4.1.9"
resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.1.9.tgz#baacba37d19d11f9d146d3578bc99958c3787e29"

graphql-compose@^4.4.0:
version "4.4.0"
resolved "https://registry.yarnpkg.com/graphql-compose/-/graphql-compose-4.4.0.tgz#459045017496d63c00051e23d850907bfbf5cede"
graphql-compose@^4.4.1:
version "4.4.1"
resolved "https://registry.yarnpkg.com/graphql-compose/-/graphql-compose-4.4.1.tgz#2f801bb8e70e8601c21a2e52b629a21c6aba35db"
dependencies:
babel-runtime "^6.26.0"
graphql-type-json "^0.2.1"
Expand Down

0 comments on commit 6516977

Please sign in to comment.