Skip to content

Commit 62281ac

Browse files
committed
Use Webpack 5 PnP support. Setup resolve.alias to support url in browser.
1 parent c6718fe commit 62281ac

File tree

3 files changed

+13
-10
lines changed

3 files changed

+13
-10
lines changed

packages/react-scripts/config/webpack.config.js

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const fs = require('fs');
1212
const path = require('path');
1313
const webpack = require('webpack');
1414
const resolve = require('resolve');
15-
const PnpWebpackPlugin = require('pnp-webpack-plugin');
15+
// const PnpWebpackPlugin = require('pnp-webpack-plugin');
1616
const HtmlWebpackPlugin = require('html-webpack-plugin');
1717
const CaseSensitivePathsPlugin = require('case-sensitive-paths-webpack-plugin');
1818
const InlineChunkHtmlPlugin = require('react-dev-utils/InlineChunkHtmlPlugin');
@@ -323,7 +323,10 @@ module.exports = function(webpackEnv) {
323323
plugins: [
324324
// Adds support for installing with Plug'n'Play, leading to faster installs and adding
325325
// guards against forgotten dependencies and such.
326-
PnpWebpackPlugin,
326+
// Webpack 5 Change: PnP is supported by default in Webpack 5.
327+
// See https://github.com/arcanis/pnp-webpack-plugin/issues/22#issuecomment-597495032
328+
// PnpWebpackPlugin,
329+
327330
// Prevents users from importing files from outside of src/ (or node_modules/).
328331
// This often causes confusion because we only process files within src/ with babel.
329332
// To fix this, we prevent you from importing files out of src/ -- if you'd like to,
@@ -332,13 +335,13 @@ module.exports = function(webpackEnv) {
332335
new ModuleScopePlugin(paths.appSrc, [paths.appPackageJson]),
333336
],
334337
},
335-
resolveLoader: {
336-
plugins: [
337-
// Also related to Plug'n'Play, but this time it tells webpack to load its loaders
338-
// from the current package.
339-
PnpWebpackPlugin.moduleLoader(module),
340-
],
341-
},
338+
// resolveLoader: {
339+
// plugins: [
340+
// // Also related to Plug'n'Play, but this time it tells webpack to load its loaders
341+
// // from the current package.
342+
// PnpWebpackPlugin.moduleLoader(module),
343+
// ],
344+
// },
342345
module: {
343346
strictExportPresence: true,
344347
rules: [

packages/react-scripts/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@
6060
"jest-watch-typeahead": "0.4.2",
6161
"mini-css-extract-plugin": "0.9.0",
6262
"optimize-css-assets-webpack-plugin": "5.0.3",
63-
"pnp-webpack-plugin": "1.6.4",
6463
"path-browserify": "1.0.1",
6564
"postcss-flexbugs-fixes": "4.1.0",
6665
"postcss-loader": "3.0.0",

tasks/e2e-installs.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,7 @@ yarn start --smoke-test
276276
# ******************************************************************************
277277
# Test when PnP is enabled
278278
# ******************************************************************************
279+
279280
cd "$temp_app_path"
280281
npx create-react-app test-app-pnp --use-pnp
281282
cd test-app-pnp

0 commit comments

Comments
 (0)