Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

match.js:55 Uncaught TypeError: (0 , Router.exec) is not a function #347

Closed
kulak opened this issue Dec 1, 2019 · 4 comments
Closed

match.js:55 Uncaught TypeError: (0 , Router.exec) is not a function #347

kulak opened this issue Dec 1, 2019 · 4 comments

Comments

@kulak
Copy link

kulak commented Dec 1, 2019

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:

match.js:55 Uncaught TypeError: (0 , Router.exec) is not a function

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

"esModuleInterop": true

Does anyone have any idea?

@kulak
Copy link
Author

kulak commented Dec 2, 2019

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?

@aguilera51284
Copy link

i have the same error, i try to says this in slack but.... nobody answered me :(

@marvinhagemeister
Copy link
Member

@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 👍

@webyom
Copy link
Contributor

webyom commented Jan 15, 2020

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants