Closed kulak closed 4 years ago
I have noticed that while react-router distributes both es and non-es versions here: https://unpkg.com/browse/preact-router@3.1.0/
match.js is included without es version, without package.json file referencing it. Could that be a problem?
i have the same error, i try to says this in slack but.... nobody answered me :(
@aguilera51284 I can't find any message thread related to that for the past weeks in slack.
@Kulak Thank you so much for the repo. That way I can easily reproduce the described issue. I had a closer look and the error is caused by a bug in @rollup/plugin-commonjs (formely known as rollup-plugin-commonjs
. In our case we're exporting the code like this:
class Foo {
// ...
}
Foo.baz = 42
const bar = () => null;
export { Foo, bar };
export default Foo;
When rollup sees someone using a commonjs import like we do in match.js
that is distributed on npm, rollup wrongly throws away all non-default exports.
const MyFoo = require("./Foo");
// What rollup actually exports
class Foo() {...}
// What should be correct exports instead
{
default: Foo,
Foo,
bar,
}
I'm afraid we can't fix that issue on our end. The rollup team is pretty amazing when it comes to fixing these things so the best chance to get this resolved is to file an issue in their tracker :+1:
@marvinhagemeister I don't think this is a rollup issue, as match
is a cjs module which depends on exec
of main module, but exec isn't exported in main cjs module.
I have tried rollupjs approach that's not path frequently taken and I used
preact-cli
generated TypeScript as a starting point. So, the issue might be caused by rollupjs.When I include
Link
I get this error:I created a demo project to replicate this error with detailed exception provided in README: https://github.com/Kulak/preactRouterRollupExample
My tsconfig file already includes option
Does anyone have any idea?