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

[Bug] Output chunk code sequence problem with splitting code? #3165

Closed
noyobo opened this issue Jun 15, 2023 · 2 comments
Closed

[Bug] Output chunk code sequence problem with splitting code? #3165

noyobo opened this issue Jun 15, 2023 · 2 comments

Comments

@noyobo
Copy link

noyobo commented Jun 15, 2023

The issue project git repo https://github.com/noyobo/esbuild-issues/tree/chunk-order npm run build

esbuild config https://github.com/noyobo/esbuild-issues/blob/a4ecc9edf322c26f74aba5c1767379a20653e727/scripts/build.js#LL1C1-L1C1

There is a problem with the output chunk code.

https://github.com/noyobo/esbuild-issues/blob/a4ecc9edf322c26f74aba5c1767379a20653e727/dist/chunk-AFYZHPWT.js#L133

image

Line 133 calls dp_default.dpMaps but dp_default is defined on line 195 https://github.com/noyobo/esbuild-issues/blob/a4ecc9edf322c26f74aba5c1767379a20653e727/dist/chunk-AFYZHPWT.js#L195

actual execution throws an error Uncaught TypeError: Cannot read properties of undefined (reading 'dpMaps')

@evanw
Copy link
Owner

evanw commented Jun 15, 2023

I haven't looked into the code you linked to. However, you should be aware that there are known ordering bugs with esbuild's current code splitting implementation: #399. This is explicitly called out at the top of the documentation for code splitting: https://esbuild.github.io/api/#splitting.

@noyobo
Copy link
Author

noyobo commented Jun 15, 2023

Sorry for not reading the docs carefully.

Can you refer to the code organization method of webpack, and register and call through the file name.

The order of the output code content is not the order of actual loading and parsing, but when the program starts to execute, it starts to execute according to the reference relationship.

@noyobo noyobo closed this as completed Jun 16, 2023
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

2 participants