-
-
Notifications
You must be signed in to change notification settings - Fork 26.9k
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
Plug'n'Play support #5136
Plug'n'Play support #5136
Conversation
We probably need the Jest resolver too, right? |
Oh likely, yes - I tested |
Got it working with the plugin, just one interesting problem - Babel transforms the code to use the If Apart from moving |
The full path option sounds great, especially because it's immediately bundled in other parts of the app. |
Pushed a commit that does exactly this (I'll move it in a separate PR later too so it can be merged independently) 👍 I also need to merge yarnpkg/yarn#6444 and yarnpkg/yarn#6443 on Yarn's side. Will then continue investigating to make sure everything's ok. Do you have suggestions to add tests? Can I just add a travis config that uses PnP to make the install? |
We need to majorly overhaul our testing, but a travis config that uses PnP would be best for now. |
Here we go! All green 😃 Note that this PR only makes create-native-app compatible with PnP environments, but doesn't expose a way to toggle it on from the command line (apart from using |
@arcanis Could you clarify what happens to ESLint in the meantime? |
You can add a |
|
||
const nodeArgs = fs.existsSync(pnpPath) ? ['--require', pnpPath] : []; | ||
|
||
await executeNodeScript( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this work on Node LTS version?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think so, it doesn't use any recent feature and the Node 8 tests pass.
// Prevents users from importing files from outside of src/ (or node_modules/). | ||
// This often causes confusion because we only process files within src/ with babel. | ||
// To fix this, we prevent you from importing files out of src/ -- if you'd like to, | ||
// please link the files into your node_modules/ and let module-resolution kick in. | ||
// Make sure your source files are compiled, as they will not be processed in any way. | ||
new ModuleScopePlugin(paths.appSrc, [paths.appPackageJson]), | ||
], | ||
// Plug'n'Play relies on symlink for its virtual paths (ie peer dependencies), which Webpack | ||
// always resolve to the absolute path on disk by default. | ||
symlinks: false, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we're not in PnP mode, would that create problems? It seems like potential breaking change, no?
I'm not sure how this impacts behavior but I wouldn't be surprised if it does.
Is this something we want to do anyway?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we do this, symlinking src/
to node_modules/@
won't work because we'll treat app code as node_module
code (instead of application code).
We could add special behavior to compile code from @
as app code, but I'd want to collect feedback on what people are using symlinks for currently -- I suspect it'll be in line with the behavior we want.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Timer where is defined this @
symlink? Shouldn't it be an alias
entry in webpack/jest?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We didn’t add this feature yet. We were hoping we could do it via symlink instead of adding a special alias to every tool. It would be nice to not confuse IDEs, Flow, etc, which symlink could help with.
I added CRA/ESLint compatibility with yarnpkg/yarn#6449. It basically makes
Will check 👍 |
Can you describe effects of this change in detail, unrelated to PnP? I think this will probably break some existing use cases but I’m not sure they’re valid in the first place. I’m also not sure how this relates to Jest behavior (does Jest match behavior with this flag on or off?) Also is this related to #3883? |
How can I test this? |
I found a way to avoid As for testing I didn't test directly on create-react-app, but I got a case where |
Ah that sounds fine, thanks. I meant — how can I test this PR? Do I need to build yarn from master? |
The nightly Yarn should be fine: https://nightly.yarnpkg.com/yarn-1.12.0-20180928.1315.js To enable PnP when creating a new project, you can set the |
Do we know why AppVeyor build is timing out? |
Appears to have started with 2a7346e, though it did not add any new tests for AppVeyor -- strictly Travis. Maybe the |
Thanks! |
@@ -22,7 +22,8 @@ module.exports = (resolve, rootDir, isEjecting) => { | |||
// in Jest configs. We need help from somebody with Windows to determine this. | |||
const config = { | |||
collectCoverageFrom: ['src/**/*.{js,jsx}'], | |||
setupFiles: ['react-app-polyfill/jsdom'], | |||
resolver: require.resolve('jest-pnp-resolver'), | |||
setupFiles: [require.resolve('react-app-polyfill/jsdom')], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This leaves an absolute path after ejecting.
* Adds the PnP plugin for Webpack to find dependencies when working under PnP * Adds configuration for jest * Adds an e2e test for when using PnP * Avoids cra from crashing at the engine check * Avoids cra from crashing when initializing react-scripts * Makes the ownPath portable * Fixes linting * Bumps to pnp-webpack-plugin@1.1.0, removes symlinks: false * Adds a --use-pnp option * Pin version
Fixes #5117 - there's still at least one issue with ESLint which cannot load its plugins, and as a result crashes (eslint/eslint#10125), but at least it gets to this point 🙂