You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
esbuild is failing to make sure that the ESM wrapper (i.e., the init_* function) is getting called before accessing the variables exported from the module in some cases.
Including both ESM and CJS is necessary to trigger the creation of ESM wrappers. Code splitting is also used in the reproduction and is likely necessary to trigger the bug.
The problematic output file is dist/Popper.js:
import{Popper}from"./chunk-67J4M5PZ.js";// <--- Imports Popper before ESM wrapper `init_styled` is called.import"./chunk-IBEMUV7X.js";// <--- Calls ESM wrapper `init_styled`.import"./chunk-5KLWG3PA.js";export{Popper};
Running dist/Popper.js throws an error (i.e., TypeError: styled is not a function) because the styled module has not been initialized.
Downstream issues
This issue causes many problems for Vite and Remix users when using MUI (which is how I wound up here). Some unresolved issues in other repos related to this are:
Methuselah96
changed the title
Re-exported module not initialized
ESM initialization wrapper not called before accessing module exports
Aug 30, 2023
Methuselah96
changed the title
ESM initialization wrapper not called before accessing module exports
ESM wrapper not initialized before accessing module exports
Aug 30, 2023
Issue description
esbuild is failing to make sure that the ESM wrapper (i.e., the
init_*
function) is getting called before accessing the variables exported from the module in some cases.I've created a reproduction of this happening.
Including both ESM and CJS is necessary to trigger the creation of ESM wrappers. Code splitting is also used in the reproduction and is likely necessary to trigger the bug.
The problematic output file is
dist/Popper.js
:Running
dist/Popper.js
throws an error (i.e.,TypeError: styled is not a function
) because thestyled
module has not been initialized.Downstream issues
This issue causes many problems for Vite and Remix users when using MUI (which is how I wound up here). Some unresolved issues in other repos related to this are:
Related issues
__esm()
initialisation never called withexport * from
statement. #1490The text was updated successfully, but these errors were encountered: