From 8f38ae7de9ef4633919827ec97562835f8866fd6 Mon Sep 17 00:00:00 2001 From: fushen Date: Thu, 21 Apr 2022 15:59:10 +0800 Subject: [PATCH] fix: exports field build error in webpack4 --- CHANGELOG.md | 5 +++++ packages/plugin-rax-app/CHANGELOG.md | 4 ++++ packages/plugin-rax-app/package.json | 4 ++-- packages/plugin-rax-app/src/base.js | 8 ++++---- packages/rax-app/package.json | 6 +++--- 5 files changed, 18 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 043e21639..979c2446b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,8 +1,13 @@ ## Changelog +## 3.8.16 + +- Fix: exports field build error in webpack4 + ## 3.8.15 - Chore: update @builder/pack to 0.6.x, more detail see https://github.com/ice-lab/builder-deps/pull/20 +- Feat: change the way of options pass into postcss-loader because the update of it ## 3.8.14 diff --git a/packages/plugin-rax-app/CHANGELOG.md b/packages/plugin-rax-app/CHANGELOG.md index 0f3f04a09..442732e3b 100644 --- a/packages/plugin-rax-app/CHANGELOG.md +++ b/packages/plugin-rax-app/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## 7.0.10 + +- Fix: resolve error with `import` in webpack4 + ## 7.0.9 - Fix: the way of options pass into `postcss-loader` because the update of `postcss-loader` diff --git a/packages/plugin-rax-app/package.json b/packages/plugin-rax-app/package.json index cfcf7bd6e..05c5718cd 100644 --- a/packages/plugin-rax-app/package.json +++ b/packages/plugin-rax-app/package.json @@ -1,6 +1,6 @@ { "name": "build-plugin-rax-app", - "version": "7.0.9", + "version": "7.0.10", "description": "The basic webpack configuration for rax project", "author": "Rax Team", "main": "lib/index.js", @@ -52,4 +52,4 @@ "url": "git@github.com:raxjs/rax-app.git" }, "gitHead": "07ac7bb07162aac8c90778dd1de4a2060f8df498" -} +} \ No newline at end of file diff --git a/packages/plugin-rax-app/src/base.js b/packages/plugin-rax-app/src/base.js index 145989d01..3b6967486 100644 --- a/packages/plugin-rax-app/src/base.js +++ b/packages/plugin-rax-app/src/base.js @@ -107,13 +107,12 @@ module.exports = (api, { target, babelConfigOptions, progressOptions = {} }) => }); } - const conditionNames = [target, '...']; - // Add condition names if (isWebpack4) { config.plugin('ExportsFieldWebpackPlugin').use(ExportsFieldWebpackPlugin, [ { - conditionNames, + // In webpack4, import, require, node for fallback + conditionNames: [target, 'import', 'require', 'node'], }, ]); // Set dev server content base @@ -122,7 +121,8 @@ module.exports = (api, { target, babelConfigOptions, progressOptions = {} }) => config.target('web'); } else { config.resolve.merge({ - conditionNames, + // Webpack5+ will dynamic return default value with ..., which depends on build task target + conditionNames: [target, '...'], }); // Set dev server content base diff --git a/packages/rax-app/package.json b/packages/rax-app/package.json index 7b5309629..a32ddee24 100644 --- a/packages/rax-app/package.json +++ b/packages/rax-app/package.json @@ -1,6 +1,6 @@ { "name": "rax-app", - "version": "3.8.15", + "version": "3.8.16", "description": "command line interface and builtin plugin for rax app", "author": "Rax Team", "homepage": "https://github.com/raxjs/rax-app#readme", @@ -18,7 +18,7 @@ "build-scripts": "^1.1.0", "build-plugin-app-core": "2.1.0", "build-plugin-ice-config": "2.0.2", - "build-plugin-rax-app": "7.0.9", + "build-plugin-rax-app": "7.0.10", "build-plugin-rax-kraken": "2.1.1", "build-plugin-rax-miniapp": "2.0.2", "build-plugin-rax-pha": "2.1.1", @@ -56,4 +56,4 @@ "node": ">=12.22.0", "npm": ">=3.0.0" } -} +} \ No newline at end of file