Open ChristianM18 opened 2 months ago
Edit: In my case the issue was with the input
flag, not imports in the input. Still a bug, but not a common usage. I resolved by running require.resolve
first.
I think plugin-node-resolve
is unable to resolve anything other than exports: './file.js'
because I'm having similar issues with this exports array:
Could not resolve entry module "../../tmp/219e0b6c-a89a-45ab-9365-67aa8252356b/node_modules/webext-dynamic-content-scripts".
"exports": {
".": {
"types": "./distribution/index.d.ts",
"default": "./distribution/index.js"
},
"./including-active-tab.js": {
"types": "./distribution/including-active-tab.d.ts",
"default": "./distribution/including-active-tab.js"
},
"./utils.js": {
"types": "./distribution/utils.d.ts",
"default": "./distribution/utils.js"
}
},
My config is just:
const bundle = await rollup({
input,
plugins: [
rollupResolve(), // Also no luck with {exportConditions: ["node"]}
commonjs(),
cleanup(),
],
});
"@rollup/plugin-commonjs": "^26.0.1",
"@rollup/plugin-node-resolve": "^15.2.3",
"rollup": "^3.29.4",
exports: './index.js'
at https://bundle.fregante.com/?pkg=webext-patterns
⚠️ Please note that the packaged
utils
library in this example is available here, if needed: https://github.com/ChristianM18/build-utilsExpected Behavior
Arrays defined in
package.json
exports
to be taken into account, with the resolution algorithm trying each item until one is successfully resolved.Actual Behavior
The following error is thrown:
Additional Information
I expected the following statement:
to resolve to
./dist/color/index.js
, as theutil
's librarypackage.json
contains:and
./dist/color.js
does not exist.However, it seems that the fact that
./dist/color.js
is missing fires an exception, making the algorithm stop.Apparently a similar (if not same) issue has already been addressed in #670, so maybe it's just a problem on my end.