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

Do not use .mjs extension for ES module files #419

Open
aldeed opened this issue Jul 12, 2019 · 4 comments
Open

Do not use .mjs extension for ES module files #419

aldeed opened this issue Jul 12, 2019 · 4 comments

Comments

@aldeed
Copy link
Contributor

aldeed commented Jul 12, 2019

Type: minor

Describe the bug
When a Webpack app imports this package and styled-components, two copies of the styled-components code are bundled. See Webpack issue: webpack/webpack#9329

Expected behavior
Only one copy of styled-components package should be bundled.

Solution
This still seems like something wrong in Webpack, but as discovered in the issue, the problem stems from the .mjs extension, which we need not use to provide ES modules. So the solution is to update this file in a few places to use .esm.js instead of .mjs as the extension.

@aldeed
Copy link
Contributor Author

aldeed commented Jul 12, 2019

@willopez I think if you do this and publish updated package, you will then be able to remove your other resolve workaround in the apps that had this issue.

@Kiailandi
Copy link

Kiailandi commented Jan 20, 2020

This is a major issue for me, as the two styled-components modules seem to be interfering with each other and they end up breaking either the reaction components style or the style of my "handmade" components.

EDIT: I "fixed" it adding an alias for styled-components in webpack to force it to chose just one version of it.

@HarisSpahijaPon
Copy link
Contributor

Would you mind sharing your solution for future troubleshooting @Kiailandi ?

@Kiailandi
Copy link

Kiailandi commented Feb 14, 2020

I added an alias for styled-components in my webpack config file forcing the choice on the one coming from the styled-components package itself.

resolve: { extensions: ['.mjs', '.js', '.jsx', '.tsx', '.ts'], alias: { 'styled-components': 'styled-components/dist/styled-components.browser.esm.js', } }

EDIT: sorry about the format, I don't really understand why it removes the line breaks even if it's formatted as code.

@aldeed aldeed self-assigned this Feb 26, 2020
@aldeed aldeed removed their assignment May 21, 2020
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

3 participants