-
-
Notifications
You must be signed in to change notification settings - Fork 615
Description
- Rollup Plugin Name:
commonjs - Rollup Plugin Version: 14.0.0
- Rollup Version: 1.27.14
- Operating System (or Browser): Ubuntu
- Node Version: v12.18.2
- Link to reproduction (
⚠️ read below):
https://repl.it/@christiantjl/rollup-hashbang-dir (useyarn testfor repro)
Expected Behavior
Bundle produced at output/bundle.mjs.
Actual Behavior
Error is thrown, presumably due to hashbang-only directory in filepath and/or index.js assumption (see below).
Additional Information
I'm working to stress test Rollup against the entire dependency tree of the top 100 or so npm packages, which involves loading a set of plugins for legacy compatibility: commonjs, node-resolve, and json. That work will be ongoing in a separate repo, but I wanted to submit this bug report in advance since it was the most common error at compile-time (the stress test will also run the bundle through node runtime).
import statements for vast majority of these 1300 or so packages will indeed bundle, but a few (~17) do not, ~75% of which are modules that rely on a popular package called es5-ext. Some packages which cannot bundle because of this error include: d gulp es6-iterator es6-symbol es6-weak-map gulp gulp-cli last-run semver-greatest-satisfied-range sver-compat undertaker
Consider the example module on repl.it, that just imports this package to demonstrate:
import hashbangDirInDepTree from 'es5-ext';Bundling with the plugins I mentioned throws:
index.mjs → output/bundle.mjs...
[!] (plugin Rollup Core) Error: Could not load /home/runner/rollup-hashbang-dir/node_modules/es5-ext/array/index.js#/compact (imported by /home/runner/rollup-hashbang-dir/node_modules/es5-ext/json/safe-stringify.js): ENOENT: no such file or directory, open '/home/runner/rollup-hashbang-dir/node_modules/es5-ext/array/index.js#/compact'
Notice how it attempts to resolve to array/index.js#/compact and not array/#/compact/index.js for what I assume is https://github.com/medikoo/es5-ext/blob/master/json/safe-stringify.js#L3 :
var compact = require("../array/#/compact")Please let me know if I have been unclear or can otherwise provide more information. The error message indicates Rollup Core, but I believe it's the CommonJS plugin that is directing Core to load a nonexistent file so I opened the issue in this repo.