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

Webpack5 upgrade #1421

Merged
merged 67 commits into from
Mar 29, 2022
Merged
Show file tree
Hide file tree
Changes from 23 commits
Commits
Show all changes
67 commits
Select commit Hold shift + click to select a range
c5c50db
Bring webpack configuration to a valid (but not working) state
Feb 18, 2022
f139c67
webpack build working
Feb 21, 2022
a2c91cb
Remove sourcemap obsolete flag
Feb 21, 2022
3d3352d
Redo ForkTsCheckerWebpackPlugin conf
Feb 21, 2022
5fcacfa
Fix stats type mismatch
Feb 21, 2022
8fb8342
start.js
Feb 22, 2022
b20e694
dev server working but trying to typecheck node_modules
Feb 23, 2022
bdfd0ec
webpack start is working
Feb 23, 2022
8986bd9
Change css minimizer to remove deprecation
Feb 23, 2022
9bd0894
Remove diagnostics
Feb 23, 2022
510fb6b
Update snapshots
Feb 24, 2022
92597a4
Support new version of minimize
Feb 24, 2022
8bf2aea
Add explaining comment
Feb 24, 2022
c6df324
Merge remote-tracking branch 'origin/main' into feature/experiment-we…
Feb 28, 2022
5a340d0
Update yarn.lock
Feb 28, 2022
3122acf
Merge remote-tracking branch 'origin/main' into feature/experiment-we…
Mar 4, 2022
1f7a830
Merge remote-tracking branch 'origin/main' into feature/experiment-we…
Mar 7, 2022
8b1f89b
Merge remote-tracking branch 'origin/main' into feature/experiment-we…
Mar 8, 2022
f075c72
Update snapshots
Mar 8, 2022
7c98350
Update all snapshots
Mar 8, 2022
5f3c001
Update snapshot hash
Mar 8, 2022
7b45909
Add missing quotes
Mar 8, 2022
f97c6f2
Merge branch 'main' into feature/experiment-webpack-5
cristiano-belloni Mar 11, 2022
bc9cb4c
Remove unwanted media dist files
Mar 11, 2022
87964dd
remove tsbuildinfo
Mar 11, 2022
187f866
Merge remote-tracking branch 'origin/main' into feature/experiment-we…
Mar 11, 2022
e1abbef
Make test names decoupled from hashes
Mar 14, 2022
8816b88
Update test snapshots
Mar 14, 2022
4c7b6aa
Bump @babel/core from 7.17.5 to 7.17.7 (#1479)
dependabot[bot] Mar 16, 2022
a8b8837
Bump postcss from 8.4.8 to 8.4.11 (#1482)
dependabot[bot] Mar 16, 2022
6e21cf9
Bump @rollup/plugin-babel from 5.3.0 to 5.3.1 (#1426)
dependabot[bot] Mar 16, 2022
6c8dc62
Bump @types/puppeteer from 5.4.4 to 5.4.5 (#1429)
dependabot[bot] Mar 16, 2022
e5d772f
Create silver-dolphins-remember.md
cristiano-belloni Mar 16, 2022
681ab74
Merge remote-tracking branch 'origin/main' into feature/experiment-we…
Mar 17, 2022
639307c
Bump prettier from 2.5.1 to 2.6.0 (#1488)
dependabot[bot] Mar 17, 2022
5262deb
Bump lint-staged from 12.3.5 to 12.3.6 (#1489)
dependabot[bot] Mar 17, 2022
2f2109d
Bump dotenv-expand from 8.0.1 to 8.0.2 (#1475)
dependabot[bot] Mar 17, 2022
1d35d85
Bump postcss from 8.4.11 to 8.4.12 (#1487)
dependabot[bot] Mar 17, 2022
b324d6e
Bump @types/node from 17.0.18 to 17.0.21 (#1432)
dependabot[bot] Mar 17, 2022
016d195
Bump typescript from 4.4.4 to 4.6.2 (#1440)
dependabot[bot] Mar 17, 2022
a04a237
Bump eslint-plugin-testing-library from 5.0.6 to 5.1.0 (#1473)
dependabot[bot] Mar 17, 2022
7b01937
Bump eslint-plugin-react from 7.27.0 to 7.29.4 (#1476)
dependabot[bot] Mar 17, 2022
07052ac
Remove requireEnsure
Mar 21, 2022
7489071
fix: package builds respect --private option (#1433)
benpryke Mar 22, 2022
55df9e0
Merge remote-tracking branch 'origin/main' into feature/experiment-we…
Mar 22, 2022
8ace2f4
Bump lint-staged from 12.3.6 to 12.3.7 (#1490)
dependabot[bot] Mar 22, 2022
40a8c32
Bump @types/react-dom from 17.0.13 to 17.0.14 (#1491)
dependabot[bot] Mar 22, 2022
673d491
Bump node-forge from 1.2.1 to 1.3.0 (#1499)
dependabot[bot] Mar 22, 2022
8c83ea2
Bump @babel/core from 7.17.7 to 7.17.8 (#1493)
dependabot[bot] Mar 23, 2022
da74950
Bump @types/node from 17.0.21 to 17.0.22 (#1497)
dependabot[bot] Mar 23, 2022
7433583
Bump @types/node from 17.0.22 to 17.0.23 (#1502)
dependabot[bot] Mar 24, 2022
a82482d
Bump @types/react from 17.0.40 to 17.0.42 (#1501)
dependabot[bot] Mar 24, 2022
69be206
Bump postcss-preset-env from 7.4.2 to 7.4.3 (#1496)
dependabot[bot] Mar 24, 2022
790ab7f
Bump @testing-library/dom from 8.11.2 to 8.11.4 (#1500)
dependabot[bot] Mar 24, 2022
178796b
Bump minimist from 1.2.5 to 1.2.6 (#1504)
dependabot[bot] Mar 24, 2022
1a39571
Relax our dependency criteria (#1503)
cristiano-belloni Mar 25, 2022
985a2d7
Version Packages (#1261)
github-actions[bot] Mar 25, 2022
bd5e86b
Merge remote-tracking branch 'origin/main' into feature/experiment-we…
Mar 25, 2022
22c2114
fix node-12 incompatible javascript (#1517)
LukeSheard Mar 28, 2022
d896289
Revert engine range (#1518)
cristiano-belloni Mar 28, 2022
1503e78
Version Packages (#1519)
github-actions[bot] Mar 28, 2022
4846d21
Fix bug that prevents lint diff code from running (#1510)
cheemcheem Mar 28, 2022
1916c58
Enable pre-release workflow (#1486)
cristiano-belloni Mar 28, 2022
5a6dfdc
Merge remote-tracking branch 'origin/main' into feature/experiment-we…
Mar 28, 2022
47e1ec4
Update snapshots
Mar 28, 2022
64f46f7
Update build snapshots
Mar 28, 2022
41ded67
Update browser versions
Mar 28, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions packages/modular-scripts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@
"change-case": "4.1.2",
"commander": "8.2.0",
"cross-spawn": "7.0.3",
"css-loader": "4.3.0",
"css-loader": "6.6.0",
"css-minimizer-webpack-plugin": "3.4.1",
"dedent": "0.7.0",
"detect-port-alt": "1.1.6",
"dotenv": "16.0.0",
Expand All @@ -56,12 +57,12 @@
"file-loader": "6.2.0",
"filesize": "8.0.3",
"find-up": "5.0.0",
"fork-ts-checker-webpack-plugin": "4.1.6",
"fork-ts-checker-webpack-plugin": "6.5.0",
"fs-extra": "10.0.0",
"global-modules": "2.0.0",
"globby": "11.0.4",
"gzip-size": "6.0.0",
"html-webpack-plugin": "4.5.2",
"html-webpack-plugin": "5.5.0",
"is-ci": "2.0.0",
"is-root": "2.1.0",
"jest": "26.6.3",
Expand All @@ -72,19 +73,18 @@
"jest-transform-stub": "2.0.0",
"jest-watch-typeahead": "0.6.5",
"js-yaml": "^4.1.0",
"loader-utils": "2.0.0",
"loader-utils": "3.2.0",
"micromatch": "4.0.4",
"mime": "^3.0.0",
"mini-css-extract-plugin": "0.11.3",
"mini-css-extract-plugin": "2.5.3",
"npm-packlist": "3.0.0",
"open": "8.3.0",
"optimize-css-assets-webpack-plugin": "6.0.1",
"parse5": "6.0.1",
"pkg-up": "3.1.0",
"pnp-webpack-plugin": "1.6.4",
"pnp-webpack-plugin": "1.7.0",
"postcss": "8.4.8",
"postcss-flexbugs-fixes": "4.2.1",
"postcss-loader": "4.2.0",
"postcss-loader": "6.2.1",
"postcss-normalize": "8.0.1",
"postcss-preset-env": "7.4.1",
"postcss-safe-parser": "5.0.2",
Expand All @@ -94,27 +94,27 @@
"react-refresh": "0.8.3",
"recursive-readdir": "2.2.2",
"resolve": "1.21.0",
"resolve-url-loader": "5.0.0-beta.1",
"resolve-url-loader": "5.0.0",
"rimraf": "3.0.2",
"rollup": "2.67.2",
"rollup-plugin-esbuild": "^4.7.2",
"rollup-plugin-postcss": "4.0.2",
"sass-loader": "10.0.5",
"sass-loader": "12.6.0",
"semver": "7.3.5",
"semver-regex": "3.1.3",
"shell-quote": "1.7.3",
"source-map-support": "0.5.21",
"strip-ansi": "6.0.0",
"style-loader": "1.3.0",
"terser-webpack-plugin": "4.2.3",
"style-loader": "3.3.1",
"terser-webpack-plugin": "5.3.1",
"tmp": "^0.2.1",
"ts-jest": "26.5.6",
"ts-morph": "^13.0.2",
"update-notifier": "5.1.0",
"url-loader": "4.1.1",
"webpack": "4.46.0",
"webpack": "5.69.1",
"webpack-dev-server": "4.7.4",
"webpack-manifest-plugin": "2.2.0",
"webpack-manifest-plugin": "4.1.1",
"ws": "8.5.0"
},
"peerDependencies": {
Expand Down
79 changes: 8 additions & 71 deletions packages/modular-scripts/react-dev-utils/WebpackDevServerUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ const forkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
const { clearConsole } = require('./logger');
const formatWebpackMessages = require('./formatWebpackMessages');
const getProcessForPort = require('./getProcessForPort');
const typescriptFormatter = require('./typescriptFormatter');
const console = require('./logger');

const isInteractive = process.stdout.isTTY;
Expand Down Expand Up @@ -94,15 +93,7 @@ function printInstructions(appName, urls) {
console.log();
}

function createCompiler({
appName,
config,
devSocket,
urls,
useTypeScript,
tscCompileOnError,
webpack,
}) {
function createCompiler({ appName, config, urls, useTypeScript, webpack }) {
// "Compiler" is a low-level interface to webpack.
// It lets us listen to some events and provide our own custom messages.
let compiler;
Expand All @@ -129,28 +120,16 @@ function createCompiler({

let isFirstCompile = true;
let tsMessagesPromise;
let tsMessagesResolver;

if (useTypeScript) {
compiler.hooks.beforeCompile.tap('beforeCompile', () => {
tsMessagesPromise = new Promise((resolve) => {
tsMessagesResolver = (msgs) => resolve(msgs);
});
});

forkTsCheckerWebpackPlugin
.getCompilerHooks(compiler)
.receive.tap('afterTypeScriptCheck', (diagnostics, lints) => {
const allMsgs = [...diagnostics, ...lints];
const format = (message) =>
`${message.file}\n${typescriptFormatter(message, true)}`;

tsMessagesResolver({
errors: allMsgs.filter((msg) => msg.severity === 'error').map(format),
warnings: allMsgs
.filter((msg) => msg.severity === 'warning')
.map(format),
});
.waiting.tap('awaitingTypeScriptCheck', () => {
console.log(
chalk.yellow(
'Files successfully emitted, waiting for typecheck results...',
),
);
});
}

Expand All @@ -172,48 +151,6 @@ function createCompiler({
errors: true,
});

if (useTypeScript && statsData.errors.length === 0) {
const delayedMsg = setTimeout(() => {
console.log(
chalk.yellow(
'Files successfully emitted, waiting for typecheck results...',
),
);
}, 100);

const messages = await tsMessagesPromise;
clearTimeout(delayedMsg);
if (tscCompileOnError) {
statsData.warnings.push(...messages.errors);
} else {
statsData.errors.push(...messages.errors);
}
statsData.warnings.push(...messages.warnings);

// Push errors and warnings into compilation result
// to show them after page refresh triggered by user.
if (tscCompileOnError) {
stats.compilation.warnings.push(...messages.errors);
} else {
stats.compilation.errors.push(...messages.errors);
}
stats.compilation.warnings.push(...messages.warnings);

if (messages.errors.length > 0) {
if (tscCompileOnError) {
devSocket.warnings(messages.errors);
} else {
devSocket.errors(messages.errors);
}
} else if (messages.warnings.length > 0) {
devSocket.warnings(messages.warnings);
}

if (isInteractive) {
clearConsole();
}
}

const messages = formatWebpackMessages(statsData);
const isSuccessful = !messages.errors.length && !messages.warnings.length;
if (isSuccessful) {
Expand Down Expand Up @@ -371,7 +308,7 @@ function prepareProxy(proxy, appPublicFolder, servedPathname) {
// If proxy is specified, let it handle any request except for
// files in the public folder and requests to the WebpackDevServer socket endpoint.
// https://github.com/facebook/create-react-app/issues/6720
const sockPath = process.env.WDS_SOCKET_PATH || '/sockjs-node';
const sockPath = process.env.WDS_SOCKET_PATH || '/ws';
const isDefaultSockHost = !process.env.WDS_SOCKET_HOST;
function mayProxy(pathname) {
const maybePublicPath = path.resolve(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ function base64SourceMap(source) {
}

function getSourceById(server, id) {
const module = server._stats.compilation.modules.find((m) => m.id === id);
const module = Array.from(server._stats.compilation.modules).find(
(m) => server._stats.compilation.chunkGraph.getModuleId(m) === id,
);
return module.originalSource();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,13 @@ function isLikelyASyntaxError(message) {

// Cleans up webpack error messages.
function formatMessage(message) {
let lines = message.split('\n');
let lines = [];

if (typeof message === 'string' || message instanceof String) {
lines = message.split('\n');
} else if ('message' in message) {
lines = message['message'].split('\n');
}

// Strip webpack-added headers off errors/warnings
// https://github.com/webpack/webpack/blob/master/lib/ModuleError.js
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ var connection = new WebSocket(
hostname: process.env.WDS_SOCKET_HOST || window.location.hostname,
port: process.env.WDS_SOCKET_PORT || window.location.port,
// Hardcoded in WebpackDevServer
pathname: process.env.WDS_SOCKET_PATH || '/sockjs-node',
pathname: process.env.WDS_SOCKET_PATH || '/ws',
slashes: true,
}),
);
Expand Down
Loading