Skip to content

Commit 495dcf7

Browse files
committed
feat: add mjs build (es6 modules)
1 parent 9b604fa commit 495dcf7

File tree

5 files changed

+47
-12
lines changed

5 files changed

+47
-12
lines changed

Diff for: .babelrc

+37-8
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,42 @@
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-runtime", { "polyfill": false }]
10+
],
11+
"presets": [
12+
["env", {
13+
"targets": {
14+
"node": 4
15+
},
16+
}]
17+
],
18+
},
19+
"mjs": {
20+
"presets": [
21+
[
22+
"env",
23+
{
24+
"targets": {
25+
"node": "8.0.0"
26+
},
27+
"loose": true,
28+
"modules": false
29+
}
30+
]
31+
]
32+
},
33+
"test": {
34+
"presets": [
35+
["env", {
36+
"targets": {
37+
"node": "current"
38+
},
39+
}]
40+
]
41+
}
42+
}
1443
}

Diff for: .eslintignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
lib/*
22
es/*
3+
mjs/*

Diff for: .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.*

Diff for: .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

Diff for: package.json

+7-3
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@
44
"description": "Plugin for `graphql-compose` which provide a pagination resolver for types.",
55
"files": [
66
"lib",
7+
"mjs",
78
"README.md"
89
],
910
"main": "lib/index.js",
11+
"module": "mjs/index.js",
1012
"repository": {
1113
"type": "git",
1214
"url": "https://github.com/graphql-compose/graphql-compose-pagination.git"
@@ -63,9 +65,11 @@
6365
]
6466
},
6567
"scripts": {
66-
"build": "npm run build-cjs && npm run build-flow",
67-
"build-cjs": "rimraf lib && babel src --ignore __tests__,__mocks__ -d lib",
68-
"build-flow": "find ./src -name '*.js' -not -path '*/__*' | while read filepath; do cp $filepath `echo $filepath | sed 's/\\/src\\//\\/lib\\//g'`.flow; done",
68+
"build": "npm run build-cjs && npm run build-mjs && npm run build-flow",
69+
"build-cjs": "rimraf lib && babel src --ignore __tests__,__mocks__ -d lib && COPY_TO_FOLDER=lib npm run build-flow",
70+
"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",
71+
"build-mjs-rename": "find ./mjs -name \"*.js\" -exec bash -c 'mv \"$1\" \"${1%.js}\".mjs' - '{}' \\;",
72+
"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",
6973
"watch": "jest --watch",
7074
"coverage": "jest --coverage",
7175
"lint": "eslint --ext .js ./src",

0 commit comments

Comments
 (0)