@modern-js/builder 2.34.0 → 2.35.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/dist/plugins/arco.js +2 -3
- package/dist/plugins/fileSize.js +7 -3
- package/dist/plugins/html.js +1 -2
- package/dist/plugins/nodeAddons.js +1 -2
- package/dist/plugins/sourceBuild.d.ts +3 -5
- package/dist/plugins/sourceBuild.js +25 -13
- package/dist/plugins/splitChunks.js +1 -1
- package/dist/plugins/tsChecker.js +1 -2
- package/package.json +9 -9
package/dist/plugins/arco.js
CHANGED
|
@@ -16,14 +16,13 @@ const builderPluginArco = () => ({
|
|
|
16
16
|
const ARCO_NAME = "@arco-design/web-react";
|
|
17
17
|
const ARCO_ICON = `${ARCO_NAME}/icon`;
|
|
18
18
|
api.modifyBuilderConfig((builderConfig) => {
|
|
19
|
-
var _transformImport, _transformImport1;
|
|
20
19
|
var _builderConfig;
|
|
21
20
|
const { transformImport = [] } = builderConfig.source || {};
|
|
22
21
|
if (transformImport === false || !(0, _utils.isPackageInstalled)(ARCO_NAME, api.context.rootPath)) {
|
|
23
22
|
return;
|
|
24
23
|
}
|
|
25
24
|
const isUseSSR = (0, _antd.useSSR)(api.context.target);
|
|
26
|
-
if (!(
|
|
25
|
+
if (!(transformImport === null || transformImport === void 0 ? void 0 : transformImport.some((item) => item.libraryName === ARCO_NAME))) {
|
|
27
26
|
transformImport.push({
|
|
28
27
|
libraryName: ARCO_NAME,
|
|
29
28
|
libraryDirectory: isUseSSR ? "lib" : "es",
|
|
@@ -31,7 +30,7 @@ const builderPluginArco = () => ({
|
|
|
31
30
|
style: true
|
|
32
31
|
});
|
|
33
32
|
}
|
|
34
|
-
if (!(
|
|
33
|
+
if (!(transformImport === null || transformImport === void 0 ? void 0 : transformImport.some((item) => item.libraryName === ARCO_ICON))) {
|
|
35
34
|
transformImport.push({
|
|
36
35
|
libraryName: ARCO_ICON,
|
|
37
36
|
libraryDirectory: isUseSSR ? "react-icon-cjs" : "react-icon",
|
package/dist/plugins/fileSize.js
CHANGED
|
@@ -62,8 +62,12 @@ async function printFileSizes(stats, distPath) {
|
|
|
62
62
|
folder: _path.default.join(_path.default.basename(distPath), _path.default.dirname(asset.name)),
|
|
63
63
|
name: _path.default.basename(asset.name),
|
|
64
64
|
gzippedSize,
|
|
65
|
-
sizeLabel: filesize(size
|
|
66
|
-
|
|
65
|
+
sizeLabel: filesize(size, {
|
|
66
|
+
round: 1
|
|
67
|
+
}),
|
|
68
|
+
gzipSizeLabel: getAssetColor(gzippedSize)(filesize(gzippedSize, {
|
|
69
|
+
round: 1
|
|
70
|
+
}))
|
|
67
71
|
};
|
|
68
72
|
};
|
|
69
73
|
const multiStats = "stats" in stats ? stats.stats : [
|
|
@@ -89,7 +93,7 @@ async function printFileSizes(stats, distPath) {
|
|
|
89
93
|
assets.sort((a, b) => b.size - a.size);
|
|
90
94
|
const longestLabelLength = Math.max(...assets.map((a) => stripAnsi(a.sizeLabel).length));
|
|
91
95
|
const longestFileLength = Math.max(...assets.map((a) => stripAnsi(a.folder + _path.default.sep + a.name).length));
|
|
92
|
-
_buildershared.logger.info(`
|
|
96
|
+
_buildershared.logger.info(`Production file sizes:
|
|
93
97
|
`);
|
|
94
98
|
printHeader(longestFileLength, longestLabelLength);
|
|
95
99
|
let totalSize = 0;
|
package/dist/plugins/html.js
CHANGED
|
@@ -23,12 +23,11 @@ const _path = /* @__PURE__ */ _interop_require_default._(require("path"));
|
|
|
23
23
|
const _buildershared = require("@modern-js/builder-shared");
|
|
24
24
|
const _lodash = /* @__PURE__ */ _interop_require_default._(require("@modern-js/utils/lodash"));
|
|
25
25
|
async function getTemplateParameters(entryName, config, assetPrefix) {
|
|
26
|
-
var _templateParametersByEntries;
|
|
27
26
|
const { applyOptionsChain } = await Promise.resolve().then(() => /* @__PURE__ */ _interop_require_wildcard._(require("@modern-js/utils")));
|
|
28
27
|
const { mountId, templateParameters, templateParametersByEntries } = config.html;
|
|
29
28
|
const meta = await (0, _buildershared.getMetaTags)(entryName, config);
|
|
30
29
|
const title = (0, _buildershared.getTitle)(entryName, config);
|
|
31
|
-
const templateParams = (
|
|
30
|
+
const templateParams = (templateParametersByEntries === null || templateParametersByEntries === void 0 ? void 0 : templateParametersByEntries[entryName]) || templateParameters;
|
|
32
31
|
const baseParameters = {
|
|
33
32
|
meta,
|
|
34
33
|
title,
|
|
@@ -26,10 +26,9 @@ const builderPluginNodeAddons = () => ({
|
|
|
26
26
|
throw new Error(`Failed to compile Node.js addons, couldn't find the package.json of ${chalk.yellow(resource)}.`);
|
|
27
27
|
}
|
|
28
28
|
const getFilename = (resource2, pkgName2) => {
|
|
29
|
-
var _match;
|
|
30
29
|
const reg = new RegExp(`node_modules/${pkgName2}/(.+)`);
|
|
31
30
|
const match = resource2.match(reg);
|
|
32
|
-
const filename =
|
|
31
|
+
const filename = match === null || match === void 0 ? void 0 : match[1];
|
|
33
32
|
if (!filename) {
|
|
34
33
|
return "[name].[ext]";
|
|
35
34
|
}
|
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type BuilderPlugin } from '@modern-js/builder-shared';
|
|
2
2
|
import type { BuilderPluginAPI as WebpackBuilderPluginAPI } from '@modern-js/builder-webpack-provider';
|
|
3
3
|
import type { BuilderPluginAPI as RspackBuilderPluginAPI } from '@modern-js/builder-rspack-provider';
|
|
4
|
-
import { type ExtraMonorepoStrategies } from '@modern-js/monorepo-utils';
|
|
4
|
+
import { type Project, type ExtraMonorepoStrategies } from '@modern-js/monorepo-utils';
|
|
5
5
|
export declare const pluginName = "builder-plugin-source-build";
|
|
6
6
|
export declare const getSourceInclude: (options: {
|
|
7
|
-
|
|
8
|
-
findMonorepoStartPath: string;
|
|
7
|
+
projects: Project[];
|
|
9
8
|
sourceField: string;
|
|
10
|
-
extraMonorepoStrategies?: ExtraMonorepoStrategies;
|
|
11
9
|
}) => Promise<string[]>;
|
|
12
10
|
export interface PluginSourceBuildOptions {
|
|
13
11
|
projectName?: string;
|
|
@@ -20,18 +20,15 @@ _export(exports, {
|
|
|
20
20
|
return builderPluginSourceBuild;
|
|
21
21
|
}
|
|
22
22
|
});
|
|
23
|
+
const _interop_require_default = require("@swc/helpers/_/_interop_require_default");
|
|
24
|
+
const _buildershared = require("@modern-js/builder-shared");
|
|
23
25
|
const _monorepoutils = require("@modern-js/monorepo-utils");
|
|
24
26
|
const _utils = require("@modern-js/utils");
|
|
27
|
+
const _path = /* @__PURE__ */ _interop_require_default._(require("path"));
|
|
25
28
|
const log = (0, _utils.debug)("BUILDER_PLUGIN_SOURCE_BUILD");
|
|
26
29
|
const pluginName = "builder-plugin-source-build";
|
|
27
30
|
const getSourceInclude = async (options) => {
|
|
28
|
-
const {
|
|
29
|
-
const projects = await (0, _monorepoutils.getDependentProjects)(projectNameOrRootPath, {
|
|
30
|
-
cwd: findMonorepoStartPath,
|
|
31
|
-
recursive: true,
|
|
32
|
-
filter: (0, _monorepoutils.filterByField)(sourceField),
|
|
33
|
-
extraMonorepoStrategies
|
|
34
|
-
});
|
|
31
|
+
const { projects, sourceField } = options;
|
|
35
32
|
const includes = [];
|
|
36
33
|
for (const project of projects) {
|
|
37
34
|
includes.push(...project.getSourceEntryPaths({
|
|
@@ -47,19 +44,24 @@ function builderPluginSourceBuild(options) {
|
|
|
47
44
|
name: pluginName,
|
|
48
45
|
async setup(api) {
|
|
49
46
|
const projectRootPath = api.context.rootPath;
|
|
47
|
+
let projects = [];
|
|
50
48
|
if (api.context.bundlerType === "webpack") {
|
|
51
49
|
api.modifyBuilderConfig(async (config) => {
|
|
52
50
|
var _config_experiments;
|
|
53
|
-
const { sourceBuild
|
|
51
|
+
const { sourceBuild } = (_config_experiments = config.experiments) !== null && _config_experiments !== void 0 ? _config_experiments : {};
|
|
54
52
|
if (!sourceBuild) {
|
|
55
53
|
return;
|
|
56
54
|
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
55
|
+
projects = await (0, _monorepoutils.getDependentProjects)(projectName || projectRootPath, {
|
|
56
|
+
cwd: projectRootPath,
|
|
57
|
+
recursive: true,
|
|
58
|
+
filter: (0, _monorepoutils.filterByField)(sourceField),
|
|
61
59
|
extraMonorepoStrategies
|
|
62
60
|
});
|
|
61
|
+
const includes = await getSourceInclude({
|
|
62
|
+
projects,
|
|
63
|
+
sourceField
|
|
64
|
+
});
|
|
63
65
|
var _config_source;
|
|
64
66
|
config.source = (_config_source = config.source) !== null && _config_source !== void 0 ? _config_source : {};
|
|
65
67
|
var _config_source_include;
|
|
@@ -68,7 +70,7 @@ function builderPluginSourceBuild(options) {
|
|
|
68
70
|
...includes
|
|
69
71
|
];
|
|
70
72
|
});
|
|
71
|
-
api.
|
|
73
|
+
api.modifyWebpackChain((chain, { CHAIN_ID }) => {
|
|
72
74
|
const { experiments: { sourceBuild }, tools: { tsLoader } } = api.getNormalizedConfig();
|
|
73
75
|
if (!sourceBuild) {
|
|
74
76
|
return;
|
|
@@ -84,6 +86,16 @@ function builderPluginSourceBuild(options) {
|
|
|
84
86
|
sourceField
|
|
85
87
|
]
|
|
86
88
|
});
|
|
89
|
+
const { TS_CONFIG_PATHS } = CHAIN_ID.RESOLVE_PLUGIN;
|
|
90
|
+
if (chain.resolve.plugins.has(TS_CONFIG_PATHS)) {
|
|
91
|
+
chain.resolve.plugin(TS_CONFIG_PATHS).tap((options2) => {
|
|
92
|
+
const references = projects.map((project) => _path.default.join(project.dir, _buildershared.TS_CONFIG_FILE)).filter((filePath) => _utils.fs.existsSync(filePath)).map((filePath) => _path.default.relative(projectRootPath, filePath));
|
|
93
|
+
return options2.map((option) => ({
|
|
94
|
+
...option,
|
|
95
|
+
references
|
|
96
|
+
}));
|
|
97
|
+
});
|
|
98
|
+
}
|
|
87
99
|
});
|
|
88
100
|
}
|
|
89
101
|
}
|
|
@@ -49,7 +49,7 @@ async function splitByExperience(ctx) {
|
|
|
49
49
|
const { override, polyfill, rootPath, defaultConfig, userDefinedCacheGroups } = ctx;
|
|
50
50
|
const experienceCacheGroup = {};
|
|
51
51
|
const packageRegExps = {
|
|
52
|
-
react: createDependenciesRegExp("react", "react-dom"),
|
|
52
|
+
react: createDependenciesRegExp("react", "react-dom", "scheduler"),
|
|
53
53
|
router: createDependenciesRegExp("react-router", "react-router-dom", "@remix-run/router", "history"),
|
|
54
54
|
lodash: createDependenciesRegExp("lodash", "lodash-es"),
|
|
55
55
|
axios: createDependenciesRegExp("axios", /axios-.+/)
|
|
@@ -15,7 +15,6 @@ const builderPluginTsChecker = () => {
|
|
|
15
15
|
name: "builder-plugin-ts-checker",
|
|
16
16
|
setup(api) {
|
|
17
17
|
api.modifyBundlerChain(async (chain, { target }) => {
|
|
18
|
-
var _experiments;
|
|
19
18
|
const config = api.getNormalizedConfig();
|
|
20
19
|
if (config.output.disableTsChecker || !api.context.tsconfigPath) {
|
|
21
20
|
return;
|
|
@@ -38,7 +37,7 @@ const builderPluginTsChecker = () => {
|
|
|
38
37
|
}
|
|
39
38
|
const { experiments } = api.getNormalizedConfig();
|
|
40
39
|
var _experiments_sourceBuild;
|
|
41
|
-
const enableSourceBuild = (_experiments_sourceBuild =
|
|
40
|
+
const enableSourceBuild = (_experiments_sourceBuild = experiments === null || experiments === void 0 ? void 0 : experiments.sourceBuild) !== null && _experiments_sourceBuild !== void 0 ? _experiments_sourceBuild : false;
|
|
42
41
|
const tsCheckerOptions = applyOptionsChain({
|
|
43
42
|
typescript: {
|
|
44
43
|
// avoid OOM issue
|
package/package.json
CHANGED
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"engines": {
|
|
19
19
|
"node": ">=14.0.0"
|
|
20
20
|
},
|
|
21
|
-
"version": "2.
|
|
21
|
+
"version": "2.35.1",
|
|
22
22
|
"jsnext:source": "./src/index.ts",
|
|
23
23
|
"types": "./dist/index.d.ts",
|
|
24
24
|
"main": "./dist/index.js",
|
|
@@ -45,19 +45,19 @@
|
|
|
45
45
|
"dependencies": {
|
|
46
46
|
"@svgr/webpack": "8.0.1",
|
|
47
47
|
"@swc/helpers": "0.5.1",
|
|
48
|
-
"@modern-js/
|
|
49
|
-
"@modern-js/
|
|
50
|
-
"@modern-js/
|
|
51
|
-
"@modern-js/
|
|
48
|
+
"@modern-js/builder-shared": "2.35.1",
|
|
49
|
+
"@modern-js/monorepo-utils": "2.35.1",
|
|
50
|
+
"@modern-js/utils": "2.35.1",
|
|
51
|
+
"@modern-js/node-bundle-require": "2.35.1"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
54
|
"@types/babel__core": "^7.20.0",
|
|
55
55
|
"@types/node": "^14",
|
|
56
56
|
"typescript": "^5",
|
|
57
|
-
"@modern-js/builder-webpack-provider": "2.
|
|
58
|
-
"@modern-js/builder-rspack-provider": "2.
|
|
59
|
-
"@scripts/
|
|
60
|
-
"@scripts/
|
|
57
|
+
"@modern-js/builder-webpack-provider": "2.35.1",
|
|
58
|
+
"@modern-js/builder-rspack-provider": "2.35.1",
|
|
59
|
+
"@scripts/vitest-config": "2.35.1",
|
|
60
|
+
"@scripts/build": "2.35.1"
|
|
61
61
|
},
|
|
62
62
|
"publishConfig": {
|
|
63
63
|
"registry": "https://registry.npmjs.org/",
|