@modern-js/builder 2.6.0 → 2.8.0

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,41 @@
1
1
  # @modern-js/builder
2
2
 
3
+ ## 2.8.0
4
+
5
+ ### Patch Changes
6
+
7
+ - bd369a89a4: fix(builder): failed to set CDN URL via html.tags
8
+
9
+ fix(builder): 修复 html.tags 无法设置 CDN URL 的问题
10
+
11
+ - Updated dependencies [bd369a89a4]
12
+ - Updated dependencies [1104a9f18b]
13
+ - Updated dependencies [2c1151271d]
14
+ - Updated dependencies [481461a61d]
15
+ - Updated dependencies [1f6ca2c7fb]
16
+ - @modern-js/builder-shared@2.8.0
17
+ - @modern-js/utils@2.8.0
18
+
19
+ ## 2.7.0
20
+
21
+ ### Minor Changes
22
+
23
+ - dfece9dc1c: fix(builder): vendor library chunks include sources
24
+ fix(builder): 用户源码被划分到第三方库所在 Chunk
25
+
26
+ ### Patch Changes
27
+
28
+ - Updated dependencies [206c806efa]
29
+ - Updated dependencies [0f15fc597c]
30
+ - Updated dependencies [5f899af53a]
31
+ - Updated dependencies [dcad887024]
32
+ - Updated dependencies [a4672f7c16]
33
+ - Updated dependencies [ebe0d2dd6e]
34
+ - Updated dependencies [7fff9020e1]
35
+ - Updated dependencies [84bfb439b8]
36
+ - @modern-js/builder-shared@2.7.0
37
+ - @modern-js/utils@2.7.0
38
+
3
39
  ## 2.6.0
4
40
 
5
41
  ### Patch Changes
package/README.md CHANGED
@@ -5,12 +5,12 @@
5
5
  <p align="center">
6
6
  Modern.js Builder
7
7
  <br/>
8
- <a href="https://modernjs.dev/builder" target="blank">
8
+ <a href="https://modernjs.dev/builder/en" target="blank">
9
9
  modernjs.dev/builder
10
10
  </a>
11
11
  </p>
12
12
  <p align="center">
13
- A Build Engine for web development.
13
+ A build engine for web development.
14
14
  </p>
15
15
 
16
16
  # @modern-js/builder
@@ -24,4 +24,4 @@ This is the core package of Modern.js Builder.
24
24
 
25
25
  ## Contributing
26
26
 
27
- - [Contributing Guide](https://github.com/modern-js-dev/modern.js/blob/main/CONTRIBUTING.md)
27
+ - [Contributing Guide](https://github.com/web-infra-dev/modern.js/blob/main/CONTRIBUTING.md)
@@ -66,8 +66,6 @@ async function getChunks(entryName, entryValue) {
66
66
  }
67
67
  return [...dependOn, entryName];
68
68
  }
69
- // Determine if the string is a favicon url
70
- const isFaviconUrl = (str) => str.startsWith('http');
71
69
  const applyInjectTags = (api) => {
72
70
  api.modifyBundlerChain(async (chain, { HtmlPlugin, CHAIN_ID }) => {
73
71
  const config = api.getNormalizedConfig();
@@ -141,7 +139,7 @@ const builderPluginHtml = () => ({
141
139
  templateParameters,
142
140
  };
143
141
  if (favicon) {
144
- if (isFaviconUrl(favicon)) {
142
+ if ((0, builder_shared_1.isURL)(favicon)) {
145
143
  faviconUrls.push({
146
144
  filename,
147
145
  url: favicon,
@@ -11,6 +11,7 @@ export declare const plugins: {
11
11
  toml: () => Promise<import("@modern-js/builder-shared").DefaultBuilderPlugin>;
12
12
  svg: () => Promise<import("@modern-js/builder-shared").DefaultBuilderPlugin>;
13
13
  splitChunks: () => Promise<import("@modern-js/builder-shared").DefaultBuilderPlugin>;
14
+ inlineChunk: () => Promise<import("@modern-js/builder-shared").DefaultBuilderPlugin>;
14
15
  bundleAnalyzer: () => Promise<import("@modern-js/builder-shared").DefaultBuilderPlugin>;
15
16
  font: () => Promise<import("@modern-js/builder-shared").DefaultBuilderPlugin>;
16
17
  image: () => Promise<import("@modern-js/builder-shared").DefaultBuilderPlugin>;
@@ -38,6 +38,7 @@ exports.plugins = {
38
38
  toml: () => Promise.resolve().then(() => __importStar(require('./toml'))).then(m => m.builderPluginToml()),
39
39
  svg: () => Promise.resolve().then(() => __importStar(require('./svg'))).then(m => m.builderPluginSvg()),
40
40
  splitChunks: () => Promise.resolve().then(() => __importStar(require('./splitChunks'))).then(m => m.builderPluginSplitChunks()),
41
+ inlineChunk: () => Promise.resolve().then(() => __importStar(require('./inlineChunk'))).then(m => m.builderPluginInlineChunk()),
41
42
  bundleAnalyzer: () => Promise.resolve().then(() => __importStar(require('./bundleAnalyzer'))).then(m => m.builderPluginBundleAnalyzer()),
42
43
  font: () => Promise.resolve().then(() => __importStar(require('./asset'))).then(m => m.builderAssetPlugin('font', builder_shared_1.FONT_EXTENSIONS)),
43
44
  image: () => Promise.resolve().then(() => __importStar(require('./asset'))).then(m => m.builderAssetPlugin('image', builder_shared_1.IMAGE_EXTENSIONS)),
@@ -0,0 +1,2 @@
1
+ import { DefaultBuilderPlugin } from '@modern-js/builder-shared';
2
+ export declare const builderPluginInlineChunk: () => DefaultBuilderPlugin;
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.builderPluginInlineChunk = void 0;
27
+ const builder_shared_1 = require("@modern-js/builder-shared");
28
+ const builderPluginInlineChunk = () => ({
29
+ name: 'builder-plugin-inline-chunk',
30
+ setup(api) {
31
+ api.modifyBundlerChain(async (chain, { target, CHAIN_ID, isProd, HtmlPlugin }) => {
32
+ const config = api.getNormalizedConfig();
33
+ if ((0, builder_shared_1.isHtmlDisabled)(config, target) || !isProd) {
34
+ return;
35
+ }
36
+ const { InlineChunkHtmlPlugin } = await Promise.resolve().then(() => __importStar(require('@modern-js/builder-shared')));
37
+ const { disableInlineRuntimeChunk, enableInlineStyles,
38
+ // todo: not support enableInlineScripts in Rspack yet, which will take unknown build error
39
+ enableInlineScripts, } = config.output;
40
+ chain.plugin(CHAIN_ID.PLUGIN.INLINE_HTML).use(InlineChunkHtmlPlugin, [
41
+ HtmlPlugin,
42
+ {
43
+ tests: [
44
+ enableInlineScripts && /\.js$/,
45
+ enableInlineStyles && /\.css$/,
46
+ !disableInlineRuntimeChunk &&
47
+ // RegExp like /builder-runtime([.].+)?\.js$/
48
+ // matches builder-runtime.js and builder-runtime.123456.js
49
+ new RegExp(`${builder_shared_1.RUNTIME_CHUNK_NAME}([.].+)?\\.js$`),
50
+ ].filter(Boolean),
51
+ distPath: (0, builder_shared_1.pick)(config.output.distPath, ['js', 'css']),
52
+ },
53
+ ]);
54
+ });
55
+ },
56
+ });
57
+ exports.builderPluginInlineChunk = builderPluginInlineChunk;
@@ -1,2 +1,4 @@
1
1
  import { DefaultBuilderPlugin } from '@modern-js/builder-shared';
2
+ /** Expect to match path just like "./node_modules/react-router/" */
3
+ export declare const createDependenciesRegExp: (...dependencies: string[]) => RegExp;
2
4
  export declare function builderPluginSplitChunks(): DefaultBuilderPlugin;
@@ -26,7 +26,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
26
26
  return (mod && mod.__esModule) ? mod : { "default": mod };
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.builderPluginSplitChunks = void 0;
29
+ exports.builderPluginSplitChunks = exports.createDependenciesRegExp = void 0;
30
30
  const assert_1 = __importDefault(require("assert"));
31
31
  const builder_shared_1 = require("@modern-js/builder-shared");
32
32
  function getUserDefinedCacheGroups(forceSplitting) {
@@ -43,28 +43,31 @@ function getUserDefinedCacheGroups(forceSplitting) {
43
43
  });
44
44
  return cacheGroups;
45
45
  }
46
+ /** Expect to match path just like "./node_modules/react-router/" */
47
+ const createDependenciesRegExp = (...dependencies) => new RegExp(`[\\\\/]node_modules[\\\\/](${dependencies.join('|')})[\\\\/]`);
48
+ exports.createDependenciesRegExp = createDependenciesRegExp;
46
49
  async function splitByExperience(ctx) {
47
50
  const { isPackageInstalled } = await Promise.resolve().then(() => __importStar(require('@modern-js/utils')));
48
51
  const { override, polyfill, rootPath, defaultConfig, userDefinedCacheGroups, } = ctx;
49
52
  const experienceCacheGroup = {};
50
53
  const packageRegExps = {
51
- react: /[\\/]react|react-dom[\\/]/,
52
- router: /[\\/]react-router|react-router-dom|history[\\/]/,
53
- lodash: /[\\/]lodash|lodash-es[\\/]/,
54
+ react: (0, exports.createDependenciesRegExp)('react', 'react-dom'),
55
+ router: (0, exports.createDependenciesRegExp)('react-router', 'react-router-dom', 'history'),
56
+ lodash: (0, exports.createDependenciesRegExp)('lodash', 'lodash-es'),
54
57
  };
55
58
  // Detect if the package is installed in current project
56
59
  // If installed, add the package to cache group
57
60
  if (isPackageInstalled('antd', rootPath)) {
58
- packageRegExps.antd = /[\\/]antd[\\/]/;
61
+ packageRegExps.antd = (0, exports.createDependenciesRegExp)('antd');
59
62
  }
60
63
  if (isPackageInstalled('@arco-design/web-react', rootPath)) {
61
- packageRegExps.arco = /[\\/]arco-design[\\/]/;
64
+ packageRegExps.arco = (0, exports.createDependenciesRegExp)('arco-design');
62
65
  }
63
66
  if (isPackageInstalled('@douyinfe/semi-ui', rootPath)) {
64
- packageRegExps.semi = /[\\/]semi-ui[\\/]/;
67
+ packageRegExps.semi = (0, exports.createDependenciesRegExp)('semi-ui');
65
68
  }
66
69
  if (polyfill === 'entry' || polyfill === 'usage') {
67
- packageRegExps.polyfill = /[\\/]core-js|@babel\/runtime[\\/]/;
70
+ packageRegExps.polyfill = (0, exports.createDependenciesRegExp)('core-js', '@babel/runtime');
68
71
  }
69
72
  Object.entries(packageRegExps).forEach(([name, test]) => {
70
73
  const key = `lib-${name}`;
package/package.json CHANGED
@@ -2,8 +2,8 @@
2
2
  "name": "@modern-js/builder",
3
3
  "description": "Builder of modern.js.",
4
4
  "homepage": "https://modernjs.dev",
5
- "bugs": "https://github.com/modern-js-dev/modern.js/issues",
6
- "repository": "modern-js-dev/modern.js",
5
+ "bugs": "https://github.com/web-infra-dev/modern.js/issues",
6
+ "repository": "web-infra-dev/modern.js",
7
7
  "license": "MIT",
8
8
  "keywords": [
9
9
  "react",
@@ -14,7 +14,7 @@
14
14
  "engines": {
15
15
  "node": ">=14.0.0"
16
16
  },
17
- "version": "2.6.0",
17
+ "version": "2.8.0",
18
18
  "jsnext:source": "./src/index.ts",
19
19
  "types": "./dist/index.d.ts",
20
20
  "main": "./dist/index.js",
@@ -27,8 +27,8 @@
27
27
  },
28
28
  "dependencies": {
29
29
  "@svgr/webpack": "6.5.1",
30
- "@modern-js/builder-shared": "2.6.0",
31
- "@modern-js/utils": "2.6.0"
30
+ "@modern-js/builder-shared": "2.8.0",
31
+ "@modern-js/utils": "2.8.0"
32
32
  },
33
33
  "devDependencies": {
34
34
  "@babel/core": "7.18.0",
@@ -36,7 +36,7 @@
36
36
  "@types/babel__preset-env": "^7.9.2",
37
37
  "@types/node": "^14",
38
38
  "typescript": "^4",
39
- "@scripts/vitest-config": "2.6.0"
39
+ "@scripts/vitest-config": "2.8.0"
40
40
  },
41
41
  "publishConfig": {
42
42
  "registry": "https://registry.npmjs.org/",