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

Error when adding import to another member in the same module. #847

Open
JSerFeng opened this issue May 29, 2024 · 0 comments
Open

Error when adding import to another member in the same module. #847

JSerFeng opened this issue May 29, 2024 · 0 comments

Comments

@JSerFeng
Copy link

JSerFeng commented May 29, 2024

I modify a module like:

import { 
  foo
+ bar
} from "./components/index";

console.log(foo);
+ console.log(bar);

const App = () => {
  return <div></div>;
};

export default App;

There will be an error
image

Reason

The chunk id is affected by modules inside that chunk. So if I have a initial chunk with module a, let's say its id is src_a, then updated the chunk with modules a and b, the chunk id changes to src_a-src_b, the hot-update.json is like

{
  "m": [],
  "r": ["src_a"],
  "c": [],
}

However the new chunk src_a-src_b is not appear here, because it's a new chunk to hmr, it should be loaded again by its parents. However if it doesn't have parent (initial chunk), it cannot be loaded, thus the new module b cannot be loaded, the error above is caused by this.

However in Webpack, if error occur, the page will reload, so it's fine if not using this plugin. This plugin will handle error occured in HMR, so Webpack do not know if something wrong during hmr

I'm wondering if we can throw this error back to Webpack instead of consuming it

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

1 participant