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

fix: Make explicit imports of index.js in main library files. #5668

Merged
merged 1 commit into from Feb 1, 2024

Conversation

waweber
Copy link
Contributor

@waweber waweber commented Jan 28, 2024

Fixes #4991 by making imports of subpackages reference the index.js file explicitly.

The newer "nodenext" resolution rules require relative imports to include the file extension, and implicit index imports are not supported. Under these rules, exports like export * from './core'; fail. This change works around these rules by changing these imports to export * from './core/index.js'; which resolves correctly under both "nodenext" and the default "node" resolution rules. It seems sufficient to only update the imports in the main index.ts files, TypeScript appears to use the default rules with deeper imports.

This is likely the less hacky solution, but this might break people's bundlers if they don't handle imports that include extensions.

This allows the package imports to work correctly when
"moduleResolution": "nodenext" is set.
@rtivital rtivital merged commit afbfc1a into mantinedev:master Feb 1, 2024
1 check passed
@rtivital
Copy link
Member

rtivital commented Feb 1, 2024

Thanks!

@rtivital
Copy link
Member

rtivital commented Feb 1, 2024

Unfortunately, it breaks Storybook, I had to revert this change

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 this pull request may close these issues.

Imports fail with TS "moduleResolution": "nodenext"
2 participants