Skip to content

Commit d99dc62

Browse files
authored
fix: convert to dual package with conditional exports (#121)
fix #119 BREAKING CHANGE: drop support for Node < 8
1 parent ee2ba06 commit d99dc62

File tree

6 files changed

+24
-110
lines changed

6 files changed

+24
-110
lines changed

.babelrc.js

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,10 @@
11
module.exports = function(api) {
2-
const plugins = [
3-
'@babel/plugin-transform-flow-strip-types',
4-
'@babel/plugin-syntax-dynamic-import',
5-
'@babel/plugin-proposal-class-properties',
6-
'@babel/plugin-proposal-export-default-from',
7-
'@babel/plugin-proposal-export-namespace-from',
8-
'@babel/plugin-proposal-object-rest-spread',
9-
]
2+
const plugins = ['@babel/plugin-proposal-object-rest-spread']
103
const presets = [
11-
[
12-
'@babel/preset-env',
13-
api.env('es5')
14-
? { forceAllTransforms: true }
15-
: { targets: { node: 'current' } },
16-
],
174
'@babel/preset-flow',
5+
['@babel/preset-env', { targets: { node: 8 } }],
186
]
197

20-
if (api.env(['test', 'coverage', 'es5'])) {
21-
plugins.push('@babel/plugin-transform-runtime')
22-
}
238
if (api.env('coverage')) {
249
plugins.push('babel-plugin-istanbul')
2510
}

.gitignore

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
coverage
22
.nyc_output
33
node_modules
4-
lib
5-
es
64
.eslintcache
75
/*.js
6+
/*.mjs
7+
/*.cjs
88
/*.js.flow
9+
/*.d.ts
910
!/.babelrc.js

.npmignore

Lines changed: 0 additions & 13 deletions
This file was deleted.

package.json

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,20 @@
22
"name": "promisify-child-process",
33
"version": "0.0.0-development",
44
"description": "seriously like the best async child process library",
5-
"main": "index.js",
5+
"engines": {
6+
"node": ">=8"
7+
},
8+
"main": "./index.cjs",
9+
"exports": {
10+
"import": "./index.mjs",
11+
"require": "./index.cjs"
12+
},
13+
"files": [
14+
"index.cjs",
15+
"index.mjs",
16+
"index.d.ts",
17+
"index.js.flow"
18+
],
619
"sideEffects": false,
720
"scripts": {
821
"lint": "eslint src test --cache",
@@ -13,13 +26,12 @@
1326
"flow": "flow",
1427
"flow:coverage": "for file in src/**.js test/**.js; do echo $file; flow coverage $file; done",
1528
"flow:watch": "flow-watch -e js,js.flow,flowconfig --ignore es/ --ignore node_modules/ --watch .flowconfig --watch src/ --watch test/",
16-
"clean": "rimraf es lib $(cd src; ls) *.js.flow",
17-
"build": "npm run clean && babel src --out-dir es && flow-copy-source -v src/ es && cross-env BABEL_ENV=es5 babel src --out-dir . && flow-copy-source -v src/ .",
18-
"test": "cross-env NODE_ENV=test BABEL_ENV=es5 mocha $npm_package_config_mocha && cross-env NODE_ENV=test BABEL_ENV=coverage nyc --reporter=lcov --reporter=text mocha $npm_package_config_mocha",
29+
"build": "babel src/index.js -o index.cjs && flow-copy-source -v src/ .",
30+
"test": "cross-env NODE_ENV=test mocha $npm_package_config_mocha && cross-env NODE_ENV=test BABEL_ENV=coverage nyc --reporter=lcov --reporter=text mocha $npm_package_config_mocha",
1931
"test:watch": "cross-env NODE_ENV=test BABEL_ENV=test mocha --watch $npm_package_config_mocha",
2032
"test:debug": "cross-env NODE_ENV=test BABEL_ENV=test mocha --inspect-brk $npm_package_config_mocha",
2133
"codecov": "nyc report --reporter=text-lcov > coverage.lcov; codecov",
22-
"prepublishOnly": "npm run clean && npm run prettier:check && npm run lint && flow && tsc && npm test && npm run build",
34+
"prepublishOnly": "npm run prettier:check && npm run lint && flow && tsc && npm test && npm run build",
2335
"open:coverage": "open coverage/lcov-report/index.html",
2436
"semantic-release": "semantic-release"
2537
},
@@ -89,12 +101,7 @@
89101
"devDependencies": {
90102
"@babel/cli": "^7.1.5",
91103
"@babel/core": "^7.1.6",
92-
"@babel/plugin-proposal-class-properties": "^7.1.0",
93-
"@babel/plugin-proposal-export-default-from": "^7.0.0",
94-
"@babel/plugin-proposal-export-namespace-from": "^7.0.0",
95104
"@babel/plugin-proposal-object-rest-spread": "^7.0.0",
96-
"@babel/plugin-syntax-dynamic-import": "^7.0.0",
97-
"@babel/plugin-transform-runtime": "^7.1.0",
98105
"@babel/preset-env": "^7.1.6",
99106
"@babel/preset-flow": "^7.0.0",
100107
"@babel/register": "^7.0.0",

src/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// @flow
22

33
import type { ChildProcess } from 'child_process'
4-
import child_process from 'child_process'
4+
const child_process = require('child_process')
55

66
export type ChildProcessOutput = {
77
stdout: ?(string | Buffer),

yarn.lock

Lines changed: 1 addition & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -244,34 +244,6 @@
244244
"@babel/helper-remap-async-to-generator" "^7.1.0"
245245
"@babel/plugin-syntax-async-generators" "^7.0.0"
246246

247-
"@babel/plugin-proposal-class-properties@^7.1.0":
248-
version "7.1.0"
249-
resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-class-properties/-/plugin-proposal-class-properties-7.1.0.tgz#9af01856b1241db60ec8838d84691aa0bd1e8df4"
250-
integrity sha512-/PCJWN+CKt5v1xcGn4vnuu13QDoV+P7NcICP44BoonAJoPSGwVkgrXihFIQGiEjjPlUDBIw1cM7wYFLARS2/hw==
251-
dependencies:
252-
"@babel/helper-function-name" "^7.1.0"
253-
"@babel/helper-member-expression-to-functions" "^7.0.0"
254-
"@babel/helper-optimise-call-expression" "^7.0.0"
255-
"@babel/helper-plugin-utils" "^7.0.0"
256-
"@babel/helper-replace-supers" "^7.1.0"
257-
"@babel/plugin-syntax-class-properties" "^7.0.0"
258-
259-
"@babel/plugin-proposal-export-default-from@^7.0.0":
260-
version "7.0.0"
261-
resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-export-default-from/-/plugin-proposal-export-default-from-7.0.0.tgz#a057bbfd4649facfe39f33a537e18554bdd2b5da"
262-
integrity sha512-cWhkx6SyjZ4caFOanoPmDNgQCuYYTmou4QXy886JsyLTw/vhWQbop2gLKsWyyswrJkKTB7fSNxVYbP/oEsoySA==
263-
dependencies:
264-
"@babel/helper-plugin-utils" "^7.0.0"
265-
"@babel/plugin-syntax-export-default-from" "^7.0.0"
266-
267-
"@babel/plugin-proposal-export-namespace-from@^7.0.0":
268-
version "7.0.0"
269-
resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-export-namespace-from/-/plugin-proposal-export-namespace-from-7.0.0.tgz#ce847cc62c3626547107a1b835592b8ee494af51"
270-
integrity sha512-UZuK8lkobh3570vCu0sxDQn+ZlCV6CVLlXe+nNohvPr6/zI5I+j4Ir2fTTCG0ayBQanym0N+29K5+v4c8SATaQ==
271-
dependencies:
272-
"@babel/helper-plugin-utils" "^7.0.0"
273-
"@babel/plugin-syntax-export-namespace-from" "^7.0.0"
274-
275247
"@babel/plugin-proposal-json-strings@^7.0.0":
276248
version "7.0.0"
277249
resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-json-strings/-/plugin-proposal-json-strings-7.0.0.tgz#3b4d7b5cf51e1f2e70f52351d28d44fc2970d01e"
@@ -312,34 +284,6 @@
312284
dependencies:
313285
"@babel/helper-plugin-utils" "^7.0.0"
314286

315-
"@babel/plugin-syntax-class-properties@^7.0.0":
316-
version "7.0.0"
317-
resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-class-properties/-/plugin-syntax-class-properties-7.0.0.tgz#e051af5d300cbfbcec4a7476e37a803489881634"
318-
integrity sha512-cR12g0Qzn4sgkjrbrzWy2GE7m9vMl/sFkqZ3gIpAQdrvPDnLM8180i+ANDFIXfjHo9aqp0ccJlQ0QNZcFUbf9w==
319-
dependencies:
320-
"@babel/helper-plugin-utils" "^7.0.0"
321-
322-
"@babel/plugin-syntax-dynamic-import@^7.0.0":
323-
version "7.0.0"
324-
resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-dynamic-import/-/plugin-syntax-dynamic-import-7.0.0.tgz#6dfb7d8b6c3be14ce952962f658f3b7eb54c33ee"
325-
integrity sha512-Gt9xNyRrCHCiyX/ZxDGOcBnlJl0I3IWicpZRC4CdC0P5a/I07Ya2OAMEBU+J7GmRFVmIetqEYRko6QYRuKOESw==
326-
dependencies:
327-
"@babel/helper-plugin-utils" "^7.0.0"
328-
329-
"@babel/plugin-syntax-export-default-from@^7.0.0":
330-
version "7.0.0"
331-
resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-export-default-from/-/plugin-syntax-export-default-from-7.0.0.tgz#084b639bce3d42f3c5bf3f68ccb42220bb2d729d"
332-
integrity sha512-HNnjg/fFFbnuLAqr/Ocp1Y3GB4AjmXcu1xxn3ql3bS2kGrB/qi+Povshb8i3hOkE5jNozzh8r/0/lq1w8oOWbQ==
333-
dependencies:
334-
"@babel/helper-plugin-utils" "^7.0.0"
335-
336-
"@babel/plugin-syntax-export-namespace-from@^7.0.0":
337-
version "7.0.0"
338-
resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-export-namespace-from/-/plugin-syntax-export-namespace-from-7.0.0.tgz#17a7389a1d2571ac4d9b77ea2defa74a930edf5d"
339-
integrity sha512-l314XT1eMa0MWboSmG4BdKukHfSpSpQRenUoZmEpL6hqc5nc1/ddpLETjPB77gZE1dZ9qxy5D3U3UUjjcX2d4g==
340-
dependencies:
341-
"@babel/helper-plugin-utils" "^7.0.0"
342-
343287
"@babel/plugin-syntax-flow@^7.0.0":
344288
version "7.0.0"
345289
resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-flow/-/plugin-syntax-flow-7.0.0.tgz#70638aeaad9ee426bc532e51523cff8ff02f6f17"
@@ -545,16 +489,6 @@
545489
dependencies:
546490
regenerator-transform "^0.13.3"
547491

548-
"@babel/plugin-transform-runtime@^7.1.0":
549-
version "7.1.0"
550-
resolved "https://registry.yarnpkg.com/@babel/plugin-transform-runtime/-/plugin-transform-runtime-7.1.0.tgz#9f76920d42551bb577e2dc594df229b5f7624b63"
551-
integrity sha512-WFLMgzu5DLQEah0lKTJzYb14vd6UiES7PTnXcvrPZ1VrwFeJ+mTbvr65fFAsXYMt2bIoOoC0jk76zY1S7HZjUg==
552-
dependencies:
553-
"@babel/helper-module-imports" "^7.0.0"
554-
"@babel/helper-plugin-utils" "^7.0.0"
555-
resolve "^1.8.1"
556-
semver "^5.5.1"
557-
558492
"@babel/plugin-transform-shorthand-properties@^7.0.0":
559493
version "7.0.0"
560494
resolved "https://registry.yarnpkg.com/@babel/plugin-transform-shorthand-properties/-/plugin-transform-shorthand-properties-7.0.0.tgz#85f8af592dcc07647541a0350e8c95c7bf419d15"
@@ -7168,7 +7102,7 @@ resolve@^1.10.0:
71687102
dependencies:
71697103
path-parse "^1.0.6"
71707104

7171-
resolve@^1.3.2, resolve@^1.8.1:
7105+
resolve@^1.3.2:
71727106
version "1.8.1"
71737107
resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.8.1.tgz#82f1ec19a423ac1fbd080b0bab06ba36e84a7a26"
71747108
integrity sha512-AicPrAC7Qu1JxPCZ9ZgCZlY35QgFnNqc+0LtbRNxnVw4TXvjQ72wnuL9JQcEBgXkI9JM8MsT9kaQoHcpCRJOYA==

0 commit comments

Comments
 (0)