@modern-js/builder 2.21.1 → 2.22.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 +52 -0
- package/dist/createBuilder.js +2 -1
- package/dist/plugins/antd.d.ts +3 -2
- package/dist/plugins/antd.js +4 -3
- package/dist/plugins/arco.d.ts +2 -0
- package/dist/plugins/arco.js +38 -0
- package/dist/plugins/html.js +5 -3
- package/dist/plugins/index.js +3 -1
- package/dist/plugins/rem.d.ts +2 -0
- package/dist/plugins/rem.js +106 -0
- package/dist/plugins/startUrl.js +2 -1
- package/dist/plugins/target.js +8 -4
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,57 @@
|
|
|
1
1
|
# @modern-js/builder
|
|
2
2
|
|
|
3
|
+
## 2.22.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- a470c04: chore(builder): reuse rem plugin between rspack and webpack provider
|
|
8
|
+
|
|
9
|
+
chore(builder): 在 rspack 和 webpack provider 间复用 rem 插件
|
|
10
|
+
|
|
11
|
+
- bd4b150: feat(builder): add builder.serve method
|
|
12
|
+
|
|
13
|
+
feat(builder): 新增 builder.serve 方法
|
|
14
|
+
|
|
15
|
+
- d4045ed: fix(builder): print https URLs when devServer.https is true
|
|
16
|
+
|
|
17
|
+
fix(builder): 当 devServer.https 为 true 时,输出 https 的 URLs
|
|
18
|
+
|
|
19
|
+
- Updated dependencies [e2848a2]
|
|
20
|
+
- Updated dependencies [a470c04]
|
|
21
|
+
- Updated dependencies [95ffa6b]
|
|
22
|
+
- Updated dependencies [12d54ae]
|
|
23
|
+
- Updated dependencies [bd4b150]
|
|
24
|
+
- Updated dependencies [dd36311]
|
|
25
|
+
- Updated dependencies [d4045ed]
|
|
26
|
+
- Updated dependencies [8bd9981]
|
|
27
|
+
- Updated dependencies [1f02cd2]
|
|
28
|
+
- Updated dependencies [cfcf003]
|
|
29
|
+
- Updated dependencies [15181be]
|
|
30
|
+
- @modern-js/utils@2.22.1
|
|
31
|
+
- @modern-js/builder-shared@2.22.1
|
|
32
|
+
|
|
33
|
+
## 2.22.0
|
|
34
|
+
|
|
35
|
+
### Patch Changes
|
|
36
|
+
|
|
37
|
+
- 9c3c231: feat(deps): bump @svgr/webpack from v6 to v8
|
|
38
|
+
|
|
39
|
+
feat(deps): 将 @svgr/webpack 从 v6 升级到 v8
|
|
40
|
+
|
|
41
|
+
- 850cde6: feat(builder): add arco config to transformImport by default
|
|
42
|
+
|
|
43
|
+
feat(builder): 默认增加 arco 的 transformImport 配置
|
|
44
|
+
|
|
45
|
+
- ae3fcc2: fix(builder): failed to configure browserslist when target is web-worker
|
|
46
|
+
|
|
47
|
+
fix(builder): 修复 target 为 web-worker 时无法配置 browserslist 的问题
|
|
48
|
+
|
|
49
|
+
- Updated dependencies [3d48836]
|
|
50
|
+
- Updated dependencies [5050e8e]
|
|
51
|
+
- Updated dependencies [850cde6]
|
|
52
|
+
- @modern-js/builder-shared@2.22.0
|
|
53
|
+
- @modern-js/utils@2.22.0
|
|
54
|
+
|
|
3
55
|
## 2.21.1
|
|
4
56
|
|
|
5
57
|
### Patch Changes
|
package/dist/createBuilder.js
CHANGED
|
@@ -6,7 +6,7 @@ const plugins_1 = require("./plugins");
|
|
|
6
6
|
async function createBuilder(provider, options) {
|
|
7
7
|
const builderOptions = (0, builder_shared_1.applyDefaultBuilderOptions)(options);
|
|
8
8
|
const pluginStore = (0, builder_shared_1.createPluginStore)();
|
|
9
|
-
const { build, pluginAPI, publicContext, initConfigs, inspectConfig, createCompiler, startDevServer, applyDefaultPlugins, } = await provider({
|
|
9
|
+
const { build, serve, pluginAPI, publicContext, initConfigs, inspectConfig, createCompiler, startDevServer, applyDefaultPlugins, } = await provider({
|
|
10
10
|
pluginStore,
|
|
11
11
|
builderOptions,
|
|
12
12
|
plugins: plugins_1.plugins,
|
|
@@ -29,6 +29,7 @@ async function createBuilder(provider, options) {
|
|
|
29
29
|
'getBuilderConfig',
|
|
30
30
|
'getNormalizedConfig',
|
|
31
31
|
]),
|
|
32
|
+
serve,
|
|
32
33
|
build,
|
|
33
34
|
createCompiler,
|
|
34
35
|
initConfigs,
|
package/dist/plugins/antd.d.ts
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
import type { DefaultBuilderPlugin } from '@modern-js/builder-shared';
|
|
2
|
-
export declare const
|
|
1
|
+
import type { BuilderTarget, DefaultBuilderPlugin } from '@modern-js/builder-shared';
|
|
2
|
+
export declare const builderPluginAntd: () => DefaultBuilderPlugin;
|
|
3
|
+
export declare function useSSR(target: BuilderTarget | BuilderTarget[]): boolean;
|
package/dist/plugins/antd.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.useSSR = exports.builderPluginAntd = void 0;
|
|
4
4
|
const utils_1 = require("@modern-js/utils");
|
|
5
|
-
const
|
|
5
|
+
const builderPluginAntd = () => ({
|
|
6
6
|
name: `builder-plugin-antd`,
|
|
7
7
|
setup(api) {
|
|
8
8
|
api.modifyBuilderConfig(builderConfig => {
|
|
@@ -29,7 +29,8 @@ const builderAntdPlugin = () => ({
|
|
|
29
29
|
});
|
|
30
30
|
},
|
|
31
31
|
});
|
|
32
|
-
exports.
|
|
32
|
+
exports.builderPluginAntd = builderPluginAntd;
|
|
33
33
|
function useSSR(target) {
|
|
34
34
|
return (Array.isArray(target) ? target : [target]).some(item => ['node', 'service-worker'].includes(item));
|
|
35
35
|
}
|
|
36
|
+
exports.useSSR = useSSR;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.builderPluginArco = void 0;
|
|
4
|
+
const utils_1 = require("@modern-js/utils");
|
|
5
|
+
const antd_1 = require("./antd");
|
|
6
|
+
const builderPluginArco = () => ({
|
|
7
|
+
name: `builder-plugin-arco`,
|
|
8
|
+
setup(api) {
|
|
9
|
+
const ARCO_NAME = '@arco-design/web-react';
|
|
10
|
+
const ARCO_ICON = `${ARCO_NAME}/icon`;
|
|
11
|
+
api.modifyBuilderConfig(builderConfig => {
|
|
12
|
+
const { transformImport = [] } = builderConfig.source || {};
|
|
13
|
+
if (transformImport === false ||
|
|
14
|
+
!(0, utils_1.isPackageInstalled)(ARCO_NAME, api.context.rootPath)) {
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
const isUseSSR = (0, antd_1.useSSR)(api.context.target);
|
|
18
|
+
if (!(transformImport === null || transformImport === void 0 ? void 0 : transformImport.some(item => item.libraryName === ARCO_NAME))) {
|
|
19
|
+
transformImport.push({
|
|
20
|
+
libraryName: ARCO_NAME,
|
|
21
|
+
libraryDirectory: isUseSSR ? 'lib' : 'es',
|
|
22
|
+
camelToDashComponentName: false,
|
|
23
|
+
style: true,
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
if (!(transformImport === null || transformImport === void 0 ? void 0 : transformImport.some(item => item.libraryName === ARCO_ICON))) {
|
|
27
|
+
transformImport.push({
|
|
28
|
+
libraryName: ARCO_ICON,
|
|
29
|
+
libraryDirectory: isUseSSR ? 'react-icon-cjs' : 'react-icon',
|
|
30
|
+
camelToDashComponentName: false,
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
builderConfig.source || (builderConfig.source = {});
|
|
34
|
+
builderConfig.source.transformImport = transformImport;
|
|
35
|
+
});
|
|
36
|
+
},
|
|
37
|
+
});
|
|
38
|
+
exports.builderPluginArco = builderPluginArco;
|
package/dist/plugins/html.js
CHANGED
|
@@ -206,15 +206,17 @@ const builderPluginHtml = () => ({
|
|
|
206
206
|
}
|
|
207
207
|
}
|
|
208
208
|
});
|
|
209
|
-
|
|
209
|
+
const emitRouteJson = async () => {
|
|
210
210
|
const { fs, ROUTE_SPEC_FILE } = await Promise.resolve().then(() => __importStar(require('@modern-js/utils')));
|
|
211
211
|
const routeFilePath = path_1.default.join(api.context.distPath, ROUTE_SPEC_FILE);
|
|
212
|
-
// generate a basic route.json for modern.js
|
|
212
|
+
// generate a basic route.json for modern.js server
|
|
213
213
|
// if the framework has already generate a route.json, do nothing
|
|
214
214
|
if (!(await (0, builder_shared_1.isFileExists)(routeFilePath)) && routesInfo.length) {
|
|
215
215
|
await fs.outputFile(routeFilePath, JSON.stringify({ routes: routesInfo }, null, 2));
|
|
216
216
|
}
|
|
217
|
-
}
|
|
217
|
+
};
|
|
218
|
+
api.onBeforeBuild(emitRouteJson);
|
|
219
|
+
api.onBeforeStartDevServer(emitRouteJson);
|
|
218
220
|
(0, exports.applyInjectTags)(api);
|
|
219
221
|
},
|
|
220
222
|
});
|
package/dist/plugins/index.js
CHANGED
|
@@ -44,7 +44,9 @@ exports.plugins = {
|
|
|
44
44
|
image: () => Promise.resolve().then(() => __importStar(require('./asset'))).then(m => m.builderAssetPlugin('image', builder_shared_1.IMAGE_EXTENSIONS)),
|
|
45
45
|
media: () => Promise.resolve().then(() => __importStar(require('./asset'))).then(m => m.builderAssetPlugin('media', builder_shared_1.MEDIA_EXTENSIONS)),
|
|
46
46
|
assetsRetry: () => Promise.resolve().then(() => __importStar(require('./assetsRetry'))).then(m => m.builderPluginAssetsRetry()),
|
|
47
|
-
antd: () => Promise.resolve().then(() => __importStar(require('./antd'))).then(m => m.
|
|
47
|
+
antd: () => Promise.resolve().then(() => __importStar(require('./antd'))).then(m => m.builderPluginAntd()),
|
|
48
|
+
arco: () => Promise.resolve().then(() => __importStar(require('./arco'))).then(m => m.builderPluginArco()),
|
|
48
49
|
tsChecker: () => Promise.resolve().then(() => __importStar(require('./tsChecker'))).then(m => m.builderPluginTsChecker()),
|
|
49
50
|
checkSyntax: () => Promise.resolve().then(() => __importStar(require('./checkSyntax'))).then(m => m.builderPluginCheckSyntax()),
|
|
51
|
+
rem: () => Promise.resolve().then(() => __importStar(require('./rem'))).then(m => m.builderPluginRem()),
|
|
50
52
|
};
|
|
@@ -0,0 +1,106 @@
|
|
|
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
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.builderPluginRem = void 0;
|
|
30
|
+
const lodash_1 = __importDefault(require("@modern-js/utils/lodash"));
|
|
31
|
+
const builder_shared_1 = require("@modern-js/builder-shared");
|
|
32
|
+
const defaultOptions = {
|
|
33
|
+
enableRuntime: true,
|
|
34
|
+
rootFontSize: 50,
|
|
35
|
+
};
|
|
36
|
+
const builderPluginRem = () => ({
|
|
37
|
+
name: 'builder-plugin-rem',
|
|
38
|
+
pre: [
|
|
39
|
+
'builder-plugin-css',
|
|
40
|
+
'builder-plugin-less',
|
|
41
|
+
'builder-plugin-sass',
|
|
42
|
+
'builder-plugin-stylus',
|
|
43
|
+
],
|
|
44
|
+
setup(api) {
|
|
45
|
+
api.modifyBundlerChain(async (chain, { CHAIN_ID, isServer, isWebWorker, HtmlPlugin }) => {
|
|
46
|
+
const config = api.getNormalizedConfig();
|
|
47
|
+
const { output: { convertToRem }, } = config;
|
|
48
|
+
if (!convertToRem || isServer || isWebWorker) {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
const userOptions = {
|
|
52
|
+
...defaultOptions,
|
|
53
|
+
...(typeof convertToRem === 'boolean' ? {} : convertToRem),
|
|
54
|
+
};
|
|
55
|
+
// handle css
|
|
56
|
+
const { default: PxToRemPlugin } = (await Promise.resolve(`${(0, builder_shared_1.getSharedPkgCompiledPath)('postcss-pxtorem')}`).then(s => __importStar(require(s))));
|
|
57
|
+
const applyRules = [
|
|
58
|
+
CHAIN_ID.RULE.CSS,
|
|
59
|
+
CHAIN_ID.RULE.LESS,
|
|
60
|
+
CHAIN_ID.RULE.SASS,
|
|
61
|
+
CHAIN_ID.RULE.STYLUS,
|
|
62
|
+
];
|
|
63
|
+
const getPxToRemPlugin = () => PxToRemPlugin({
|
|
64
|
+
rootValue: userOptions.rootFontSize,
|
|
65
|
+
unitPrecision: 5,
|
|
66
|
+
propList: ['*'],
|
|
67
|
+
...lodash_1.default.cloneDeep(userOptions.pxtorem || {}),
|
|
68
|
+
});
|
|
69
|
+
// Deep copy options to prevent unexpected behavior.
|
|
70
|
+
applyRules.forEach(name => {
|
|
71
|
+
chain.module.rules.has(name) &&
|
|
72
|
+
chain.module
|
|
73
|
+
.rule(name)
|
|
74
|
+
.use(CHAIN_ID.USE.POSTCSS)
|
|
75
|
+
.tap((options = {}) => {
|
|
76
|
+
var _a;
|
|
77
|
+
return ({
|
|
78
|
+
...options,
|
|
79
|
+
postcssOptions: {
|
|
80
|
+
...(options.postcssOptions || {}),
|
|
81
|
+
plugins: [
|
|
82
|
+
...(((_a = options.postcssOptions) === null || _a === void 0 ? void 0 : _a.plugins) || []),
|
|
83
|
+
getPxToRemPlugin(),
|
|
84
|
+
],
|
|
85
|
+
},
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
});
|
|
89
|
+
// handle runtime (html)
|
|
90
|
+
if (!userOptions.enableRuntime) {
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
const entries = Object.keys(chain.entryPoints.entries() || {});
|
|
94
|
+
const distDir = (0, builder_shared_1.getDistPath)(config.output, 'js');
|
|
95
|
+
chain
|
|
96
|
+
.plugin(CHAIN_ID.PLUGIN.AUTO_SET_ROOT_SIZE)
|
|
97
|
+
.use(builder_shared_1.AutoSetRootFontSizePlugin, [
|
|
98
|
+
userOptions,
|
|
99
|
+
entries,
|
|
100
|
+
HtmlPlugin,
|
|
101
|
+
distDir,
|
|
102
|
+
]);
|
|
103
|
+
});
|
|
104
|
+
},
|
|
105
|
+
});
|
|
106
|
+
exports.builderPluginRem = builderPluginRem;
|
package/dist/plugins/startUrl.js
CHANGED
|
@@ -44,7 +44,8 @@ function builderPluginStartUrl() {
|
|
|
44
44
|
return;
|
|
45
45
|
}
|
|
46
46
|
const config = api.getNormalizedConfig();
|
|
47
|
-
const {
|
|
47
|
+
const { startUrl, beforeStartUrl } = config.dev;
|
|
48
|
+
const { https } = api.context.devServer || {};
|
|
48
49
|
if (!startUrl) {
|
|
49
50
|
return;
|
|
50
51
|
}
|
package/dist/plugins/target.js
CHANGED
|
@@ -14,16 +14,20 @@ const builderPluginTarget = () => ({
|
|
|
14
14
|
chain.target('webworker');
|
|
15
15
|
return;
|
|
16
16
|
}
|
|
17
|
+
// browserslist is not supported when target is web-worker
|
|
18
|
+
if (target === 'web-worker') {
|
|
19
|
+
chain.target(['webworker', 'es5']);
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
17
22
|
const browserslist = await (0, builder_shared_1.getBrowserslist)(api.context.rootPath);
|
|
18
|
-
const basicTarget = target === 'web-worker' ? 'webworker' : 'web';
|
|
19
23
|
if (browserslist) {
|
|
20
|
-
chain.merge({ target: [
|
|
24
|
+
chain.merge({ target: ['web', 'browserslist'] });
|
|
21
25
|
}
|
|
22
26
|
else if (target === 'modern-web') {
|
|
23
|
-
chain.merge({ target: [
|
|
27
|
+
chain.merge({ target: ['web', 'es2015'] });
|
|
24
28
|
}
|
|
25
29
|
else {
|
|
26
|
-
chain.merge({ target: [
|
|
30
|
+
chain.merge({ target: ['web', 'es5'] });
|
|
27
31
|
}
|
|
28
32
|
});
|
|
29
33
|
},
|
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.22.1",
|
|
22
22
|
"jsnext:source": "./src/index.ts",
|
|
23
23
|
"types": "./dist/index.d.ts",
|
|
24
24
|
"main": "./dist/index.js",
|
|
@@ -30,15 +30,15 @@
|
|
|
30
30
|
}
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@svgr/webpack": "
|
|
34
|
-
"@modern-js/builder-shared": "2.
|
|
35
|
-
"@modern-js/utils": "2.
|
|
33
|
+
"@svgr/webpack": "8.0.1",
|
|
34
|
+
"@modern-js/builder-shared": "2.22.1",
|
|
35
|
+
"@modern-js/utils": "2.22.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.
|
|
41
|
+
"@scripts/vitest-config": "2.22.1"
|
|
42
42
|
},
|
|
43
43
|
"publishConfig": {
|
|
44
44
|
"registry": "https://registry.npmjs.org/",
|