[Pkg-javascript-commits] [node-rollup-plugin-commonjs] 01/06: New upstream version 8.2.4
Julien Puydt
julien.puydt at laposte.net
Sun Oct 22 07:27:25 UTC 2017
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 a3d099fcffc028282f5d0245a7d92a9b31827675
Author: Julien Puydt <julien.puydt at laposte.net>
Date: Sun Oct 22 09:21:58 2017 +0200
New upstream version 8.2.4
---
CHANGELOG.md | 10 +
README.md | 8 +-
package-lock.json | 418 +++++++--------------
package.json | 16 +-
src/helpers.js | 2 +-
src/index.js | 33 +-
src/transform.js | 37 +-
test/form/require-collision/input.js | 5 +
test/form/require-collision/output.js | 15 +
.../duplicate-default-exports-c/exports.js | 6 +
test/function/duplicate-default-exports-c/main.js | 11 +
.../es-modules-without-default-export/main.js | 3 +
.../es-modules-without-default-export/other.js | 1 +
test/samples/use-own-output/from-rollup.js | 2 +
test/samples/use-own-output/main.js | 2 +
test/test.js | 37 +-
16 files changed, 291 insertions(+), 315 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 973555c..dacf108 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,15 @@
# rollup-plugin-commonjs changelog
+## 8.2.4
+
+* Don't import default from ES modules that don't export default ([#206](https://github.com/rollup/rollup-plugin-commonjs/issues/206))
+
+## 8.2.3
+
+* Prevent duplicate default exports ([#230](https://github.com/rollup/rollup-plugin-commonjs/pull/230))
+* Only include default export when it exists ([#226](https://github.com/rollup/rollup-plugin-commonjs/pull/226))
+* Deconflict `require` aliases ([#232](https://github.com/rollup/rollup-plugin-commonjs/issues/232))
+
## 8.2.1
* Fix magic-string deprecation warning
diff --git a/README.md b/README.md
index b7a9fbb..4a446f7 100644
--- a/README.md
+++ b/README.md
@@ -23,9 +23,11 @@ import commonjs from 'rollup-plugin-commonjs';
import nodeResolve from 'rollup-plugin-node-resolve';
export default {
- entry: 'main.js',
- dest: 'bundle.js',
- format: 'iife',
+ input: 'main.js',
+ output: {
+ file: 'bundle.js',
+ format: 'iife'
+ },
plugins: [
nodeResolve({
jsnext: true,
diff --git a/package-lock.json b/package-lock.json
index f435049..bb7748c 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,13 +1,13 @@
{
"name": "rollup-plugin-commonjs",
- "version": "8.1.1",
+ "version": "8.2.3",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
"acorn": {
- "version": "5.1.1",
- "resolved": "https://registry.npmjs.org/acorn/-/acorn-5.1.1.tgz",
- "integrity": "sha512-vOk6uEMctu0vQrvuSqFdJyqj1Q0S5VTDL79qtjo+DhRr+1mmaD+tluFSCZqhvi/JUhXSzoZN2BhtstaPEeE8cw=="
+ "version": "5.1.2",
+ "resolved": "https://registry.npmjs.org/acorn/-/acorn-5.1.2.tgz",
+ "integrity": "sha512-o96FZLJBPY1lvTuJylGA9Bk3t/GKPPJG8H0ydQQl01crzwJgspa4AEIq/pVTXigmK0PHVQhiAtn8WMBLL9D2WA=="
},
"acorn-jsx": {
"version": "3.0.1",
@@ -44,9 +44,9 @@
}
},
"ajv": {
- "version": "5.2.2",
- "resolved": "https://registry.npmjs.org/ajv/-/ajv-5.2.2.tgz",
- "integrity": "sha1-R8aNaehvXZUxA7AHSpQw3GPaXjk=",
+ "version": "5.2.3",
+ "resolved": "https://registry.npmjs.org/ajv/-/ajv-5.2.3.tgz",
+ "integrity": "sha1-wG9Zh3jETGsWGrr+NGa4GtGBTtI=",
"dev": true,
"requires": {
"co": "4.6.0",
@@ -56,15 +56,15 @@
}
},
"ajv-keywords": {
- "version": "1.5.1",
- "resolved": "https://registry.npmjs.org/ajv-keywords/-/ajv-keywords-1.5.1.tgz",
- "integrity": "sha1-MU3QpLM2j609/NxU7eYXG4htrzw=",
+ "version": "2.1.0",
+ "resolved": "https://registry.npmjs.org/ajv-keywords/-/ajv-keywords-2.1.0.tgz",
+ "integrity": "sha1-opbhf3v658HOT34N5T0pyzIWLfA=",
"dev": true
},
"ansi-escapes": {
- "version": "2.0.0",
- "resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-2.0.0.tgz",
- "integrity": "sha1-W65SvkJIeN2Xg+iRDj/Cki6DyBs=",
+ "version": "3.0.0",
+ "resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-3.0.0.tgz",
+ "integrity": "sha512-O/klc27mWNUigtv0F8NJWbLF00OcegQalkqKURWdosW08YZKi4m6CnSUSvIZG1otNJbTWhN01Hhz389DW7mvDQ==",
"dev": true
},
"ansi-regex": {
@@ -212,9 +212,9 @@
"dev": true
},
"buble": {
- "version": "0.15.2",
- "resolved": "https://registry.npmjs.org/buble/-/buble-0.15.2.tgz",
- "integrity": "sha1-VH/EdIP45egXbYKqXrzLGDsC1hM=",
+ "version": "0.16.0",
+ "resolved": "https://registry.npmjs.org/buble/-/buble-0.16.0.tgz",
+ "integrity": "sha512-Eb5vt1+IvXXPyYD1IIQIuaBwIuJOSWQ2kXzULlg5I83aLGF2qzcjRU2joYusnWFgAenvJ9xTOMvZvT0bb8BLbg==",
"dev": true,
"requires": {
"acorn": "3.3.0",
@@ -223,7 +223,8 @@
"chalk": "1.1.3",
"magic-string": "0.14.0",
"minimist": "1.2.0",
- "os-homedir": "1.0.2"
+ "os-homedir": "1.0.2",
+ "vlq": "0.2.2"
},
"dependencies": {
"acorn": {
@@ -300,7 +301,7 @@
"requires": {
"ansi-styles": "3.2.0",
"escape-string-regexp": "1.0.5",
- "supports-color": "4.2.1"
+ "supports-color": "4.4.0"
},
"dependencies": {
"ansi-styles": {
@@ -313,9 +314,9 @@
}
},
"supports-color": {
- "version": "4.2.1",
- "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-4.2.1.tgz",
- "integrity": "sha512-qxzYsob3yv6U+xMzPrv170y8AwGP7i74g+pbixCfD6rgso8BscLT2qXIuz6TpOaiJZ3mFgT5O9lyT9nMU4LfaA==",
+ "version": "4.4.0",
+ "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-4.4.0.tgz",
+ "integrity": "sha512-rKC3+DyXWgK0ZLKwmRsrkyHVZAjNkfzeehuFWdGGcqGDTZFH73+RH6S/RDAAxl9GusSjZSUWYLmT9N5pzXFOXQ==",
"dev": true,
"requires": {
"has-flag": "2.0.0"
@@ -339,9 +340,9 @@
}
},
"cli-width": {
- "version": "2.1.0",
- "resolved": "https://registry.npmjs.org/cli-width/-/cli-width-2.1.0.tgz",
- "integrity": "sha1-sjTKIJsp72b8UY2bmNWEewDt8Ao=",
+ "version": "2.2.0",
+ "resolved": "https://registry.npmjs.org/cli-width/-/cli-width-2.2.0.tgz",
+ "integrity": "sha1-/xnt6Kml5XkyQUewwR8PvLq+1jk=",
"dev": true
},
"co": {
@@ -366,13 +367,10 @@
"dev": true
},
"commander": {
- "version": "2.9.0",
- "resolved": "https://registry.npmjs.org/commander/-/commander-2.9.0.tgz",
- "integrity": "sha1-nJkJQXbhIkDLItbFFGCYQA/g99Q=",
- "dev": true,
- "requires": {
- "graceful-readlink": "1.0.1"
- }
+ "version": "2.11.0",
+ "resolved": "https://registry.npmjs.org/commander/-/commander-2.11.0.tgz",
+ "integrity": "sha512-b0553uYA5YAEGgyYIGYROzKQ7X5RAqedkfjiZxwi0kL1g3bOaBNNZfYkzt/CL0umgD5wc9Jec2FbB98CjkMRvQ==",
+ "dev": true
},
"concat-map": {
"version": "0.0.1",
@@ -409,9 +407,9 @@
}
},
"debug": {
- "version": "2.6.8",
- "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.8.tgz",
- "integrity": "sha1-5zFTHKLt4n0YgiJCfaF4IdaP9Pw=",
+ "version": "3.1.0",
+ "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz",
+ "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==",
"dev": true,
"requires": {
"ms": "2.0.0"
@@ -435,13 +433,13 @@
"object-assign": "4.1.1",
"pify": "2.3.0",
"pinkie-promise": "2.0.1",
- "rimraf": "2.6.1"
+ "rimraf": "2.6.2"
}
},
"diff": {
- "version": "3.2.0",
- "resolved": "https://registry.npmjs.org/diff/-/diff-3.2.0.tgz",
- "integrity": "sha1-yc45Okt8vQsFinJck98pkCeGj/k=",
+ "version": "3.3.1",
+ "resolved": "https://registry.npmjs.org/diff/-/diff-3.3.1.tgz",
+ "integrity": "sha512-MKPHZDMB0o6yHyDryUOScqZibp914ksXwAMYMTHj6KO8UeKsRYNJD3oNCKjTqZon+V488P7N/HzXF8t7ZR95ww==",
"dev": true
},
"doctrine": {
@@ -467,20 +465,20 @@
"dev": true
},
"eslint": {
- "version": "4.5.0",
- "resolved": "https://registry.npmjs.org/eslint/-/eslint-4.5.0.tgz",
- "integrity": "sha1-u3XTuL3pf7XhPvzVOXRGd/6wGcM=",
+ "version": "4.8.0",
+ "resolved": "https://registry.npmjs.org/eslint/-/eslint-4.8.0.tgz",
+ "integrity": "sha1-Ip7w41Tg5h2DfHqA/fuoJeGZgV4=",
"dev": true,
"requires": {
- "ajv": "5.2.2",
+ "ajv": "5.2.3",
"babel-code-frame": "6.26.0",
"chalk": "2.1.0",
"concat-stream": "1.6.0",
"cross-spawn": "5.1.0",
- "debug": "2.6.8",
+ "debug": "3.1.0",
"doctrine": "2.0.0",
"eslint-scope": "3.7.1",
- "espree": "3.5.0",
+ "espree": "3.5.1",
"esquery": "1.0.0",
"estraverse": "4.2.0",
"esutils": "2.0.2",
@@ -488,11 +486,11 @@
"functional-red-black-tree": "1.0.1",
"glob": "7.1.2",
"globals": "9.18.0",
- "ignore": "3.3.3",
+ "ignore": "3.3.5",
"imurmurhash": "0.1.4",
- "inquirer": "3.2.2",
+ "inquirer": "3.3.0",
"is-resolvable": "1.0.0",
- "js-yaml": "3.9.1",
+ "js-yaml": "3.10.0",
"json-stable-stringify": "1.0.1",
"levn": "0.3.0",
"lodash": "4.17.4",
@@ -501,13 +499,13 @@
"natural-compare": "1.4.0",
"optionator": "0.8.2",
"path-is-inside": "1.0.2",
- "pluralize": "4.0.0",
+ "pluralize": "7.0.0",
"progress": "2.0.0",
"require-uncached": "1.0.3",
"semver": "5.4.1",
"strip-ansi": "4.0.0",
"strip-json-comments": "2.0.1",
- "table": "4.0.1",
+ "table": "4.0.2",
"text-table": "0.2.0"
}
},
@@ -522,12 +520,12 @@
}
},
"espree": {
- "version": "3.5.0",
- "resolved": "https://registry.npmjs.org/espree/-/espree-3.5.0.tgz",
- "integrity": "sha1-mDWGJb3QVYYeon4oZ+pyn69GPY0=",
+ "version": "3.5.1",
+ "resolved": "https://registry.npmjs.org/espree/-/espree-3.5.1.tgz",
+ "integrity": "sha1-DJiLirRttTEAoZVK5LqZXd0n2H4=",
"dev": true,
"requires": {
- "acorn": "5.1.1",
+ "acorn": "5.1.2",
"acorn-jsx": "3.0.1"
}
},
@@ -590,14 +588,14 @@
}
},
"external-editor": {
- "version": "2.0.4",
- "resolved": "https://registry.npmjs.org/external-editor/-/external-editor-2.0.4.tgz",
- "integrity": "sha1-HtkZnanL/i7y96MbL96LDRI2iXI=",
+ "version": "2.0.5",
+ "resolved": "https://registry.npmjs.org/external-editor/-/external-editor-2.0.5.tgz",
+ "integrity": "sha512-Msjo64WT5W+NhOpQXh0nOHm+n0RfU1QUwDnKYvJ8dEJ8zlwLrqXNTv5mSUTJpepf41PDJGyhueTw2vNZW+Fr/w==",
"dev": true,
"requires": {
- "iconv-lite": "0.4.18",
+ "iconv-lite": "0.4.19",
"jschardet": "1.5.1",
- "tmp": "0.0.31"
+ "tmp": "0.0.33"
}
},
"extglob": {
@@ -635,7 +633,7 @@
"integrity": "sha1-w5KZDD5oR4PYOLjISkXYoEhFg2E=",
"dev": true,
"requires": {
- "flat-cache": "1.2.2",
+ "flat-cache": "1.3.0",
"object-assign": "4.1.1"
}
},
@@ -657,9 +655,9 @@
}
},
"flat-cache": {
- "version": "1.2.2",
- "resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-1.2.2.tgz",
- "integrity": "sha1-+oZxTnLCHbiGAXYezy9VXRq8a5Y=",
+ "version": "1.3.0",
+ "resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-1.3.0.tgz",
+ "integrity": "sha1-0wMLMrOBVPTjt+nHCfSQ9++XxIE=",
"dev": true,
"requires": {
"circular-json": "0.3.3",
@@ -750,16 +748,10 @@
"integrity": "sha1-Dovf5NHduIVNZOBOp8AOKgJuVlg=",
"dev": true
},
- "graceful-readlink": {
- "version": "1.0.1",
- "resolved": "https://registry.npmjs.org/graceful-readlink/-/graceful-readlink-1.0.1.tgz",
- "integrity": "sha1-TK+tdrxi8C+gObL5Tpo906ORpyU=",
- "dev": true
- },
"growl": {
- "version": "1.9.2",
- "resolved": "https://registry.npmjs.org/growl/-/growl-1.9.2.tgz",
- "integrity": "sha1-Dqd0NxXbjY3ixe3hd14bRayFwC8=",
+ "version": "1.10.3",
+ "resolved": "https://registry.npmjs.org/growl/-/growl-1.10.3.tgz",
+ "integrity": "sha512-hKlsbA5Vu3xsh1Cg3J7jSmX/WaW6A5oBeqzM88oNbCRQFz+zUaXm6yxS4RVytp1scBoJzSYl4YAEOQIt6O8V1Q==",
"dev": true
},
"has-ansi": {
@@ -777,16 +769,22 @@
"integrity": "sha1-6CB68cx7MNRGzHC3NLXovhj4jVE=",
"dev": true
},
+ "he": {
+ "version": "1.1.1",
+ "resolved": "https://registry.npmjs.org/he/-/he-1.1.1.tgz",
+ "integrity": "sha1-k0EP0hsAlzUVH4howvJx80J+I/0=",
+ "dev": true
+ },
"iconv-lite": {
- "version": "0.4.18",
- "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.18.tgz",
- "integrity": "sha512-sr1ZQph3UwHTR0XftSbK85OvBbxe/abLGzEnPENCQwmHf7sck8Oyu4ob3LgBxWWxRoM+QszeUyl7jbqapu2TqA==",
+ "version": "0.4.19",
+ "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.19.tgz",
+ "integrity": "sha512-oTZqweIP51xaGPI4uPa56/Pri/480R+mo7SeU+YETByQNhDG55ycFyNLIgta9vXhILrxXDmF7ZGhqZIcuN0gJQ==",
"dev": true
},
"ignore": {
- "version": "3.3.3",
- "resolved": "https://registry.npmjs.org/ignore/-/ignore-3.3.3.tgz",
- "integrity": "sha1-QyNS5XrM2HqzEQ6C0/6g5HgSFW0=",
+ "version": "3.3.5",
+ "resolved": "https://registry.npmjs.org/ignore/-/ignore-3.3.5.tgz",
+ "integrity": "sha512-JLH93mL8amZQhh/p6mfQgVBH3M6epNq3DfsXsTSuSrInVjwyYlFE1nv2AgfRCC8PoOhM0jwQ5v8s9LgbK7yGDw==",
"dev": true
},
"imurmurhash": {
@@ -812,16 +810,16 @@
"dev": true
},
"inquirer": {
- "version": "3.2.2",
- "resolved": "https://registry.npmjs.org/inquirer/-/inquirer-3.2.2.tgz",
- "integrity": "sha512-bTKLzEHJVATimZO/YFdLrom0lRx1BHfRYskFHfIMVkGdp8+dIZaxuU+4yrsS1lcu6YWywVQVVsfvdwESzbeqHw==",
+ "version": "3.3.0",
+ "resolved": "https://registry.npmjs.org/inquirer/-/inquirer-3.3.0.tgz",
+ "integrity": "sha512-h+xtnyk4EwKvFWHrUYsWErEVR+igKtLdchu+o0Z1RL7VU/jVMFbYir2bp6bAj8efFNxWqHX0dIss6fJQ+/+qeQ==",
"dev": true,
"requires": {
- "ansi-escapes": "2.0.0",
+ "ansi-escapes": "3.0.0",
"chalk": "2.1.0",
"cli-cursor": "2.1.0",
- "cli-width": "2.1.0",
- "external-editor": "2.0.4",
+ "cli-width": "2.2.0",
+ "external-editor": "2.0.5",
"figures": "2.0.0",
"lodash": "4.17.4",
"mute-stream": "0.0.7",
@@ -970,9 +968,9 @@
"dev": true
},
"js-yaml": {
- "version": "3.9.1",
- "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.9.1.tgz",
- "integrity": "sha512-CbcG379L1e+mWBnLvHWWeLs8GyV/EMw862uLI3c+GxVyDHWZcjZinwuBd3iW2pgxgIlksW/1vNJa4to+RvDOww==",
+ "version": "3.10.0",
+ "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.10.0.tgz",
+ "integrity": "sha512-O2v52ffjLa9VeM43J4XocZE//WT9N0IiwDa3KSHH7Tu8CtH+1qM8SIZvnsTh6v+4yFy5KUY3BHUVwjpfAWsjIA==",
"dev": true,
"requires": {
"argparse": "1.0.9",
@@ -1000,12 +998,6 @@
"jsonify": "0.0.0"
}
},
- "json3": {
- "version": "3.3.2",
- "resolved": "https://registry.npmjs.org/json3/-/json3-3.3.2.tgz",
- "integrity": "sha1-PAQ0dD35Pi9cQq7nsZvLSDV19OE=",
- "dev": true
- },
"jsonify": {
"version": "0.0.0",
"resolved": "https://registry.npmjs.org/jsonify/-/jsonify-0.0.0.tgz",
@@ -1042,74 +1034,6 @@
"integrity": "sha1-eCA6TRwyiuHYbcpkYONptX9AVa4=",
"dev": true
},
- "lodash._baseassign": {
- "version": "3.2.0",
- "resolved": "https://registry.npmjs.org/lodash._baseassign/-/lodash._baseassign-3.2.0.tgz",
- "integrity": "sha1-jDigmVAPIVrQnlnxci/QxSv+Ck4=",
- "dev": true,
- "requires": {
- "lodash._basecopy": "3.0.1",
- "lodash.keys": "3.1.2"
- }
- },
- "lodash._basecopy": {
- "version": "3.0.1",
- "resolved": "https://registry.npmjs.org/lodash._basecopy/-/lodash._basecopy-3.0.1.tgz",
- "integrity": "sha1-jaDmqHbPNEwK2KVIghEd08XHyjY=",
- "dev": true
- },
- "lodash._basecreate": {
- "version": "3.0.3",
- "resolved": "https://registry.npmjs.org/lodash._basecreate/-/lodash._basecreate-3.0.3.tgz",
- "integrity": "sha1-G8ZhYU2qf8MRt9A78WgGoCE8+CE=",
- "dev": true
- },
- "lodash._getnative": {
- "version": "3.9.1",
- "resolved": "https://registry.npmjs.org/lodash._getnative/-/lodash._getnative-3.9.1.tgz",
- "integrity": "sha1-VwvH3t5G1hzc3mh9ZdPuy6o6r/U=",
- "dev": true
- },
- "lodash._isiterateecall": {
- "version": "3.0.9",
- "resolved": "https://registry.npmjs.org/lodash._isiterateecall/-/lodash._isiterateecall-3.0.9.tgz",
- "integrity": "sha1-UgOte6Ql+uhCRg5pbbnPPmqsBXw=",
- "dev": true
- },
- "lodash.create": {
- "version": "3.1.1",
- "resolved": "https://registry.npmjs.org/lodash.create/-/lodash.create-3.1.1.tgz",
- "integrity": "sha1-1/KEnw29p+BGgruM1yqwIkYd6+c=",
- "dev": true,
- "requires": {
- "lodash._baseassign": "3.2.0",
- "lodash._basecreate": "3.0.3",
- "lodash._isiterateecall": "3.0.9"
- }
- },
- "lodash.isarguments": {
- "version": "3.1.0",
- "resolved": "https://registry.npmjs.org/lodash.isarguments/-/lodash.isarguments-3.1.0.tgz",
- "integrity": "sha1-L1c9hcaiQon/AGY7SRwdM4/zRYo=",
- "dev": true
- },
- "lodash.isarray": {
- "version": "3.0.4",
- "resolved": "https://registry.npmjs.org/lodash.isarray/-/lodash.isarray-3.0.4.tgz",
- "integrity": "sha1-eeTriMNqgSKvhvhEqpvNhRtfu1U=",
- "dev": true
- },
- "lodash.keys": {
- "version": "3.1.2",
- "resolved": "https://registry.npmjs.org/lodash.keys/-/lodash.keys-3.1.2.tgz",
- "integrity": "sha1-TbwEcrFWvlCgsoaFXRvQsMZWCYo=",
- "dev": true,
- "requires": {
- "lodash._getnative": "3.9.1",
- "lodash.isarguments": "3.1.0",
- "lodash.isarray": "3.0.4"
- }
- },
"lru-cache": {
"version": "4.1.1",
"resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-4.1.1.tgz",
@@ -1179,51 +1103,30 @@
}
},
"mocha": {
- "version": "3.5.0",
- "resolved": "https://registry.npmjs.org/mocha/-/mocha-3.5.0.tgz",
- "integrity": "sha512-pIU2PJjrPYvYRqVpjXzj76qltO9uBYI7woYAMoxbSefsa+vqAfptjoeevd6bUgwD0mPIO+hv9f7ltvsNreL2PA==",
+ "version": "4.0.1",
+ "resolved": "https://registry.npmjs.org/mocha/-/mocha-4.0.1.tgz",
+ "integrity": "sha512-evDmhkoA+cBNiQQQdSKZa2b9+W2mpLoj50367lhy+Klnx9OV8XlCIhigUnn1gaTFLQCa0kdNhEGDr0hCXOQFDw==",
"dev": true,
"requires": {
"browser-stdout": "1.3.0",
- "commander": "2.9.0",
- "debug": "2.6.8",
- "diff": "3.2.0",
+ "commander": "2.11.0",
+ "debug": "3.1.0",
+ "diff": "3.3.1",
"escape-string-regexp": "1.0.5",
- "glob": "7.1.1",
- "growl": "1.9.2",
- "json3": "3.3.2",
- "lodash.create": "3.1.1",
+ "glob": "7.1.2",
+ "growl": "1.10.3",
+ "he": "1.1.1",
"mkdirp": "0.5.1",
- "supports-color": "3.1.2"
+ "supports-color": "4.4.0"
},
"dependencies": {
- "glob": {
- "version": "7.1.1",
- "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.1.tgz",
- "integrity": "sha1-gFIR3wT6rxxjo2ADBs31reULLsg=",
- "dev": true,
- "requires": {
- "fs.realpath": "1.0.0",
- "inflight": "1.0.6",
- "inherits": "2.0.3",
- "minimatch": "3.0.4",
- "once": "1.4.0",
- "path-is-absolute": "1.0.1"
- }
- },
- "has-flag": {
- "version": "1.0.0",
- "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-1.0.0.tgz",
- "integrity": "sha1-nZ55MWXOAXoA8AQYxD+UKnsdEfo=",
- "dev": true
- },
"supports-color": {
- "version": "3.1.2",
- "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-3.1.2.tgz",
- "integrity": "sha1-cqJiiU2dQIuVbKBf83su2KbiotU=",
+ "version": "4.4.0",
+ "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-4.4.0.tgz",
+ "integrity": "sha512-rKC3+DyXWgK0ZLKwmRsrkyHVZAjNkfzeehuFWdGGcqGDTZFH73+RH6S/RDAAxl9GusSjZSUWYLmT9N5pzXFOXQ==",
"dev": true,
"requires": {
- "has-flag": "1.0.0"
+ "has-flag": "2.0.0"
}
}
}
@@ -1363,9 +1266,9 @@
}
},
"pluralize": {
- "version": "4.0.0",
- "resolved": "https://registry.npmjs.org/pluralize/-/pluralize-4.0.0.tgz",
- "integrity": "sha1-WbcIwcAZCi9pLxx2GMRGsFL9F2I=",
+ "version": "7.0.0",
+ "resolved": "https://registry.npmjs.org/pluralize/-/pluralize-7.0.0.tgz",
+ "integrity": "sha512-ARhBOdzS3e41FbkW/XWrTEtukqqLoK5+Z/4UeDaLuSW+39JPeFgs4gCGqsrJHVZX0fUrx//4OF0K1CUGwlIFow==",
"dev": true
},
"prelude-ls": {
@@ -1523,46 +1426,28 @@
}
},
"rimraf": {
- "version": "2.6.1",
- "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.1.tgz",
- "integrity": "sha1-wjOOxkPfeht/5cVPqG9XQopV8z0=",
+ "version": "2.6.2",
+ "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.2.tgz",
+ "integrity": "sha512-lreewLK/BlghmxtfH36YYVg1i8IAce4TI7oao75I1g245+6BctqTVQiBP3YUJ9C6DQOXJmkYR9X9fCLtCOJc5w==",
"dev": true,
"requires": {
"glob": "7.1.2"
}
},
"rollup": {
- "version": "0.48.2",
- "resolved": "https://registry.npmjs.org/rollup/-/rollup-0.48.2.tgz",
- "integrity": "sha512-5IOVEA87/OWQlojaAPN0WStLAhlaY7GS/5p+pA/IHReXjtc+d7IJYgRD3Y/U2LVXoD7f1SBc3ymYd4g3M/zRzQ==",
+ "version": "0.50.0",
+ "resolved": "https://registry.npmjs.org/rollup/-/rollup-0.50.0.tgz",
+ "integrity": "sha512-7RqCBQ9iwsOBPkjYgoIaeUij606mSkDMExP0NT7QDI3bqkHYQHrQ83uoNIXwPcQm/vP2VbsUz3kiyZZ1qPlLTQ==",
"dev": true
},
"rollup-plugin-buble": {
- "version": "0.15.0",
- "resolved": "https://registry.npmjs.org/rollup-plugin-buble/-/rollup-plugin-buble-0.15.0.tgz",
- "integrity": "sha1-g8PonH/SJmx5GPQbo5gDE1Gcf9A=",
+ "version": "0.16.0",
+ "resolved": "https://registry.npmjs.org/rollup-plugin-buble/-/rollup-plugin-buble-0.16.0.tgz",
+ "integrity": "sha512-dPIvH9iK9AUGRrqpARL6TTNY85BJpc5OK5PiCAnFaRe7C1boRBVRXiL0SYsYNVnyYYPl6vu0lVSb722eMSw1Eg==",
"dev": true,
"requires": {
- "buble": "0.15.2",
- "rollup-pluginutils": "1.5.2"
- },
- "dependencies": {
- "estree-walker": {
- "version": "0.2.1",
- "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-0.2.1.tgz",
- "integrity": "sha1-va/oCVOD2EFNXcLs9MkXO225QS4=",
- "dev": true
- },
- "rollup-pluginutils": {
- "version": "1.5.2",
- "resolved": "https://registry.npmjs.org/rollup-pluginutils/-/rollup-pluginutils-1.5.2.tgz",
- "integrity": "sha1-HhVud4+UtyVb+hs9AXi+j1xVJAg=",
- "dev": true,
- "requires": {
- "estree-walker": "0.2.1",
- "minimatch": "3.0.4"
- }
- }
+ "buble": "0.16.0",
+ "rollup-pluginutils": "2.0.1"
}
},
"rollup-plugin-node-resolve": {
@@ -1681,24 +1566,27 @@
"dev": true
},
"slice-ansi": {
- "version": "0.0.4",
- "resolved": "https://registry.npmjs.org/slice-ansi/-/slice-ansi-0.0.4.tgz",
- "integrity": "sha1-7b+JA/ZvfOL46v1s7tZeJkyDGzU=",
- "dev": true
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/slice-ansi/-/slice-ansi-1.0.0.tgz",
+ "integrity": "sha512-POqxBK6Lb3q6s047D/XsDVNPnF9Dl8JSaqe9h9lURl0OdNqy/ujDrOiIHtsqXMGbWWTIomRzAMaTyawAU//Reg==",
+ "dev": true,
+ "requires": {
+ "is-fullwidth-code-point": "2.0.0"
+ }
},
"source-map": {
- "version": "0.5.7",
- "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz",
- "integrity": "sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w=",
+ "version": "0.6.1",
+ "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz",
+ "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==",
"dev": true
},
"source-map-support": {
- "version": "0.4.16",
- "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.4.16.tgz",
- "integrity": "sha512-A6vlydY7H/ljr4L2UOhDSajQdZQ6dMD7cLH0pzwcmwLyc9u8PNI4WGtnfDDzX7uzGL6c/T+ORL97Zlh+S4iOrg==",
+ "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==",
"dev": true,
"requires": {
- "source-map": "0.5.7"
+ "source-map": "0.6.1"
}
},
"sprintf-js": {
@@ -1756,51 +1644,17 @@
"dev": true
},
"table": {
- "version": "4.0.1",
- "resolved": "https://registry.npmjs.org/table/-/table-4.0.1.tgz",
- "integrity": "sha1-qBFsEz+sLGH0pCCrbN9cTWHw5DU=",
+ "version": "4.0.2",
+ "resolved": "https://registry.npmjs.org/table/-/table-4.0.2.tgz",
+ "integrity": "sha512-UUkEAPdSGxtRpiV9ozJ5cMTtYiqz7Ni1OGqLXRCynrvzdtR1p+cfOWe2RJLwvUG8hNanaSRjecIqwOjqeatDsA==",
"dev": true,
"requires": {
- "ajv": "4.11.8",
- "ajv-keywords": "1.5.1",
- "chalk": "1.1.3",
+ "ajv": "5.2.3",
+ "ajv-keywords": "2.1.0",
+ "chalk": "2.1.0",
"lodash": "4.17.4",
- "slice-ansi": "0.0.4",
+ "slice-ansi": "1.0.0",
"string-width": "2.1.1"
- },
- "dependencies": {
- "ajv": {
- "version": "4.11.8",
- "resolved": "https://registry.npmjs.org/ajv/-/ajv-4.11.8.tgz",
- "integrity": "sha1-gv+wKynmYq5TvcIK8VlHcGc5xTY=",
- "dev": true,
- "requires": {
- "co": "4.6.0",
- "json-stable-stringify": "1.0.1"
- }
- },
- "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"
- }
- },
- "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"
- }
- }
}
},
"text-table": {
@@ -1816,9 +1670,9 @@
"dev": true
},
"tmp": {
- "version": "0.0.31",
- "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.0.31.tgz",
- "integrity": "sha1-jzirlDjhcxXl29izZX6L+yd65Kc=",
+ "version": "0.0.33",
+ "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.0.33.tgz",
+ "integrity": "sha512-jRCJlojKnZ3addtTOjdIqoRuPEKBvNXcGYqzO6zWZX8KfKEpnGY5jfggJQ3EjKuu8D4bJRr0y+cYJFmYbImXGw==",
"dev": true,
"requires": {
"os-tmpdir": "1.0.2"
diff --git a/package.json b/package.json
index 29db2f4..3321c83 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "rollup-plugin-commonjs",
- "version": "8.2.1",
+ "version": "8.2.4",
"description": "Convert CommonJS modules to ES2015",
"main": "dist/rollup-plugin-commonjs.cjs.js",
"module": "dist/rollup-plugin-commonjs.es.js",
@@ -19,23 +19,23 @@
"README.md"
],
"dependencies": {
- "acorn": "^5.1.1",
+ "acorn": "^5.1.2",
"estree-walker": "^0.5.0",
"magic-string": "^0.22.4",
"resolve": "^1.4.0",
"rollup-pluginutils": "^2.0.1"
},
"devDependencies": {
- "eslint": "^4.5.0",
+ "eslint": "^4.8.0",
"locate-character": "^2.0.1",
- "mocha": "^3.5.0",
+ "mocha": "^4.0.1",
"require-relative": "^0.8.7",
- "rollup": "^0.48.2",
- "rollup-plugin-buble": "^0.15.0",
+ "rollup": "^0.50.0",
+ "rollup-plugin-buble": "^0.16.0",
"rollup-plugin-node-resolve": "^3.0.0",
"shx": "^0.2.2",
- "source-map": "^0.5.7",
- "source-map-support": "^0.4.16"
+ "source-map": "^0.6.1",
+ "source-map-support": "^0.5.0"
},
"repository": "rollup/rollup-plugin-commonjs",
"author": "Rich Harris",
diff --git a/src/helpers.js b/src/helpers.js
index cb62211..7748cd8 100644
--- a/src/helpers.js
+++ b/src/helpers.js
@@ -8,7 +8,7 @@ export function commonjsRequire () {
}
export function unwrapExports (x) {
- return x && x.__esModule ? x['default'] : x;
+ return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
}
export function createCommonjsModule(fn, module) {
diff --git a/src/index.js b/src/index.js
index b6e9824..07950ac 100644
--- a/src/index.js
+++ b/src/index.js
@@ -4,7 +4,7 @@ import { sync as nodeResolveSync } from 'resolve';
import { createFilter } from 'rollup-pluginutils';
import { EXTERNAL, PREFIX, HELPERS_ID, HELPERS } from './helpers.js';
import defaultResolver from './defaultResolver.js';
-import transformCommonjs from './transform.js';
+import { checkFirstpass, checkEsModule, transformCommonjs } from './transform.js';
import { getName } from './utils.js';
function getCandidatesForExtension ( resolved, extension ) {
@@ -58,6 +58,8 @@ export default function commonjs ( options = {} ) {
});
}
+ const esModulesWithoutDefaultExport = [];
+
const allowDynamicRequire = !!options.ignore; // TODO maybe this should be configurable?
const ignoreRequire = typeof options.ignore === 'function' ?
@@ -153,9 +155,12 @@ export default function commonjs ( options = {} ) {
const actualId = id.slice( PREFIX.length );
const name = getName( actualId );
- return commonjsModules.has( actualId ) ?
- `import { __moduleExports } from ${JSON.stringify( actualId )}; export default __moduleExports;` :
- `import * as ${name} from ${JSON.stringify( actualId )}; export default ( ${name} && ${name}['default'] ) || ${name};`;
+ if (commonjsModules.has( actualId ))
+ return `import { __moduleExports } from ${JSON.stringify( actualId )}; export default __moduleExports;`;
+ else if (esModulesWithoutDefaultExport.includes(actualId))
+ return `import * as ${name} from ${JSON.stringify( actualId )}; export default ${name};`;
+ else
+ return `import * as ${name} from ${JSON.stringify( actualId )}; export default ( ${name} && ${name}['default'] ) || ${name};`;
}
},
@@ -164,12 +169,24 @@ export default function commonjs ( options = {} ) {
if ( extensions.indexOf( extname( id ) ) === -1 ) return null;
return entryModuleIdPromise.then( () => {
- const transformed = transformCommonjs( code, id, id === entryModuleId, ignoreGlobal, ignoreRequire, customNamedExports[ id ], sourceMap, allowDynamicRequire );
+ const {isEsModule, hasDefaultExport, ast} = checkEsModule( code, id );
+ if ( isEsModule ) {
+ if ( !hasDefaultExport )
+ esModulesWithoutDefaultExport.push( id );
+ return;
+ }
- if ( transformed ) {
- commonjsModules.set( id, true );
- return transformed;
+ // it is not an ES module but not a commonjs module, too.
+ if ( !checkFirstpass( code, ignoreGlobal ) ) {
+ esModulesWithoutDefaultExport.push( id );
+ return;
}
+
+ const transformed = transformCommonjs( code, id, id === entryModuleId, ignoreGlobal, ignoreRequire, customNamedExports[ id ], sourceMap, allowDynamicRequire, ast );
+ if ( !transformed ) return;
+
+ commonjsModules.set( id, true );
+ return transformed;
});
}
};
diff --git a/src/transform.js b/src/transform.js
index ed9d17c..eb12e45 100644
--- a/src/transform.js
+++ b/src/transform.js
@@ -39,17 +39,30 @@ function tryParse ( code, id ) {
}
}
-export default function transformCommonjs ( code, id, isEntry, ignoreGlobal, ignoreRequire, customNamedExports, sourceMap, allowDynamicRequire ) {
+export function checkFirstpass (code, ignoreGlobal) {
const firstpass = ignoreGlobal ? firstpassNoGlobal : firstpassGlobal;
- if ( !firstpass.test( code ) ) return null;
+ return firstpass.test(code);
+}
- const ast = tryParse( code, id );
+export function checkEsModule (code, id) {
+ const ast = tryParse(code, id);
// if there are top-level import/export declarations, this is ES not CommonJS
+ let hasDefaultExport = false;
+ let isEsModule = false;
for ( const node of ast.body ) {
- if ( importExportDeclaration.test( node.type ) ) return null;
+ if ( node.type === 'ExportDefaultDeclaration' )
+ hasDefaultExport = true;
+ if ( importExportDeclaration.test( node.type ) )
+ isEsModule = true;
}
+ return { isEsModule, hasDefaultExport, ast };
+}
+
+export function transformCommonjs ( code, id, isEntry, ignoreGlobal, ignoreRequire, customNamedExports, sourceMap, allowDynamicRequire, astCache ) {
+ const ast = astCache || tryParse( code, id );
+
const magicString = new MagicString( code );
const required = {};
@@ -91,7 +104,11 @@ export default function transformCommonjs ( code, id, isEntry, ignoreGlobal, ign
if ( existing === undefined ) {
sources.push( source );
- if ( !name ) name = `require$$${uid++}`;
+ if ( !name ) {
+ do name = `require$$${uid++}`;
+ while ( scope.contains( name ) );
+ }
+
required[ source ] = { source, name, importsDefault: false };
}
@@ -374,10 +391,12 @@ export default function transformCommonjs ( code, id, isEntry, ignoreGlobal, ign
`export { ${name} };` :
`export { ${deconflicted} as ${name} };`;
- namedExportDeclarations.push({
- str: declaration,
- name
- });
+ if ( name !== 'default' ) {
+ namedExportDeclarations.push({
+ str: declaration,
+ name
+ });
+ }
defaultExportPropertyAssignments.push( `${moduleName}.${name} = ${deconflicted};` );
}
diff --git a/test/form/require-collision/input.js b/test/form/require-collision/input.js
new file mode 100644
index 0000000..348c95c
--- /dev/null
+++ b/test/form/require-collision/input.js
@@ -0,0 +1,5 @@
+(function() {
+ var foo = require("foo");
+ var require$$0 = "FAIL";
+ console.log(foo);
+})();
diff --git a/test/form/require-collision/output.js b/test/form/require-collision/output.js
new file mode 100644
index 0000000..58c8728
--- /dev/null
+++ b/test/form/require-collision/output.js
@@ -0,0 +1,15 @@
+import 'foo';
+import require$$1 from 'commonjs-proxy:foo';
+
+(function() {
+ var foo = require$$1;
+ var require$$0 = "FAIL";
+ console.log(foo);
+})();
+
+var input = {
+
+};
+
+export default input;
+export { input as __moduleExports };
diff --git a/test/function/duplicate-default-exports-c/exports.js b/test/function/duplicate-default-exports-c/exports.js
new file mode 100644
index 0000000..8adb997
--- /dev/null
+++ b/test/function/duplicate-default-exports-c/exports.js
@@ -0,0 +1,6 @@
+exports.Foo = 1;
+exports.var = 'VAR';
+exports.default = {
+ Foo: 2,
+ default: 3
+};
diff --git a/test/function/duplicate-default-exports-c/main.js b/test/function/duplicate-default-exports-c/main.js
new file mode 100644
index 0000000..a7fdb64
--- /dev/null
+++ b/test/function/duplicate-default-exports-c/main.js
@@ -0,0 +1,11 @@
+import E from './exports.js';
+import { Foo } from './exports.js';
+import { var as Var } from './exports.js';
+
+assert.strictEqual( E.Foo, 1 );
+assert.strictEqual( E.var, 'VAR' );
+assert.deepEqual( E.default, { Foo: 2, default: 3 });
+assert.strictEqual( E.default.Foo, 2 );
+assert.strictEqual( E.default.default, 3 );
+assert.strictEqual( Foo, 1 );
+assert.strictEqual( Var, 'VAR' );
diff --git a/test/samples/es-modules-without-default-export/main.js b/test/samples/es-modules-without-default-export/main.js
new file mode 100644
index 0000000..9824c7f
--- /dev/null
+++ b/test/samples/es-modules-without-default-export/main.js
@@ -0,0 +1,3 @@
+const { a } = require('./other.js');
+
+assert.equal( a, 1 );
diff --git a/test/samples/es-modules-without-default-export/other.js b/test/samples/es-modules-without-default-export/other.js
new file mode 100644
index 0000000..cc798ff
--- /dev/null
+++ b/test/samples/es-modules-without-default-export/other.js
@@ -0,0 +1 @@
+export const a = 1;
diff --git a/test/samples/use-own-output/from-rollup.js b/test/samples/use-own-output/from-rollup.js
new file mode 100644
index 0000000..3a0bcda
--- /dev/null
+++ b/test/samples/use-own-output/from-rollup.js
@@ -0,0 +1,2 @@
+Object.defineProperty(exports, '__esModule', { value: true });
+exports.x = 10
diff --git a/test/samples/use-own-output/main.js b/test/samples/use-own-output/main.js
new file mode 100644
index 0000000..c011220
--- /dev/null
+++ b/test/samples/use-own-output/main.js
@@ -0,0 +1,2 @@
+import * as b from "./from-rollup";
+window.b = b;
diff --git a/test/test.js b/test/test.js
index 074c357..37655c2 100644
--- a/test/test.js
+++ b/test/test.js
@@ -121,8 +121,8 @@ describe( 'rollup-plugin-commonjs', () => {
const generated = await bundle.generate({
format: 'cjs',
- sourceMap: true,
- sourceMapFile: path.resolve( 'bundle.js' )
+ sourcemap: true,
+ sourcemapFile: path.resolve( 'bundle.js' )
});
const smc = new SourceMapConsumer( generated.map );
@@ -410,7 +410,7 @@ describe( 'rollup-plugin-commonjs', () => {
it( 'prefers to set name using directory for index files', async () => {
const bundle = await rollup({
- entry: 'samples/rename-index/main.js',
+ input: 'samples/rename-index/main.js',
plugins: [ commonjs() ]
});
@@ -420,5 +420,34 @@ describe( 'rollup-plugin-commonjs', () => {
assert.notEqual( code.indexOf( 'var validVar' ), -1 );
assert.notEqual( code.indexOf( 'var nonIndex' ), -1 );
});
+
+ it( 'does not misassign default when consuming rollup output', async () => {
+ // Issue #224
+ const bundle = await rollup({
+ input: 'samples/use-own-output/main.js',
+ plugins: [ commonjs() ],
+ });
+
+ const window = {};
+ await executeBundle( bundle, { context: { window } } );
+ assert.notEqual( window.b.default, undefined );
+ });
+
+ it( 'does not warn even if the ES module not export "default"', async () => {
+ const warns = [];
+ await rollup({
+ input: 'samples/es-modules-without-default-export/main.js',
+ plugins: [ commonjs() ],
+ onwarn: (warn) => warns.push( warn )
+ });
+ assert.equal( warns.length, 0 );
+
+ await rollup({
+ input: 'function/bare-import/bar.js',
+ plugins: [ commonjs() ],
+ onwarn: (warn) => warns.push( warn )
+ });
+ assert.equal( warns.length, 0 );
+ });
});
-});
+});
\ No newline at end of file
--
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