@modern-js/builder 2.23.1 → 2.24.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,26 @@
1
1
  # @modern-js/builder
2
2
 
3
+ ## 2.24.1
4
+
5
+ ### Patch Changes
6
+
7
+ - @modern-js/builder-shared@2.24.1
8
+ - @modern-js/utils@2.24.1
9
+
10
+ ## 2.24.0
11
+
12
+ ### Patch Changes
13
+
14
+ - ef041c0: chore(builder): reuse externals plugin
15
+
16
+ chore(builder): 复用 externals 插件
17
+
18
+ - Updated dependencies [c882fbd]
19
+ - Updated dependencies [ef041c0]
20
+ - Updated dependencies [4a82c3b]
21
+ - @modern-js/utils@2.24.0
22
+ - @modern-js/builder-shared@2.24.0
23
+
3
24
  ## 2.23.1
4
25
 
5
26
  ### Patch Changes
@@ -0,0 +1,2 @@
1
+ import { DefaultBuilderPlugin } from '@modern-js/builder-shared';
2
+ export declare function builderPluginExternals(): DefaultBuilderPlugin;
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.builderPluginExternals = void 0;
4
+ function builderPluginExternals() {
5
+ return {
6
+ name: 'builder-plugin-externals',
7
+ setup(api) {
8
+ api.modifyBundlerChain(chain => {
9
+ const { externals } = api.getNormalizedConfig().output;
10
+ if (externals) {
11
+ chain.externals(externals);
12
+ }
13
+ });
14
+ api.onBeforeCreateCompiler(({ bundlerConfigs }) => {
15
+ bundlerConfigs.forEach(config => {
16
+ const isWebWorker = Array.isArray(config.target)
17
+ ? config.target.includes('webworker')
18
+ : config.target === 'webworker';
19
+ // externals will not take effect, the Worker environment can not access global variables.
20
+ if (isWebWorker && config.externals) {
21
+ delete config.externals;
22
+ }
23
+ });
24
+ });
25
+ },
26
+ };
27
+ }
28
+ exports.builderPluginExternals = builderPluginExternals;
@@ -184,8 +184,6 @@ const builderPluginHtml = () => ({
184
184
  .use(HtmlCrossOriginPlugin, [
185
185
  { crossOrigin: formattedCrossorigin, HtmlPlugin },
186
186
  ]);
187
- // todo: not support in rspack
188
- // @ts-expect-error
189
187
  chain.output.crossOriginLoading(formattedCrossorigin);
190
188
  }
191
189
  if (faviconUrls.length) {
@@ -51,4 +51,5 @@ exports.plugins = {
51
51
  rem: () => Promise.resolve().then(() => __importStar(require('./rem'))).then(m => m.builderPluginRem()),
52
52
  wasm: () => Promise.resolve().then(() => __importStar(require('./wasm'))).then(m => m.builderPluginWasm()),
53
53
  moment: () => Promise.resolve().then(() => __importStar(require('./moment'))).then(m => m.builderPluginMoment()),
54
+ externals: () => Promise.resolve().then(() => __importStar(require('./externals'))).then(m => m.builderPluginExternals()),
54
55
  };
package/package.json CHANGED
@@ -18,7 +18,7 @@
18
18
  "engines": {
19
19
  "node": ">=14.0.0"
20
20
  },
21
- "version": "2.23.1",
21
+ "version": "2.24.1",
22
22
  "jsnext:source": "./src/index.ts",
23
23
  "types": "./dist/index.d.ts",
24
24
  "main": "./dist/index.js",
@@ -31,14 +31,14 @@
31
31
  },
32
32
  "dependencies": {
33
33
  "@svgr/webpack": "8.0.1",
34
- "@modern-js/builder-shared": "2.23.1",
35
- "@modern-js/utils": "2.23.1"
34
+ "@modern-js/builder-shared": "2.24.1",
35
+ "@modern-js/utils": "2.24.1"
36
36
  },
37
37
  "devDependencies": {
38
38
  "@types/babel__core": "^7.20.0",
39
39
  "@types/node": "^14",
40
40
  "typescript": "^5",
41
- "@scripts/vitest-config": "2.23.1"
41
+ "@scripts/vitest-config": "2.24.1"
42
42
  },
43
43
  "publishConfig": {
44
44
  "registry": "https://registry.npmjs.org/",