[Pkg-javascript-commits] [node-rollup-plugin-commonjs] 01/03: New upstream version 9.0.0
Julien Puydt
julien.puydt at laposte.net
Wed Mar 7 09:58:26 UTC 2018
This is an automated email from the git hooks/post-receive script.
jpuydt-guest pushed a commit to branch master
in repository node-rollup-plugin-commonjs.
commit 12f52dfbf4bd824e9be8fbdfc10272328bc584c4
Author: Julien Puydt <julien.puydt at laposte.net>
Date: Wed Mar 7 10:54:34 2018 +0100
New upstream version 9.0.0
---
CHANGELOG.md | 6 +
package-lock.json | 467 +++++++++++++-----------------
package.json | 25 +-
src/index.js | 11 +-
src/transform.js | 17 +-
test/function/bare-import-comment/bar.js | 2 +
test/function/bare-import-comment/foo.js | 1 +
test/function/bare-import-comment/main.js | 3 +
test/samples/invalid-syntax/main.js | 1 +
test/test.js | 29 +-
10 files changed, 278 insertions(+), 284 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index f0a031a..973701f 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,11 @@
# rollup-plugin-commonjs changelog
+## 8.4.0
+
+* Better handle non-CJS files that contain CJS keywords ([#285](https://github.com/rollup/rollup-plugin-commonjs/issues/285))
+* Use rollup's plugin context`parse` function ([#287](https://github.com/rollup/rollup-plugin-commonjs/issues/287))
+* Improve error handling ([#288](https://github.com/rollup/rollup-plugin-commonjs/issues/288))
+
## 8.3.0
* Handle multiple entry points ([#283](https://github.com/rollup/rollup-plugin-commonjs/issues/283))
diff --git a/package-lock.json b/package-lock.json
index 93cd28b..01a638b 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,35 +1,28 @@
{
"name": "rollup-plugin-commonjs",
- "version": "8.3.0",
+ "version": "9.0.0",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
"acorn": {
- "version": "5.2.1",
- "resolved": "https://registry.npmjs.org/acorn/-/acorn-5.2.1.tgz",
- "integrity": "sha512-jG0u7c4Ly+3QkkW18V+NRDN+4bWHdln30NL1ZL2AvFZZmQe/BfopYCtghCKKVBUSetZ4QKcyA0pY6/4Gw8Pv8w=="
+ "version": "5.5.0",
+ "resolved": "https://registry.npmjs.org/acorn/-/acorn-5.5.0.tgz",
+ "integrity": "sha512-arn53F07VXmls4o4pUhSzBa4fvaagPRe7AVZ8l7NHxFWUie2DsuFSBMMNAkgzRlOhEhzAnxeKyaWVzOH4xqp/g==",
+ "dev": true
},
- "acorn-jsx": {
- "version": "3.0.1",
- "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-3.0.1.tgz",
- "integrity": "sha1-r9+UiPsezvyDSPb7IvRk4ypYs2s=",
+ "acorn-dynamic-import": {
+ "version": "3.0.0",
+ "resolved": "https://registry.npmjs.org/acorn-dynamic-import/-/acorn-dynamic-import-3.0.0.tgz",
+ "integrity": "sha512-zVWV8Z8lislJoOKKqdNMOB+s6+XV5WERty8MnKBeFgwA+19XJjJHs2RP5dzM57FftIs+jQnRToLiWazKr6sSWg==",
"dev": true,
"requires": {
- "acorn": "3.3.0"
- },
- "dependencies": {
- "acorn": {
- "version": "3.3.0",
- "resolved": "https://registry.npmjs.org/acorn/-/acorn-3.3.0.tgz",
- "integrity": "sha1-ReN/s56No/JbruP/U2niu18iAXo=",
- "dev": true
- }
+ "acorn": "5.5.0"
}
},
- "acorn-object-spread": {
- "version": "1.0.0",
- "resolved": "https://registry.npmjs.org/acorn-object-spread/-/acorn-object-spread-1.0.0.tgz",
- "integrity": "sha1-SOrQ9KjrFplaF6Dbn/xqyq2kumg=",
+ "acorn-jsx": {
+ "version": "3.0.1",
+ "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-3.0.1.tgz",
+ "integrity": "sha1-r9+UiPsezvyDSPb7IvRk4ypYs2s=",
"dev": true,
"requires": {
"acorn": "3.3.0"
@@ -44,21 +37,21 @@
}
},
"ajv": {
- "version": "5.2.3",
- "resolved": "https://registry.npmjs.org/ajv/-/ajv-5.2.3.tgz",
- "integrity": "sha1-wG9Zh3jETGsWGrr+NGa4GtGBTtI=",
+ "version": "5.5.2",
+ "resolved": "https://registry.npmjs.org/ajv/-/ajv-5.5.2.tgz",
+ "integrity": "sha1-c7Xuyj+rZT49P5Qis0GtQiBdyWU=",
"dev": true,
"requires": {
"co": "4.6.0",
- "fast-deep-equal": "1.0.0",
- "json-schema-traverse": "0.3.1",
- "json-stable-stringify": "1.0.1"
+ "fast-deep-equal": "1.1.0",
+ "fast-json-stable-stringify": "2.0.0",
+ "json-schema-traverse": "0.3.1"
}
},
"ajv-keywords": {
- "version": "2.1.0",
- "resolved": "https://registry.npmjs.org/ajv-keywords/-/ajv-keywords-2.1.0.tgz",
- "integrity": "sha1-opbhf3v658HOT34N5T0pyzIWLfA=",
+ "version": "2.1.1",
+ "resolved": "https://registry.npmjs.org/ajv-keywords/-/ajv-keywords-2.1.1.tgz",
+ "integrity": "sha1-YXmX/F9gV2iUxDX5QNgZ4TW4B2I=",
"dev": true
},
"ansi-escapes": {
@@ -80,9 +73,9 @@
"dev": true
},
"argparse": {
- "version": "1.0.9",
- "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.9.tgz",
- "integrity": "sha1-c9g7wmP4bpf4zE9rrhsOkKfSLIY=",
+ "version": "1.0.10",
+ "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz",
+ "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==",
"dev": true,
"requires": {
"sprintf-js": "1.0.3"
@@ -188,23 +181,6 @@
"repeat-element": "1.1.2"
}
},
- "browser-resolve": {
- "version": "1.11.2",
- "resolved": "https://registry.npmjs.org/browser-resolve/-/browser-resolve-1.11.2.tgz",
- "integrity": "sha1-j/CbCixCFxihBRwmCzLkj0QpOM4=",
- "dev": true,
- "requires": {
- "resolve": "1.1.7"
- },
- "dependencies": {
- "resolve": {
- "version": "1.1.7",
- "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.1.7.tgz",
- "integrity": "sha1-IDEU2CrSxe2ejgQRs5ModeiJ6Xs=",
- "dev": true
- }
- }
- },
"browser-stdout": {
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/browser-stdout/-/browser-stdout-1.3.0.tgz",
@@ -212,47 +188,28 @@
"dev": true
},
"buble": {
- "version": "0.16.0",
- "resolved": "https://registry.npmjs.org/buble/-/buble-0.16.0.tgz",
- "integrity": "sha512-Eb5vt1+IvXXPyYD1IIQIuaBwIuJOSWQ2kXzULlg5I83aLGF2qzcjRU2joYusnWFgAenvJ9xTOMvZvT0bb8BLbg==",
+ "version": "0.19.3",
+ "resolved": "https://registry.npmjs.org/buble/-/buble-0.19.3.tgz",
+ "integrity": "sha512-3B0Lcy2u6x6km0BqTz/FS3UnrOJlnIlBWsyjvtqzdtmWkqiS0+Sg4hc6L9Mmm63hZKTACpYS9vUeIoKSi1vcrQ==",
"dev": true,
"requires": {
- "acorn": "3.3.0",
- "acorn-jsx": "3.0.1",
- "acorn-object-spread": "1.0.0",
- "chalk": "1.1.3",
- "magic-string": "0.14.0",
+ "acorn": "5.5.0",
+ "acorn-dynamic-import": "3.0.0",
+ "acorn-jsx": "4.1.1",
+ "chalk": "2.3.2",
+ "magic-string": "0.22.4",
"minimist": "1.2.0",
"os-homedir": "1.0.2",
- "vlq": "0.2.2"
+ "vlq": "1.0.0"
},
"dependencies": {
- "acorn": {
- "version": "3.3.0",
- "resolved": "https://registry.npmjs.org/acorn/-/acorn-3.3.0.tgz",
- "integrity": "sha1-ReN/s56No/JbruP/U2niu18iAXo=",
- "dev": true
- },
- "chalk": {
- "version": "1.1.3",
- "resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz",
- "integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=",
- "dev": true,
- "requires": {
- "ansi-styles": "2.2.1",
- "escape-string-regexp": "1.0.5",
- "has-ansi": "2.0.0",
- "strip-ansi": "3.0.1",
- "supports-color": "2.0.0"
- }
- },
- "magic-string": {
- "version": "0.14.0",
- "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.14.0.tgz",
- "integrity": "sha1-VyJK7xcByu7Sc7F6OalW5ysXJGI=",
+ "acorn-jsx": {
+ "version": "4.1.1",
+ "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-4.1.1.tgz",
+ "integrity": "sha512-JY+iV6r+cO21KtntVvFkD+iqjtdpRUpGqKWgfkCdZq1R+kbreEl8EcdcJR4SmiIgsIQT33s6QzheQ9a275Q8xw==",
"dev": true,
"requires": {
- "vlq": "0.2.2"
+ "acorn": "5.5.0"
}
},
"minimist": {
@@ -261,14 +218,11 @@
"integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=",
"dev": true
},
- "strip-ansi": {
- "version": "3.0.1",
- "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz",
- "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=",
- "dev": true,
- "requires": {
- "ansi-regex": "2.1.1"
- }
+ "vlq": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/vlq/-/vlq-1.0.0.tgz",
+ "integrity": "sha512-o3WmXySo+oI5thgqr7Qy8uBkT/v9Zr+sRyrh1lr8aWPUkgDWdWt4Nae2WKBrLsocgE8BuWWD0jLc+VW8LeU+2g==",
+ "dev": true
}
}
},
@@ -294,36 +248,42 @@
"dev": true
},
"chalk": {
- "version": "2.1.0",
- "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.1.0.tgz",
- "integrity": "sha512-LUHGS/dge4ujbXMJrnihYMcL4AoOweGnw9Tp3kQuqy1Kx5c1qKjqvMJZ6nVJPMWJtKCTN72ZogH3oeSO9g9rXQ==",
+ "version": "2.3.2",
+ "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.3.2.tgz",
+ "integrity": "sha512-ZM4j2/ld/YZDc3Ma8PgN7gyAk+kHMMMyzLNryCPGhWrsfAuDVeuid5bpRFTDgMH9JBK2lA4dyyAkkZYF/WcqDQ==",
"dev": true,
"requires": {
- "ansi-styles": "3.2.0",
+ "ansi-styles": "3.2.1",
"escape-string-regexp": "1.0.5",
- "supports-color": "4.4.0"
+ "supports-color": "5.3.0"
},
"dependencies": {
"ansi-styles": {
- "version": "3.2.0",
- "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.0.tgz",
- "integrity": "sha512-NnSOmMEYtVR2JVMIGTzynRkkaxtiq1xnFBcdQD/DnNCYPoEPsVJhM98BDyaoNOQIi7p4okdi3E27eN7GQbsUug==",
+ "version": "3.2.1",
+ "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz",
+ "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==",
"dev": true,
"requires": {
- "color-convert": "1.9.0"
+ "color-convert": "1.9.1"
}
},
"supports-color": {
- "version": "4.4.0",
- "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-4.4.0.tgz",
- "integrity": "sha512-rKC3+DyXWgK0ZLKwmRsrkyHVZAjNkfzeehuFWdGGcqGDTZFH73+RH6S/RDAAxl9GusSjZSUWYLmT9N5pzXFOXQ==",
+ "version": "5.3.0",
+ "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.3.0.tgz",
+ "integrity": "sha512-0aP01LLIskjKs3lq52EC0aGBAJhLq7B2Rd8HC/DR/PtNNpcLilNmHC12O+hu0usQpo7wtHNRqtrhBwtDb0+dNg==",
"dev": true,
"requires": {
- "has-flag": "2.0.0"
+ "has-flag": "3.0.0"
}
}
}
},
+ "chardet": {
+ "version": "0.4.2",
+ "resolved": "https://registry.npmjs.org/chardet/-/chardet-0.4.2.tgz",
+ "integrity": "sha1-tUc7M9yXxCTl2Y3IfVXU2KKci/I=",
+ "dev": true
+ },
"circular-json": {
"version": "0.3.3",
"resolved": "https://registry.npmjs.org/circular-json/-/circular-json-0.3.3.tgz",
@@ -352,9 +312,9 @@
"dev": true
},
"color-convert": {
- "version": "1.9.0",
- "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.0.tgz",
- "integrity": "sha1-Gsz5fdc5uYO/mU1W/sj5WFNkG3o=",
+ "version": "1.9.1",
+ "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.1.tgz",
+ "integrity": "sha512-mjGanIiwQJskCC18rPR6OmrZ6fm2Lc7PeGFYwCmy5J34wC6F1PzdGL6xeMfmgicfYcNLGuVFA3WzXtIDCQSZxQ==",
"dev": true,
"requires": {
"color-name": "1.1.3"
@@ -379,13 +339,13 @@
"dev": true
},
"concat-stream": {
- "version": "1.6.0",
- "resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.6.0.tgz",
- "integrity": "sha1-CqxmL9Ur54lk1VMvaUeE5wEQrPc=",
+ "version": "1.6.1",
+ "resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.6.1.tgz",
+ "integrity": "sha512-gslSSJx03QKa59cIKqeJO9HQ/WZMotvYJCuaUULrLpjj8oG40kV2Z+gz82pVxlTkOADi4PJxQPPfhl1ELYrrXw==",
"dev": true,
"requires": {
"inherits": "2.0.3",
- "readable-stream": "2.3.3",
+ "readable-stream": "2.3.5",
"typedarray": "0.0.6"
}
},
@@ -443,13 +403,12 @@
"dev": true
},
"doctrine": {
- "version": "2.0.0",
- "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-2.0.0.tgz",
- "integrity": "sha1-xz2NKQnSIpHhoAejlYBNqLZl/mM=",
+ "version": "2.1.0",
+ "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-2.1.0.tgz",
+ "integrity": "sha512-35mSku4ZXK0vfCuHEDAwt55dg2jNajHZ1odvF+8SSr82EsZY4QmXfuWso8oEd8zRhVObSN18aM0CjSdoBX7zIw==",
"dev": true,
"requires": {
- "esutils": "2.0.2",
- "isarray": "1.0.0"
+ "esutils": "2.0.2"
}
},
"es6-object-assign": {
@@ -465,35 +424,35 @@
"dev": true
},
"eslint": {
- "version": "4.8.0",
- "resolved": "https://registry.npmjs.org/eslint/-/eslint-4.8.0.tgz",
- "integrity": "sha1-Ip7w41Tg5h2DfHqA/fuoJeGZgV4=",
+ "version": "4.18.2",
+ "resolved": "https://registry.npmjs.org/eslint/-/eslint-4.18.2.tgz",
+ "integrity": "sha512-qy4i3wODqKMYfz9LUI8N2qYDkHkoieTbiHpMrYUI/WbjhXJQr7lI4VngixTgaG+yHX+NBCv7nW4hA0ShbvaNKw==",
"dev": true,
"requires": {
- "ajv": "5.2.3",
+ "ajv": "5.5.2",
"babel-code-frame": "6.26.0",
- "chalk": "2.1.0",
- "concat-stream": "1.6.0",
+ "chalk": "2.3.2",
+ "concat-stream": "1.6.1",
"cross-spawn": "5.1.0",
"debug": "3.1.0",
- "doctrine": "2.0.0",
+ "doctrine": "2.1.0",
"eslint-scope": "3.7.1",
- "espree": "3.5.1",
+ "eslint-visitor-keys": "1.0.0",
+ "espree": "3.5.4",
"esquery": "1.0.0",
- "estraverse": "4.2.0",
"esutils": "2.0.2",
"file-entry-cache": "2.0.0",
"functional-red-black-tree": "1.0.1",
"glob": "7.1.2",
- "globals": "9.18.0",
- "ignore": "3.3.5",
+ "globals": "11.3.0",
+ "ignore": "3.3.7",
"imurmurhash": "0.1.4",
"inquirer": "3.3.0",
- "is-resolvable": "1.0.0",
- "js-yaml": "3.10.0",
- "json-stable-stringify": "1.0.1",
+ "is-resolvable": "1.1.0",
+ "js-yaml": "3.11.0",
+ "json-stable-stringify-without-jsonify": "1.0.1",
"levn": "0.3.0",
- "lodash": "4.17.4",
+ "lodash": "4.17.5",
"minimatch": "3.0.4",
"mkdirp": "0.5.1",
"natural-compare": "1.4.0",
@@ -502,7 +461,7 @@
"pluralize": "7.0.0",
"progress": "2.0.0",
"require-uncached": "1.0.3",
- "semver": "5.4.1",
+ "semver": "5.5.0",
"strip-ansi": "4.0.0",
"strip-json-comments": "2.0.1",
"table": "4.0.2",
@@ -515,17 +474,23 @@
"integrity": "sha1-PWPD7f2gLgbgGkUq2IyqzHzctug=",
"dev": true,
"requires": {
- "esrecurse": "4.2.0",
+ "esrecurse": "4.2.1",
"estraverse": "4.2.0"
}
},
+ "eslint-visitor-keys": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-1.0.0.tgz",
+ "integrity": "sha512-qzm/XxIbxm/FHyH341ZrbnMUpe+5Bocte9xkmFMzPMjRaZMcXww+MpBptFvtU+79L362nqiLhekCxCxDPaUMBQ==",
+ "dev": true
+ },
"espree": {
- "version": "3.5.1",
- "resolved": "https://registry.npmjs.org/espree/-/espree-3.5.1.tgz",
- "integrity": "sha1-DJiLirRttTEAoZVK5LqZXd0n2H4=",
+ "version": "3.5.4",
+ "resolved": "https://registry.npmjs.org/espree/-/espree-3.5.4.tgz",
+ "integrity": "sha512-yAcIQxtmMiB/jL32dzEp2enBeidsB7xWPLNiw3IIkpVds1P+h7qF9YwJq1yUNzp2OKXgAprs4F61ih66UsoD1A==",
"dev": true,
"requires": {
- "acorn": "5.2.1",
+ "acorn": "5.5.0",
"acorn-jsx": "3.0.1"
}
},
@@ -545,13 +510,12 @@
}
},
"esrecurse": {
- "version": "4.2.0",
- "resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.2.0.tgz",
- "integrity": "sha1-+pVo2Y04I/mkHZHpAtyrnqblsWM=",
+ "version": "4.2.1",
+ "resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.2.1.tgz",
+ "integrity": "sha512-64RBB++fIOAXPw3P9cy89qfMlvZEXZkqqJkjqqXIvzP5ezRZjW+lPWjw35UX/3EhUPFYbg5ER4JYgDw4007/DQ==",
"dev": true,
"requires": {
- "estraverse": "4.2.0",
- "object-assign": "4.1.1"
+ "estraverse": "4.2.0"
}
},
"estraverse": {
@@ -561,9 +525,9 @@
"dev": true
},
"estree-walker": {
- "version": "0.5.0",
- "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-0.5.0.tgz",
- "integrity": "sha512-/bEAy+yKAZQrEWUhGmS3H9XpGqSDBtRzX0I2PgMw9kA2n1jN22uV5B5p7MFdZdvWdXCRJztXAfx6ZeRfgkEETg=="
+ "version": "0.5.1",
+ "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-0.5.1.tgz",
+ "integrity": "sha512-7HgCgz1axW7w5aOvgOQkoR1RMBkllygJrssU3BvymKQ95lxXYv6Pon17fBRDm9qhkvXZGijOULoSF9ShOk/ZLg=="
},
"esutils": {
"version": "2.0.2",
@@ -588,13 +552,13 @@
}
},
"external-editor": {
- "version": "2.0.5",
- "resolved": "https://registry.npmjs.org/external-editor/-/external-editor-2.0.5.tgz",
- "integrity": "sha512-Msjo64WT5W+NhOpQXh0nOHm+n0RfU1QUwDnKYvJ8dEJ8zlwLrqXNTv5mSUTJpepf41PDJGyhueTw2vNZW+Fr/w==",
+ "version": "2.1.0",
+ "resolved": "https://registry.npmjs.org/external-editor/-/external-editor-2.1.0.tgz",
+ "integrity": "sha512-E44iT5QVOUJBKij4IIV3uvxuNlbKS38Tw1HiupxEIHPv9qtC2PrDYohbXV5U+1jnfIXttny8gUhj+oZvflFlzA==",
"dev": true,
"requires": {
+ "chardet": "0.4.2",
"iconv-lite": "0.4.19",
- "jschardet": "1.5.1",
"tmp": "0.0.33"
}
},
@@ -607,9 +571,15 @@
}
},
"fast-deep-equal": {
- "version": "1.0.0",
- "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-1.0.0.tgz",
- "integrity": "sha1-liVqO8l1WV6zbYLpkp0GDYk0Of8=",
+ "version": "1.1.0",
+ "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-1.1.0.tgz",
+ "integrity": "sha1-wFNHeBfIa1HaqFPIHgWbcz0CNhQ=",
+ "dev": true
+ },
+ "fast-json-stable-stringify": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.0.0.tgz",
+ "integrity": "sha1-1RQsDK7msRifh9OnYREGT4bIu/I=",
"dev": true
},
"fast-levenshtein": {
@@ -723,9 +693,9 @@
}
},
"globals": {
- "version": "9.18.0",
- "resolved": "https://registry.npmjs.org/globals/-/globals-9.18.0.tgz",
- "integrity": "sha512-S0nG3CLEQiY/ILxqtztTWH/3iRRdyBLw6KMDxnKMchrtbj2OFmehVh0WUCfW3DUrIgx/qFrJPICrq4Z4sTR9UQ==",
+ "version": "11.3.0",
+ "resolved": "https://registry.npmjs.org/globals/-/globals-11.3.0.tgz",
+ "integrity": "sha512-kkpcKNlmQan9Z5ZmgqKH/SMbSmjxQ7QjyNqfXVc8VJcoBV2UEg+sxQD15GQofGRh2hfpwUb70VC31DR7Rq5Hdw==",
"dev": true
},
"globby": {
@@ -764,9 +734,9 @@
}
},
"has-flag": {
- "version": "2.0.0",
- "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-2.0.0.tgz",
- "integrity": "sha1-6CB68cx7MNRGzHC3NLXovhj4jVE=",
+ "version": "3.0.0",
+ "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz",
+ "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=",
"dev": true
},
"he": {
@@ -782,9 +752,9 @@
"dev": true
},
"ignore": {
- "version": "3.3.5",
- "resolved": "https://registry.npmjs.org/ignore/-/ignore-3.3.5.tgz",
- "integrity": "sha512-JLH93mL8amZQhh/p6mfQgVBH3M6epNq3DfsXsTSuSrInVjwyYlFE1nv2AgfRCC8PoOhM0jwQ5v8s9LgbK7yGDw==",
+ "version": "3.3.7",
+ "resolved": "https://registry.npmjs.org/ignore/-/ignore-3.3.7.tgz",
+ "integrity": "sha512-YGG3ejvBNHRqu0559EOxxNFihD0AjpvHlC/pdGKd3X3ofe+CoJkYazwNJYTNebqpPKN+VVQbh4ZFn1DivMNuHA==",
"dev": true
},
"imurmurhash": {
@@ -816,12 +786,12 @@
"dev": true,
"requires": {
"ansi-escapes": "3.0.0",
- "chalk": "2.1.0",
+ "chalk": "2.3.2",
"cli-cursor": "2.1.0",
"cli-width": "2.2.0",
- "external-editor": "2.0.5",
+ "external-editor": "2.1.0",
"figures": "2.0.0",
- "lodash": "4.17.4",
+ "lodash": "4.17.5",
"mute-stream": "0.0.7",
"run-async": "2.3.0",
"rx-lite": "4.0.8",
@@ -905,13 +875,13 @@
"integrity": "sha1-ZHdYK4IU1gI0YJRWcAO+ip6sBNw=",
"dev": true,
"requires": {
- "is-path-inside": "1.0.0"
+ "is-path-inside": "1.0.1"
}
},
"is-path-inside": {
- "version": "1.0.0",
- "resolved": "https://registry.npmjs.org/is-path-inside/-/is-path-inside-1.0.0.tgz",
- "integrity": "sha1-/AbloWg/vaE95mev9xe7wQpI838=",
+ "version": "1.0.1",
+ "resolved": "https://registry.npmjs.org/is-path-inside/-/is-path-inside-1.0.1.tgz",
+ "integrity": "sha1-jvW33lBDej/cprToZe96pVy0gDY=",
"dev": true,
"requires": {
"path-is-inside": "1.0.2"
@@ -934,13 +904,10 @@
"dev": true
},
"is-resolvable": {
- "version": "1.0.0",
- "resolved": "https://registry.npmjs.org/is-resolvable/-/is-resolvable-1.0.0.tgz",
- "integrity": "sha1-jfV8YeouPFAUCNEA+wE8+NbgzGI=",
- "dev": true,
- "requires": {
- "tryit": "1.0.3"
- }
+ "version": "1.1.0",
+ "resolved": "https://registry.npmjs.org/is-resolvable/-/is-resolvable-1.1.0.tgz",
+ "integrity": "sha512-qgDYXFSR5WvEfuS5dMj6oTMEbrrSaM0CrFk2Yiq/gXnBvD9pMa2jGXxyhGLfvhZpuMZe18CJpFxAt3CRs42NMg==",
+ "dev": true
},
"isarray": {
"version": "1.0.0",
@@ -968,40 +935,25 @@
"dev": true
},
"js-yaml": {
- "version": "3.10.0",
- "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.10.0.tgz",
- "integrity": "sha512-O2v52ffjLa9VeM43J4XocZE//WT9N0IiwDa3KSHH7Tu8CtH+1qM8SIZvnsTh6v+4yFy5KUY3BHUVwjpfAWsjIA==",
+ "version": "3.11.0",
+ "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.11.0.tgz",
+ "integrity": "sha512-saJstZWv7oNeOyBh3+Dx1qWzhW0+e6/8eDzo7p5rDFqxntSztloLtuKu+Ejhtq82jsilwOIZYsCz+lIjthg1Hw==",
"dev": true,
"requires": {
- "argparse": "1.0.9",
+ "argparse": "1.0.10",
"esprima": "4.0.0"
}
},
- "jschardet": {
- "version": "1.5.1",
- "resolved": "https://registry.npmjs.org/jschardet/-/jschardet-1.5.1.tgz",
- "integrity": "sha512-vE2hT1D0HLZCLLclfBSfkfTTedhVj0fubHpJBHKwwUWX0nSbhPAfk+SG9rTX95BYNmau8rGFfCeaT6T5OW1C2A==",
- "dev": true
- },
"json-schema-traverse": {
"version": "0.3.1",
"resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.3.1.tgz",
"integrity": "sha1-NJptRMU6Ud6JtAgFxdXlm0F9M0A=",
"dev": true
},
- "json-stable-stringify": {
+ "json-stable-stringify-without-jsonify": {
"version": "1.0.1",
- "resolved": "https://registry.npmjs.org/json-stable-stringify/-/json-stable-stringify-1.0.1.tgz",
- "integrity": "sha1-mnWdOcXy/1A/1TAGRu1EX4jE+a8=",
- "dev": true,
- "requires": {
- "jsonify": "0.0.0"
- }
- },
- "jsonify": {
- "version": "0.0.0",
- "resolved": "https://registry.npmjs.org/jsonify/-/jsonify-0.0.0.tgz",
- "integrity": "sha1-LHS27kHZPKUbe1qu6PUDYx0lKnM=",
+ "resolved": "https://registry.npmjs.org/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz",
+ "integrity": "sha1-nbe1lJatPzz+8wp1FC0tkwrXJlE=",
"dev": true
},
"kind-of": {
@@ -1023,15 +975,15 @@
}
},
"locate-character": {
- "version": "2.0.1",
- "resolved": "https://registry.npmjs.org/locate-character/-/locate-character-2.0.1.tgz",
- "integrity": "sha1-SPlZnzQtryb3PbMvRZQerje645E=",
+ "version": "2.0.5",
+ "resolved": "https://registry.npmjs.org/locate-character/-/locate-character-2.0.5.tgz",
+ "integrity": "sha512-n2GmejDXtOPBAZdIiEFy5dJ5N38xBCXLNOtw2WpB9kGh6pnrEuKlwYI+Tkpofc4wDtVXHtoAOJaMRlYG/oYaxg==",
"dev": true
},
"lodash": {
- "version": "4.17.4",
- "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.4.tgz",
- "integrity": "sha1-eCA6TRwyiuHYbcpkYONptX9AVa4=",
+ "version": "4.17.5",
+ "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.5.tgz",
+ "integrity": "sha512-svL3uiZf1RwhH+cWrfZn3A4+U58wbP0tGVTLQPbjplZxZ8ROD9VLuNgsRniTlLe7OlSqR79RUehXgpBW/s0IQw==",
"dev": true
},
"lru-cache": {
@@ -1073,9 +1025,9 @@
}
},
"mimic-fn": {
- "version": "1.1.0",
- "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-1.1.0.tgz",
- "integrity": "sha1-5md4PZLonb00KBi1IwudYqZyrRg=",
+ "version": "1.2.0",
+ "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-1.2.0.tgz",
+ "integrity": "sha512-jf84uxzwiuiIVKiOLpfYk7N46TSy8ubTonmneY9vrpHNAnp0QBt2BxWV9dO3/j+BoVAb+a5G6YDPW3M5HOdMWQ==",
"dev": true
},
"minimatch": {
@@ -1103,9 +1055,9 @@
}
},
"mocha": {
- "version": "4.0.1",
- "resolved": "https://registry.npmjs.org/mocha/-/mocha-4.0.1.tgz",
- "integrity": "sha512-evDmhkoA+cBNiQQQdSKZa2b9+W2mpLoj50367lhy+Klnx9OV8XlCIhigUnn1gaTFLQCa0kdNhEGDr0hCXOQFDw==",
+ "version": "5.0.1",
+ "resolved": "https://registry.npmjs.org/mocha/-/mocha-5.0.1.tgz",
+ "integrity": "sha512-SpwyojlnE/WRBNGtvJSNfllfm5PqEDFxcWluSIgLeSBJtXG4DmoX2NNAeEA7rP5kK+79VgtVq8nG6HskaL1ykg==",
"dev": true,
"requires": {
"browser-stdout": "1.3.0",
@@ -1120,6 +1072,12 @@
"supports-color": "4.4.0"
},
"dependencies": {
+ "has-flag": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-2.0.0.tgz",
+ "integrity": "sha1-6CB68cx7MNRGzHC3NLXovhj4jVE=",
+ "dev": true
+ },
"supports-color": {
"version": "4.4.0",
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-4.4.0.tgz",
@@ -1187,7 +1145,7 @@
"integrity": "sha1-BnQoIw/WdEOyeUsiu6UotoZ5YtQ=",
"dev": true,
"requires": {
- "mimic-fn": "1.1.0"
+ "mimic-fn": "1.2.0"
}
},
"optionator": {
@@ -1283,9 +1241,9 @@
"integrity": "sha1-gV7R9uvGWSb4ZbMQwHE7yzMVzks="
},
"process-nextick-args": {
- "version": "1.0.7",
- "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-1.0.7.tgz",
- "integrity": "sha1-FQ4gt1ZZCtP5EJPyWk8q2L/zC6M=",
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.0.tgz",
+ "integrity": "sha512-MtEC1TqN0EU5nephaJ4rAtThHtC86dNN9qCuEhtshvpVBkAW5ZO7BASN9REnF9eoXGcRub+pFuKEpOHE+HbEMw==",
"dev": true
},
"progress": {
@@ -1338,15 +1296,15 @@
}
},
"readable-stream": {
- "version": "2.3.3",
- "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.3.tgz",
- "integrity": "sha512-m+qzzcn7KUxEmd1gMbchF+Y2eIUbieUaxkWtptyHywrX0rE8QEYqPC07Vuy4Wm32/xE16NcdBctb8S0Xe/5IeQ==",
+ "version": "2.3.5",
+ "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.5.tgz",
+ "integrity": "sha512-tK0yDhrkygt/knjowCUiWP9YdV7c5R+8cR0r/kt9ZhBU906Fs6RpQJCEilamRJj1Nx2rWI6LkW9gKqjTkshhEw==",
"dev": true,
"requires": {
"core-util-is": "1.0.2",
"inherits": "2.0.3",
"isarray": "1.0.0",
- "process-nextick-args": "1.0.7",
+ "process-nextick-args": "2.0.0",
"safe-buffer": "5.1.1",
"string_decoder": "1.0.3",
"util-deprecate": "1.0.2"
@@ -1358,7 +1316,7 @@
"integrity": "sha1-hSBLVNuoLVdC4oyWdW70OvUOM4Q=",
"dev": true,
"requires": {
- "resolve": "1.4.0"
+ "resolve": "1.5.0"
}
},
"regex-cache": {
@@ -1402,9 +1360,9 @@
}
},
"resolve": {
- "version": "1.4.0",
- "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.4.0.tgz",
- "integrity": "sha512-aW7sVKPufyHqOmyyLzg/J+8606v5nevBgaliIlV7nUpVMsDnoBGV/cbSLNjZAg9q0Cfd/+easKVKQ8vOu8fn1Q==",
+ "version": "1.5.0",
+ "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.5.0.tgz",
+ "integrity": "sha512-hgoSGrc3pjzAPHNBg+KnFcK2HwlHTs/YrAGUr6qgTVUZmXv1UEXXl0bZNBKMA9fud6lRYFdPGz0xXxycPzmmiw==",
"requires": {
"path-parse": "1.0.5"
}
@@ -1435,31 +1393,30 @@
}
},
"rollup": {
- "version": "0.55.0",
- "resolved": "https://registry.npmjs.org/rollup/-/rollup-0.55.0.tgz",
- "integrity": "sha512-uCwDXz2qHQ0XsPekrLIeIEORSF32Zfk1H057ENgb+sj84m10pWaG2YGQSvF8kvyf0WLcrzk2TzYuC/+iZP4hyA==",
+ "version": "0.56.4",
+ "resolved": "https://registry.npmjs.org/rollup/-/rollup-0.56.4.tgz",
+ "integrity": "sha512-Ja1ph+tZSE9sY5/WURJCuhaU2+2LTKKmhvxG7Smunn37s7aESLDFUj5XMnSYMypytwxeTvpy8ZzFfEeFiYMyug==",
"dev": true
},
"rollup-plugin-buble": {
- "version": "0.16.0",
- "resolved": "https://registry.npmjs.org/rollup-plugin-buble/-/rollup-plugin-buble-0.16.0.tgz",
- "integrity": "sha512-dPIvH9iK9AUGRrqpARL6TTNY85BJpc5OK5PiCAnFaRe7C1boRBVRXiL0SYsYNVnyYYPl6vu0lVSb722eMSw1Eg==",
+ "version": "0.19.2",
+ "resolved": "https://registry.npmjs.org/rollup-plugin-buble/-/rollup-plugin-buble-0.19.2.tgz",
+ "integrity": "sha512-dxK0prR8j/7qhI2EZDz/evKCRuhuZMpRlUGPrRWmpg5/2V8tP1XFW+Uk0WfxyNgFfJHvy0GmxnJSTb5dIaNljQ==",
"dev": true,
"requires": {
- "buble": "0.16.0",
+ "buble": "0.19.3",
"rollup-pluginutils": "2.0.1"
}
},
"rollup-plugin-node-resolve": {
- "version": "3.0.0",
- "resolved": "https://registry.npmjs.org/rollup-plugin-node-resolve/-/rollup-plugin-node-resolve-3.0.0.tgz",
- "integrity": "sha1-i4l8TDAw1QASd7BRSyXSygloPuA=",
+ "version": "3.0.3",
+ "resolved": "https://registry.npmjs.org/rollup-plugin-node-resolve/-/rollup-plugin-node-resolve-3.0.3.tgz",
+ "integrity": "sha512-qJLXJ1aASV6p8SrEfRdQdHmb5OQmqXyIWIdVGcju8QFzftSsHcuL554Vy+n8mr0fZCC+ksO6aWJ7TAVl2F+Qwg==",
"dev": true,
"requires": {
- "browser-resolve": "1.11.2",
"builtin-modules": "1.1.1",
"is-module": "1.0.0",
- "resolve": "1.4.0"
+ "resolve": "1.5.0"
}
},
"rollup-pluginutils": {
@@ -1509,9 +1466,9 @@
"dev": true
},
"semver": {
- "version": "5.4.1",
- "resolved": "https://registry.npmjs.org/semver/-/semver-5.4.1.tgz",
- "integrity": "sha512-WfG/X9+oATh81XtllIo/I8gOiY9EXRdv1cQdyykeXK17YcUW3EXUAi2To4pcH6nZtJPr7ZOpM5OMyWJZm+8Rsg==",
+ "version": "5.5.0",
+ "resolved": "https://registry.npmjs.org/semver/-/semver-5.5.0.tgz",
+ "integrity": "sha512-4SJ3dm0WAwWy/NVeioZh5AntkdJoWKxHxcmyP622fOkgHa4z3R0TdBJICINyaSDE6uNwVc8gZr+ZinwZAH4xIA==",
"dev": true
},
"shebang-command": {
@@ -1581,9 +1538,9 @@
"dev": true
},
"source-map-support": {
- "version": "0.5.0",
- "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.0.tgz",
- "integrity": "sha512-vUoN3I7fHQe0R/SJLKRdKYuEdRGogsviXFkHHo17AWaTGv17VLnxw+CFXvqy+y4ORZ3doWLQcxRYfwKrsd/H7Q==",
+ "version": "0.5.3",
+ "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.3.tgz",
+ "integrity": "sha512-eKkTgWYeBOQqFGXRfKabMFdnWepo51vWqEdoeikaEPFiJC7MCU5j2h4+6Q8npkZTeLGbSyecZvRxiSoWl3rh+w==",
"dev": true,
"requires": {
"source-map": "0.6.1"
@@ -1595,15 +1552,6 @@
"integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=",
"dev": true
},
- "string_decoder": {
- "version": "1.0.3",
- "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.3.tgz",
- "integrity": "sha512-4AH6Z5fzNNBcH+6XDMfA/BTt87skxqJlO0lAh3Dker5zThcAxG6mKz+iGu308UKoPPQ8Dcqx/4JhujzltRa+hQ==",
- "dev": true,
- "requires": {
- "safe-buffer": "5.1.1"
- }
- },
"string-width": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz",
@@ -1614,6 +1562,15 @@
"strip-ansi": "4.0.0"
}
},
+ "string_decoder": {
+ "version": "1.0.3",
+ "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.3.tgz",
+ "integrity": "sha512-4AH6Z5fzNNBcH+6XDMfA/BTt87skxqJlO0lAh3Dker5zThcAxG6mKz+iGu308UKoPPQ8Dcqx/4JhujzltRa+hQ==",
+ "dev": true,
+ "requires": {
+ "safe-buffer": "5.1.1"
+ }
+ },
"strip-ansi": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz",
@@ -1649,10 +1606,10 @@
"integrity": "sha512-UUkEAPdSGxtRpiV9ozJ5cMTtYiqz7Ni1OGqLXRCynrvzdtR1p+cfOWe2RJLwvUG8hNanaSRjecIqwOjqeatDsA==",
"dev": true,
"requires": {
- "ajv": "5.2.3",
- "ajv-keywords": "2.1.0",
- "chalk": "2.1.0",
- "lodash": "4.17.4",
+ "ajv": "5.5.2",
+ "ajv-keywords": "2.1.1",
+ "chalk": "2.3.2",
+ "lodash": "4.17.5",
"slice-ansi": "1.0.0",
"string-width": "2.1.1"
}
@@ -1678,12 +1635,6 @@
"os-tmpdir": "1.0.2"
}
},
- "tryit": {
- "version": "1.0.3",
- "resolved": "https://registry.npmjs.org/tryit/-/tryit-1.0.3.tgz",
- "integrity": "sha1-OTvnMKlEb9Hq1tpZoBQwjzbCics=",
- "dev": true
- },
"type-check": {
"version": "0.3.2",
"resolved": "https://registry.npmjs.org/type-check/-/type-check-0.3.2.tgz",
diff --git a/package.json b/package.json
index fd0d3d3..403437a 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "rollup-plugin-commonjs",
- "version": "8.3.0",
+ "version": "9.0.0",
"description": "Convert CommonJS modules to ES2015",
"main": "dist/rollup-plugin-commonjs.cjs.js",
"module": "dist/rollup-plugin-commonjs.es.js",
@@ -20,24 +20,27 @@
"dist",
"README.md"
],
+ "peerDependencies": {
+ "rollup": ">=0.56.0"
+ },
"dependencies": {
- "acorn": "^5.2.1",
- "estree-walker": "^0.5.0",
+ "estree-walker": "^0.5.1",
"magic-string": "^0.22.4",
- "resolve": "^1.4.0",
+ "resolve": "^1.5.0",
"rollup-pluginutils": "^2.0.1"
},
"devDependencies": {
- "eslint": "^4.8.0",
- "locate-character": "^2.0.1",
- "mocha": "^4.0.1",
+ "acorn": "^5.5.0",
+ "eslint": "^4.18.2",
+ "locate-character": "^2.0.5",
+ "mocha": "^5.0.1",
"require-relative": "^0.8.7",
- "rollup": "^0.55.0",
- "rollup-plugin-buble": "^0.16.0",
- "rollup-plugin-node-resolve": "^3.0.0",
+ "rollup": "^0.56.4",
+ "rollup-plugin-buble": "^0.19.2",
+ "rollup-plugin-node-resolve": "^3.0.3",
"shx": "^0.2.2",
"source-map": "^0.6.1",
- "source-map-support": "^0.5.0"
+ "source-map-support": "^0.5.3"
},
"repository": "rollup/rollup-plugin-commonjs",
"author": "Rich Harris",
diff --git a/src/index.js b/src/index.js
index f9c4f60..05616a1 100644
--- a/src/index.js
+++ b/src/index.js
@@ -169,7 +169,7 @@ export default function commonjs ( options = {} ) {
if ( extensions.indexOf( extname( id ) ) === -1 ) return null;
return entryModuleIdsPromise.then( (entryModuleIds) => {
- const {isEsModule, hasDefaultExport, ast} = checkEsModule( code, id );
+ const {isEsModule, hasDefaultExport, ast} = checkEsModule( this.parse, code, id );
if ( isEsModule ) {
if ( !hasDefaultExport )
esModulesWithoutDefaultExport.push( id );
@@ -182,11 +182,16 @@ export default function commonjs ( options = {} ) {
return;
}
- const transformed = transformCommonjs( code, id, entryModuleIds.indexOf(id) !== -1, ignoreGlobal, ignoreRequire, customNamedExports[ id ], sourceMap, allowDynamicRequire, ast );
- if ( !transformed ) return;
+ const transformed = transformCommonjs( this.parse, code, id, entryModuleIds.indexOf(id) !== -1, ignoreGlobal, ignoreRequire, customNamedExports[ id ], sourceMap, allowDynamicRequire, ast );
+ if ( !transformed ) {
+ esModulesWithoutDefaultExport.push( id );
+ return;
+ }
commonjsModules.set( id, true );
return transformed;
+ }).catch(err => {
+ this.error(err, err.loc);
});
}
};
diff --git a/src/transform.js b/src/transform.js
index 817a163..a24454c 100644
--- a/src/transform.js
+++ b/src/transform.js
@@ -1,4 +1,3 @@
-import acorn from 'acorn';
import { walk } from 'estree-walker';
import MagicString from 'magic-string';
import { attachScopes, makeLegalIdentifier } from 'rollup-pluginutils';
@@ -26,13 +25,9 @@ function deconflict ( scope, globals, identifier ) {
return deconflicted;
}
-function tryParse ( code, id ) {
+function tryParse ( parse, code, id ) {
try {
- return acorn.parse( code, {
- ecmaVersion: 8,
- sourceType: 'module',
- allowReturnOutsideFunction: true
- });
+ return parse( code, { allowReturnOutsideFunction: true });
} catch ( err ) {
err.message += ` in ${id}`;
throw err;
@@ -44,8 +39,8 @@ export function checkFirstpass (code, ignoreGlobal) {
return firstpass.test(code);
}
-export function checkEsModule (code, id) {
- const ast = tryParse(code, id);
+export function checkEsModule ( parse, code, id ) {
+ const ast = tryParse( parse, code, id );
// if there are top-level import/export declarations, this is ES not CommonJS
let hasDefaultExport = false;
@@ -60,8 +55,8 @@ export function checkEsModule (code, id) {
return { isEsModule, hasDefaultExport, ast };
}
-export function transformCommonjs ( code, id, isEntry, ignoreGlobal, ignoreRequire, customNamedExports, sourceMap, allowDynamicRequire, astCache ) {
- const ast = astCache || tryParse( code, id );
+export function transformCommonjs ( parse, code, id, isEntry, ignoreGlobal, ignoreRequire, customNamedExports, sourceMap, allowDynamicRequire, astCache ) {
+ const ast = astCache || tryParse( parse, code, id );
const magicString = new MagicString( code );
diff --git a/test/function/bare-import-comment/bar.js b/test/function/bare-import-comment/bar.js
new file mode 100644
index 0000000..3acfdc3
--- /dev/null
+++ b/test/function/bare-import-comment/bar.js
@@ -0,0 +1,2 @@
+// Great module
+Math.bar = 42;
diff --git a/test/function/bare-import-comment/foo.js b/test/function/bare-import-comment/foo.js
new file mode 100644
index 0000000..8578323
--- /dev/null
+++ b/test/function/bare-import-comment/foo.js
@@ -0,0 +1 @@
+require( './bar.js' );
diff --git a/test/function/bare-import-comment/main.js b/test/function/bare-import-comment/main.js
new file mode 100644
index 0000000..07d5ba7
--- /dev/null
+++ b/test/function/bare-import-comment/main.js
@@ -0,0 +1,3 @@
+import './foo.js';
+
+assert.equal( Math.bar, 42 );
diff --git a/test/samples/invalid-syntax/main.js b/test/samples/invalid-syntax/main.js
new file mode 100644
index 0000000..aabc960
--- /dev/null
+++ b/test/samples/invalid-syntax/main.js
@@ -0,0 +1 @@
+export const foo = 2,
\ No newline at end of file
diff --git a/test/test.js b/test/test.js
index f7f8723..846814b 100644
--- a/test/test.js
+++ b/test/test.js
@@ -1,3 +1,4 @@
+const acorn = require( 'acorn' );
const path = require( 'path' );
const fs = require( 'fs' );
const assert = require( 'assert' );
@@ -55,6 +56,14 @@ async function executeBundle ( bundle, { context, exports } = {} ) {
return execute( code, context );
}
+const transformContext = {
+ parse: ( input, options ) =>
+ acorn.parse( input, Object.assign( {
+ ecmaVersion: 9,
+ sourceType: 'module',
+ }, options ) )
+};
+
describe( 'rollup-plugin-commonjs', () => {
describe( 'form', () => {
fs.readdirSync( 'form' ).forEach( dir => {
@@ -73,7 +82,7 @@ describe( 'rollup-plugin-commonjs', () => {
const input = fs.readFileSync( `form/${dir}/input.js`, 'utf-8' );
const expected = fs.readFileSync( `form/${dir}/output.js`, 'utf-8' ).trim();
- return transform( input, 'input.js' ).then( transformed => {
+ return transform.call( transformContext, input, 'input.js' ).then( transformed => {
const actual = ( transformed ? transformed.code : input ).trim().replace( /\0/g, '' );
assert.equal( actual, expected );
});
@@ -481,6 +490,24 @@ describe( 'rollup-plugin-commonjs', () => {
onwarn: (warn) => warns.push( warn )
});
assert.equal( warns.length, 0 );
+
+ await rollup({
+ input: 'function/bare-import-comment/main.js',
+ plugins: [ commonjs() ],
+ onwarn: (warn) => warns.push( warn )
+ });
+ assert.equal( warns.length, 0 );
+ });
+
+ it( 'creates an error with a code frame when parsing fails', async () => {
+ try {
+ await rollup({
+ input: 'samples/invalid-syntax/main.js',
+ plugins: [ commonjs() ]
+ });
+ } catch (error) {
+ assert.equal( error.frame, '1: export const foo = 2,\n ^' );
+ }
});
});
});
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-rollup-plugin-commonjs.git
More information about the Pkg-javascript-commits
mailing list