[internals] Fix ERR_UNSUPPORTED_DIR_IMPORT for core-js-pure in Node ESM#22985
Conversation
…pure disposable stacks Signed-off-by: michel <[email protected]>
brijeshb42
left a comment
There was a problem hiding this comment.
Just FYI, code-js-pure as a dependency of x-internals has ^ version range.
Deploy previewBundle size
Check out the code infra dashboard for more information about this PR. |
|
@brijeshb42 the linter fails with |
|
I remembered we have cjs/esm outputs. What happens in that case for cjs/esm usage since both will be importing from same path ? |
|
We had a lot of back & forth for a similar fix in core - mui/material-ui#48645 |
This case is simpler than the react-transition-group situation in material-ui — core-js-pure ships only CommonJS, no ESM build. actual/disposable-stack/index.js is always a CJS file regardless of which output of @mui/x-internals is consuming it:
There's no split ESM/CJS build in core-js-pure to worry about, so a single explicit path serves all three cases. That's exactly why this is a simpler fix than the RTG case. |
Signed-off-by: michel <[email protected]>
The
@mui/x-internals/disposablemodule importedcore-js-pureusing bare directory paths (core-js-pure/actual/disposable-stack). Node's native ESM loader does not support directory imports for packages without anexportsfield, causingERR_UNSUPPORTED_DIR_IMPORTcrashes in SSR environments (Vite, TanStack Start, Next.js) where MUI X packages are left external. Fixes by switching to explicit file paths (…/index.js), the same resolution the issue reporter and Node's own error message suggest.Fixes #22984