From 13c3d9b87015e29a9e3b1e0e487acdcaaf6311a8 Mon Sep 17 00:00:00 2001
From: Ryan Christian <33403762+rschristian@users.noreply.github.com>
Date: Thu, 7 Jul 2022 20:10:28 -0500
Subject: [PATCH] feat: webpack v5 (#1645)
* feat: webpack-v5
* test: Update tests
* docs: Updating docs to reflect changes
* chore: Removing optimize-plugin local patch
---
.changeset/sweet-snakes-cheat.md | 12 ++
.eslintignore | 1 +
README.md | 14 +-
packages/cli/babel/index.js | 52 --------
packages/cli/package.json | 73 +++++------
packages/cli/src/index.js | 2 -
packages/cli/src/lib/babel-config.js | 25 ++--
packages/cli/src/lib/entry.js | 6 +-
packages/cli/src/lib/webpack/proxy-loader.js | 4 +-
packages/cli/src/lib/webpack/push-manifest.js | 49 ++++---
.../cli/src/lib/webpack/render-html-plugin.js | 35 +++--
packages/cli/src/lib/webpack/run-webpack.js | 17 +--
.../cli/src/lib/webpack/transform-config.js | 1 +
.../src/lib/webpack/webpack-base-config.js | 102 ++++-----------
.../src/lib/webpack/webpack-client-config.js | 112 ++++------------
packages/cli/src/resources/body-end.ejs | 20 ++-
packages/cli/src/resources/head-end.ejs | 2 +-
packages/cli/tests/build.test.js | 99 ++++++--------
packages/cli/tests/client.test.js | 40 +++---
packages/cli/tests/config-formats.test.js | 6 +-
packages/cli/tests/images/build.js | 122 ++++++------------
packages/cli/tests/lib/cli.js | 21 +--
packages/cli/tests/lib/utils.js | 38 ++++++
packages/cli/tests/service-worker.test.js | 7 +-
.../tests/subjects/custom-babelrc/.babelrc | 2 +-
.../subjects/custom-webpack/preact.config.js | 7 +-
.../preactConfig/cjs/function.js | 9 +-
.../preactConfig/cjs/object.js | 9 +-
.../preactConfig/esm/function.js | 9 +-
.../preactConfig/esm/object.js | 9 +-
.../subjects/public-path/preact.config.js | 2 +-
packages/cli/tests/watch.test.js | 11 --
32 files changed, 374 insertions(+), 544 deletions(-)
create mode 100644 .changeset/sweet-snakes-cheat.md
delete mode 100644 packages/cli/babel/index.js
diff --git a/.changeset/sweet-snakes-cheat.md b/.changeset/sweet-snakes-cheat.md
new file mode 100644
index 000000000..4f87f1b9e
--- /dev/null
+++ b/.changeset/sweet-snakes-cheat.md
@@ -0,0 +1,12 @@
+---
+'preact-cli': major
+---
+
+- Upgrades to Webpack v5
+ - Any custom configuration you do in your `preact.config.js` may need to be altered to account for this. Plugins may need replacements or different option formats.
+
+- `--esm` flag has been removed
+ - Dual output is now enabled by default in production builds.
+
+- `.babelrc` no longer overwrites matching keys
+ - Instead, the config will be merged in to the default. The default still takes precedence when there are conflicts, so you will still need to use your `preact.config.js` if you want to edit or remove default plugins or presets.
diff --git a/.eslintignore b/.eslintignore
index 66e817fc8..4ec2f1666 100644
--- a/.eslintignore
+++ b/.eslintignore
@@ -1,3 +1,4 @@
**/node_modules
**/tests/output
+**/tests/subjects/*/preact.config.js
**/*.d.ts
diff --git a/README.md b/README.md
index 91b5651c2..3e78f14e0 100644
--- a/README.md
+++ b/README.md
@@ -114,7 +114,7 @@ Note: If you don't specify enough data to the `npx preact-cli create` command, i
Create a production build
-You can disable `default: true` flags by prefixing them with `--no-