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

.default is back in 8.0 #238

Closed
realityking opened this issue Jan 13, 2018 · 2 comments
Closed

.default is back in 8.0 #238

realityking opened this issue Jan 13, 2018 · 2 comments

Comments

@realityking
Copy link
Contributor

Unfortunately adding the modules property to package.json in #234 brought #221 back. We're using webpack 3.10.0

This is especially painful when trying to use both Node.js for server side rendering and the browser.

I fixed this by adding mainFields: ['browser', 'main'] to our webpack config though that's obviously not optimal.

@trotzig
Copy link
Collaborator

trotzig commented Jan 17, 2018

Ouch, sorry about that. I see why this would be painful in a project mixing commonjs requires and es imports. I've tried to find a solution to this but I'm coming up short. Do you know of any libraries out there that publish both a main and a module and still works with es and commonjs?

@realityking
Copy link
Contributor Author

The thing is we're not actually mixing them - our codebase is 100% CommonJS. The problem is that webpack doesn't play nice. 😞

Given the current state of the ecosystem I think the only safe way to ship both ESM and CJS in the same package is to not have any default exports. If every export is a named export things work as expected.

realityking added a commit to realityking/react-waypoint that referenced this issue Dec 11, 2018
realityking added a commit to realityking/react-waypoint that referenced this issue Dec 12, 2018
realityking added a commit to realityking/react-waypoint that referenced this issue Jan 23, 2019
realityking added a commit to realityking/react-waypoint that referenced this issue Jan 23, 2019
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