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

TypeError: Object(...)(...) is not a function #1309

Closed
jeetiss opened this issue Jul 25, 2019 · 6 comments · Fixed by #1310
Closed

TypeError: Object(...)(...) is not a function #1309

jeetiss opened this issue Jul 25, 2019 · 6 comments · Fixed by #1310

Comments

@jeetiss
Copy link
Contributor

jeetiss commented Jul 25, 2019

Description

no semicolon code style in node_modules breaks hmr

Expected behavior

all work nice

Actual behavior

What actually happens:

TypeError: Object(...)(...) is not a function

Снимок экрана 2019-07-25 в 13 37 04

Reproducible Demo

repo with bug and steps to reproduce
https://github.com/jeetiss/gatsby-hmr-bug

@theKashey
Copy link
Collaborator

Sooo easy? Why nobody reported it before?

@theKashey
Copy link
Collaborator

However - that did not help.

  • ; is lost during rollup bundling.
  • ; is added by webpack plugin itself
  • the problem does exist only for node_modules in the SRC - the code from webpack plugin is just DIFFERENT - without ";", that somehow is bound to the source map generation
  • I am just changing IIFE mode (to !function) to prevent the issue.

@theKashey
Copy link
Collaborator

The best fix - scope webpack loader to react-dom

@jeetiss
Copy link
Contributor Author

jeetiss commented Jul 27, 2019

the problem does exist only for node_modules in the SRC

@theKashey this not right
I am update example with npm package that breaks hmr

https://github.com/jeetiss/module-that-breaks-hmr

@jeetiss
Copy link
Contributor Author

jeetiss commented Jul 27, 2019

@theKashey thanks for help ❤️

@theKashey
Copy link
Collaborator

If you will compare the final result for "normal" node modules, and your ones - it's different.
How it works in short:

  • you are given a source
  • I am reading webpackTagCommonJSExports.js
  • I am concatenating source and patch with "\n\n;" as a glue.

Usually: - everything is working as expected
For "your" modules: - there is no glue, plus some comments which should not be present.

And that's not quite explainable.

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

Successfully merging a pull request may close this issue.

2 participants