-
-
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
Changes from 7 commits
f04f0dd
63152ef
6eb3f33
7c362b0
eae3d82
5bbe63a
747ba0e
3609e33
6862713
543f5f8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,7 @@ | |
|
||
const path = require('path'); | ||
const webpack = require('webpack'); | ||
const PnpWebpackPlugin = require('pnp-webpack-plugin'); | ||
const HtmlWebpackPlugin = require('html-webpack-plugin'); | ||
const CaseSensitivePathsPlugin = require('case-sensitive-paths-webpack-plugin'); | ||
const InterpolateHtmlPlugin = require('react-dev-utils/InterpolateHtmlPlugin'); | ||
|
@@ -149,13 +150,29 @@ module.exports = { | |
'react-native': 'react-native-web', | ||
}, | ||
plugins: [ | ||
// Adds support for installing with Plug'n'Play, leading to faster installs and adding | ||
// guards against forgotten dependencies and such. | ||
PnpWebpackPlugin, | ||
// 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 commentThe 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? Is this something we want to do anyway? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we do this, symlinking There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @Timer where is defined this There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
}, | ||
resolveLoader: { | ||
plugins: [ | ||
// Also related to Plug'n'Play, but this time it tells Webpack to load its loaders | ||
// from the current package. | ||
PnpWebpackPlugin.moduleLoader(module), | ||
], | ||
// 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, | ||
}, | ||
module: { | ||
strictExportPresence: true, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 commentThe reason will be displayed to describe this comment to others. Learn more. This leaves an absolute path after ejecting. |
||
setupTestFrameworkScriptFile: setupTestsFile, | ||
testMatch: [ | ||
'<rootDir>/src/**/__tests__/**/*.{js,jsx}', | ||
|
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.