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

Add support for .mjs extension from dependencies (such as graphql) #4642

Closed
wants to merge 1 commit into from

Conversation

christemple
Copy link

@christemple christemple commented Jun 18, 2018

Here is the fix for supporting .mjs files from dependencies referenced here: #4637

I've verified the changes both before and after, here's the after screenshot:

graphql loaded successfully

I tried writing some tests for the .mjs support but failed to get the e2e docker tests running on my local machine after following this guide (was failing with user permissions?)

I'm hoping that CI will pick it up and run smoothly, if not I'd really appreciate some help in getting the tests to run locally 👍

@christemple
Copy link
Author

Also I just noticed there's been some auto-formatting committed, if you're unhappy with it I'll be happy to remove it

@Timer
Copy link
Contributor

Timer commented Jun 18, 2018

Why does this fix work? Why not include everything and only node_modules?

@Timer
Copy link
Contributor

Timer commented Jun 18, 2018

Per your comment here (#4637 (comment)) it seems this isn't a bug that needs fixed.

@facebook-github-bot
Copy link

Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please sign up at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need the corporate CLA signed.

If you have received this in error or have any questions, please contact us at cla@fb.com. Thanks!

@bugzpodder
Copy link

i messed up the autoformatting a while ago, it's ok to include it.

@facebook-github-bot
Copy link

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks!

@christemple
Copy link
Author

@Timer I'm a bit confused about your not needing fixed comment, my comment on #4637 (comment) is implying that this is still an issue that needs addressed, I tried the suggested steps and due to semver issues with the sha in the package version it installed a previous version of react-scripts that wasn't using Webpack 4. That's why it appeared as if there was no error.

I've provided an explanation as to why the issue is being caused in the issue

The solution that I am proposing in this PR is to change the default behaviour in Webpack 4 of how it treats .mjs files.

While I suspect the graphql package is the culprit here and isn't producing a valid .mjs compatible package, I am also weary that it may be the first of many.

The change that I've made in the webpack config instructs webpack to treat .mjs files from dependencies exactly like it was in Webpack 3.

I believe doing so will result in a smoother 2.0 milestone release for create-react-app as we'll still get most of the benefits of Webpack 4 without having external dependencies hinder our user experience.

At least until .mjs becomes more widespread and issues get ironed out.

@christemple
Copy link
Author

Also, I struggled to get the tests to run on my machine but hoped CI would be more reliable, but it looks like PRs being raised for a simple documentation change is breaking CI.

Are the tests currently stable in next?

Thanks

@Timer
Copy link
Contributor

Timer commented Jun 19, 2018

This looks more like a webpack bug, can we report it there?
Also, tests currently are not stable.

@christemple
Copy link
Author

christemple commented Jun 19, 2018

@Timer I'm in the process of narrowing down the issue with either webpack or graphql, and plan on raising issues where appropriate.

However I believe it still makes sense to include the config to mitigate the issue (and possible future ones) in the mean time to prevent blocking the 2.0 milestone release?

@Timer
Copy link
Contributor

Timer commented Jun 19, 2018

Looking at the source makes graphql look fine: https://unpkg.com/graphql@0.13.2/jsutils/instanceOf.mjs

And not necessarily, if this is a webpack bug it will be fixed before the 2.0 release and the 2.0 is probably 2-3 months away still.
If users need the old functionality they can use the previous alpha, it is alpha software after all. 😄

@Timer
Copy link
Contributor

Timer commented Sep 21, 2018

We dropped all .mjs support for now. Thanks for your time, though!

@Timer Timer closed this Sep 21, 2018
@lock lock bot locked and limited conversation to collaborators Jan 19, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants