Skip to content

Commit 0a1fe7c

Browse files
committed
feat: add mjs build (es6 modules)
1 parent 5f9327a commit 0a1fe7c

File tree

6 files changed

+67
-72
lines changed

6 files changed

+67
-72
lines changed

.babelrc

+40-8
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,45 @@
22
"plugins": [
33
"transform-object-rest-spread",
44
"transform-flow-strip-types",
5-
["transform-runtime", { "polyfill": false }]
6-
],
7-
"presets": [
8-
["env", {
9-
"targets": {
10-
"node": 4
11-
},
12-
}]
135
],
6+
"env": {
7+
"cjs": {
8+
"plugins": [
9+
"transform-class-properties",
10+
["transform-runtime", { "polyfill": false }]
11+
],
12+
"presets": [
13+
["env", {
14+
"targets": {
15+
"node": 4
16+
},
17+
}]
18+
],
19+
},
20+
"mjs": {
21+
"plugins": ["transform-class-properties"],
22+
"presets": [
23+
[
24+
"env",
25+
{
26+
"targets": {
27+
"node": "8.0.0"
28+
},
29+
"loose": true,
30+
"modules": false
31+
}
32+
]
33+
]
34+
},
35+
"test": {
36+
"plugins": ["transform-class-properties"],
37+
"presets": [
38+
["env", {
39+
"targets": {
40+
"node": "current"
41+
},
42+
}]
43+
]
44+
}
45+
}
1446
}

.eslintignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
flow-typed
22
lib
3+
mjs

.flowconfig

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
.*/coverage/.*
33
.*/resources/.*
44
<PROJECT_ROOT>/lib/.*
5-
<PROJECT_ROOT>/dist/.*
5+
<PROJECT_ROOT>/mjs/.*
66
.*/node_modules/ajv.*
77
.*/node_modules/acorn.*
88
.*/node_modules/async.*

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ node_modules
4141
# Transpiled code
4242
/es
4343
/lib
44+
/mjs
4445

4546
coverage
4647
.nyc_output

package.json

+9-5
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@
33
"version": "0.0.0-semantically-released",
44
"description": "AWS Cloud API via GraphQL",
55
"files": [
6-
"lib"
6+
"lib",
7+
"mjs"
78
],
89
"main": "lib/index.js",
10+
"module": "mjs/index.mjs",
911
"repository": {
1012
"type": "git",
1113
"url": "https://github.com/graphql-compose/graphql-compose-aws.git"
@@ -33,6 +35,7 @@
3335
"babel-cli": "^6.26.0",
3436
"babel-eslint": "^8.2.5",
3537
"babel-jest": "^23.2.0",
38+
"babel-plugin-transform-class-properties": "^6.24.1",
3639
"babel-plugin-transform-flow-strip-types": "^6.22.0",
3740
"babel-plugin-transform-object-rest-spread": "^6.26.0",
3841
"babel-plugin-transform-runtime": "^6.23.0",
@@ -51,7 +54,6 @@
5154
"graphql-compose": "^4.4.1",
5255
"jest": "^23.2.0",
5356
"nodemon": "^1.17.5",
54-
"npm-run-all": "^4.1.3",
5557
"prettier": "^1.13.6",
5658
"rimraf": "^2.6.2",
5759
"semantic-release": "^15.6.0"
@@ -67,9 +69,11 @@
6769
]
6870
},
6971
"scripts": {
70-
"build": "npm-run-all build:*",
71-
"build:lib": "rimraf lib && babel src --ignore __tests__,__mocks__ -d lib",
72-
"build:flow": "find ./src -name '*.js' -not -path '*/__*' | while read filepath; do cp $filepath `echo $filepath | sed 's/\\/src\\//\\/lib\\//g'`.flow; done",
72+
"build": "npm run build-cjs && npm run build-mjs",
73+
"build-cjs": "rimraf lib && BABEL_ENV=cjs babel src --ignore __tests__,__mocks__ -d lib && COPY_TO_FOLDER=lib npm run build-flow",
74+
"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",
75+
"build-mjs-rename": "find ./mjs -name \"*.js\" -exec bash -c 'mv \"$1\" \"${1%.js}\".mjs' - '{}' \\;",
76+
"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",
7377
"demo": "npm run demo-fullApi",
7478
"demo-fullApi": "nodemon -e js --ignore *test* --exec ./node_modules/.bin/babel-node ./examples/fullApi/index.js",
7579
"demo-introspection": "./node_modules/.bin/babel-node ./examples/introspection/generate.js",

yarn.lock

+15-58
Original file line numberDiff line numberDiff line change
@@ -374,10 +374,6 @@ array-equal@^1.0.0:
374374
version "1.0.0"
375375
resolved "https://registry.yarnpkg.com/array-equal/-/array-equal-1.0.0.tgz#8c2a5ef2472fd9ea742b04c77a75093ba2757c93"
376376

377-
array-filter@~0.0.0:
378-
version "0.0.1"
379-
resolved "https://registry.yarnpkg.com/array-filter/-/array-filter-0.0.1.tgz#7da8cf2e26628ed732803581fd21f67cacd2eeec"
380-
381377
array-find-index@^1.0.1:
382378
version "1.0.2"
383379
resolved "https://registry.yarnpkg.com/array-find-index/-/array-find-index-1.0.2.tgz#df010aa1287e164bbda6f9723b0a96a1ec4187a1"
@@ -390,14 +386,6 @@ array-ify@^1.0.0:
390386
version "1.0.0"
391387
resolved "https://registry.yarnpkg.com/array-ify/-/array-ify-1.0.0.tgz#9e528762b4a9066ad163a6962a364418e9626ece"
392388

393-
array-map@~0.0.0:
394-
version "0.0.0"
395-
resolved "https://registry.yarnpkg.com/array-map/-/array-map-0.0.0.tgz#88a2bab73d1cf7bcd5c1b118a003f66f665fa662"
396-
397-
array-reduce@~0.0.0:
398-
version "0.0.0"
399-
resolved "https://registry.yarnpkg.com/array-reduce/-/array-reduce-0.0.0.tgz#173899d3ffd1c7d9383e4479525dbe278cab5f2b"
400-
401389
array-union@^1.0.1:
402390
version "1.0.2"
403391
resolved "https://registry.yarnpkg.com/array-union/-/array-union-1.0.2.tgz#9a34410e4f4e3da23dea375be5be70f24778ec39"
@@ -743,6 +731,10 @@ babel-plugin-syntax-async-functions@^6.8.0:
743731
version "6.13.0"
744732
resolved "https://registry.yarnpkg.com/babel-plugin-syntax-async-functions/-/babel-plugin-syntax-async-functions-6.13.0.tgz#cad9cad1191b5ad634bf30ae0872391e0647be95"
745733

734+
babel-plugin-syntax-class-properties@^6.8.0:
735+
version "6.13.0"
736+
resolved "https://registry.yarnpkg.com/babel-plugin-syntax-class-properties/-/babel-plugin-syntax-class-properties-6.13.0.tgz#d7eb23b79a317f8543962c505b827c7d6cac27de"
737+
746738
babel-plugin-syntax-exponentiation-operator@^6.8.0:
747739
version "6.13.0"
748740
resolved "https://registry.yarnpkg.com/babel-plugin-syntax-exponentiation-operator/-/babel-plugin-syntax-exponentiation-operator-6.13.0.tgz#9ee7e8337290da95288201a6a57f4170317830de"
@@ -767,6 +759,15 @@ babel-plugin-transform-async-to-generator@^6.22.0:
767759
babel-plugin-syntax-async-functions "^6.8.0"
768760
babel-runtime "^6.22.0"
769761

762+
babel-plugin-transform-class-properties@^6.24.1:
763+
version "6.24.1"
764+
resolved "https://registry.yarnpkg.com/babel-plugin-transform-class-properties/-/babel-plugin-transform-class-properties-6.24.1.tgz#6a79763ea61d33d36f37b611aa9def81a81b46ac"
765+
dependencies:
766+
babel-helper-function-name "^6.24.1"
767+
babel-plugin-syntax-class-properties "^6.8.0"
768+
babel-runtime "^6.22.0"
769+
babel-template "^6.24.1"
770+
770771
babel-plugin-transform-es2015-arrow-functions@^6.22.0:
771772
version "6.22.0"
772773
resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-arrow-functions/-/babel-plugin-transform-es2015-arrow-functions-6.22.0.tgz#452692cb711d5f79dc7f85e440ce41b9f244d221"
@@ -1704,7 +1705,7 @@ cross-spawn@^5.0.1:
17041705
shebang-command "^1.2.0"
17051706
which "^1.2.9"
17061707

1707-
cross-spawn@^6.0.0, cross-spawn@^6.0.4, cross-spawn@^6.0.5:
1708+
cross-spawn@^6.0.0, cross-spawn@^6.0.5:
17081709
version "6.0.5"
17091710
resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-6.0.5.tgz#4a5ec7c64dfae22c3a14124dbacdee846d80cbc4"
17101711
dependencies:
@@ -1988,15 +1989,6 @@ es-abstract@^1.10.0, es-abstract@^1.6.1:
19881989
is-callable "^1.1.3"
19891990
is-regex "^1.0.4"
19901991

1991-
es-abstract@^1.4.3:
1992-
version "1.7.0"
1993-
resolved "https://registry.yarnpkg.com/es-abstract/-/es-abstract-1.7.0.tgz#dfade774e01bfcd97f96180298c449c8623fb94c"
1994-
dependencies:
1995-
es-to-primitive "^1.1.1"
1996-
function-bind "^1.1.0"
1997-
is-callable "^1.1.3"
1998-
is-regex "^1.0.3"
1999-
20001992
es-abstract@^1.5.1:
20011993
version "1.10.0"
20021994
resolved "https://registry.yarnpkg.com/es-abstract/-/es-abstract-1.10.0.tgz#1ecb36c197842a00d8ee4c2dfd8646bb97d60864"
@@ -3401,7 +3393,7 @@ is-redirect@^1.0.0:
34013393
version "1.0.0"
34023394
resolved "https://registry.yarnpkg.com/is-redirect/-/is-redirect-1.0.0.tgz#1d03dded53bd8db0f30c26e4f95d36fc7c87dc24"
34033395

3404-
is-regex@^1.0.3, is-regex@^1.0.4:
3396+
is-regex@^1.0.4:
34053397
version "1.0.4"
34063398
resolved "https://registry.yarnpkg.com/is-regex/-/is-regex-1.0.4.tgz#5517489b547091b0930e095654ced25ee97e9491"
34073399
dependencies:
@@ -4180,10 +4172,6 @@ mem@^1.1.0:
41804172
dependencies:
41814173
mimic-fn "^1.0.0"
41824174

4183-
memorystream@^0.3.1:
4184-
version "0.3.1"
4185-
resolved "https://registry.yarnpkg.com/memorystream/-/memorystream-0.3.1.tgz#86d7090b30ce455d63fbae12dda51a47ddcaf9b2"
4186-
41874175
meow@^3.3.0:
41884176
version "3.7.0"
41894177
resolved "https://registry.yarnpkg.com/meow/-/meow-3.7.0.tgz#72cb668b425228290abbfa856892587308a801fb"
@@ -4561,20 +4549,6 @@ normalize-url@^2.0.1:
45614549
query-string "^5.0.1"
45624550
sort-keys "^2.0.0"
45634551

4564-
npm-run-all@^4.1.3:
4565-
version "4.1.3"
4566-
resolved "https://registry.yarnpkg.com/npm-run-all/-/npm-run-all-4.1.3.tgz#49f15b55a66bb4101664ce270cb18e7103f8f185"
4567-
dependencies:
4568-
ansi-styles "^3.2.0"
4569-
chalk "^2.1.0"
4570-
cross-spawn "^6.0.4"
4571-
memorystream "^0.3.1"
4572-
minimatch "^3.0.4"
4573-
ps-tree "^1.1.0"
4574-
read-pkg "^3.0.0"
4575-
shell-quote "^1.6.1"
4576-
string.prototype.padend "^3.0.0"
4577-
45784552
npm-run-path@^2.0.0:
45794553
version "2.0.2"
45804554
resolved "https://registry.yarnpkg.com/npm-run-path/-/npm-run-path-2.0.2.tgz#35a9232dfa35d7067b4cb2ddf2357b1871536c5f"
@@ -5707,15 +5681,6 @@ shebang-regex@^1.0.0:
57075681
version "1.0.0"
57085682
resolved "https://registry.yarnpkg.com/shebang-regex/-/shebang-regex-1.0.0.tgz#da42f49740c0b42db2ca9728571cb190c98efea3"
57095683

5710-
shell-quote@^1.6.1:
5711-
version "1.6.1"
5712-
resolved "https://registry.yarnpkg.com/shell-quote/-/shell-quote-1.6.1.tgz#f4781949cce402697127430ea3b3c5476f481767"
5713-
dependencies:
5714-
array-filter "~0.0.0"
5715-
array-map "~0.0.0"
5716-
array-reduce "~0.0.0"
5717-
jsonify "~0.0.0"
5718-
57195684
shellwords@^0.1.1:
57205685
version "0.1.1"
57215686
resolved "https://registry.yarnpkg.com/shellwords/-/shellwords-0.1.1.tgz#d6b9181c1a48d397324c84871efbcfc73fc0654b"
@@ -5979,14 +5944,6 @@ string.prototype.matchall@^2.0.0:
59795944
has-symbols "^1.0.0"
59805945
regexp.prototype.flags "^1.2.0"
59815946

5982-
string.prototype.padend@^3.0.0:
5983-
version "3.0.0"
5984-
resolved "https://registry.yarnpkg.com/string.prototype.padend/-/string.prototype.padend-3.0.0.tgz#f3aaef7c1719f170c5eab1c32bf780d96e21f2f0"
5985-
dependencies:
5986-
define-properties "^1.1.2"
5987-
es-abstract "^1.4.3"
5988-
function-bind "^1.0.2"
5989-
59905947
string_decoder@~0.10.x:
59915948
version "0.10.31"
59925949
resolved "https://registry.yarnpkg.com/string_decoder/-/string_decoder-0.10.31.tgz#62e203bc41766c6c28c9fc84301dab1c5310fa94"

0 commit comments

Comments
 (0)