Closed natevw closed 5 years ago
UPDATE: this doesn't work — see later comment.
Turns out this is due to https://github.com/rollup/rollup-plugin-node-resolve/issues/144#issuecomment-405210086. If I add the .mjs
extension to my config, the error goes away:
import resolve from 'rollup-plugin-node-resolve';
export default {
plugins: [ resolve({
browser: true,
modulesOnly: true,
extensions: [ '.mjs', '.js']
}) ]
}
(A preact workaround for this sort of behavior would also avoid this gotcha: https://github.com/developit/preact/pull/1425)
I spoke to soon. Not sure what I was testing, but adding .mjs
as a supported extension does not fix this after all 🙁
Looks like preact is exporting multiple items, which is probably breaking isModule
: https://github.com/component/is-module/issues/3
I tried to reproduce it with the latest versions. All works perfectly! Repro here: https://github.com/mecurc/200-rollup-issue
Used versions:
"preact": "10.0.0-beta.1",
"rollup": "^1.11.3",
"rollup-plugin-node-resolve": "^4.2.3"
Console output:
$ rollup -c
src/index.js → dist/bundle.js...
created dist/bundle.js in 278ms
Done in 0.71s
Can be closed now.
I am compiling code like this:
Using this via
--config rollup.config.mjs
:Preact's package.json includes:
But I still get an error: