8000 Add package.json with type: module to esm directory by nwalters512 · Pull Request #6897 · react-bootstrap/react-bootstrap · GitHub
[go: up one dir, main page]

Skip to content

Add package.json with type: module to esm directory #6897

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

nwalters512
Copy link
Contributor

This is necessary for Node and similar environments to treat the contents of the esm directory as ES Modules. Otherwise both Node and TypeScript get quite confused.

This is a step in the right direction of resolving #6797. After this change, one should be able to write the following in a TypeScript file:

import ModalDialog from `react-bootstrap/esm/ModalDialog.js`;

function MyComponent() {
  return <ModalDialog></ModalDialog>;
}

Importing e.g. react-bootstrap/ModalDialog doesn't yet work. And the above still doesn't work at runtime because the code in esm/ModalDialog.js isn't actually valid ESM, as it doesn't use extensions on its imports. I'd like to work towards resolving these issues in future PRs, as they're blocking the use of react-bootstrap in my application.

@kyletsang
Copy link
Member

Thanks for the PR. I'm going to be looking into adding proper support for this in the near future as part of a v3 release. Still taking care of some maintenance and upstream deps before doing so

@nwalters512
Copy link
Contributor Author

That's fantastic to hear! Let me know if you want a sounding board for any plans there, I've helped fix up several other dependencies of mine that don't quite do the right thing at the intersection of ESM/Node/TypeScript.

@reteps
Copy link
reteps commented Jun 26, 2025

Any progress on this?

@kyletsang
Copy link
Member

Any progress on this?

See #6939

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.

3 participants
0