@modern-js/builder 2.27.0 → 2.28.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 +30 -0
- package/dist/plugins/antd.js +28 -30
- package/dist/plugins/arco.js +33 -34
- package/dist/plugins/checkSyntax.js +1 -1
- package/dist/plugins/html.js +2 -1
- package/dist/plugins/index.js +1 -0
- package/dist/plugins/nodeAddons.d.ts +2 -0
- package/dist/plugins/nodeAddons.js +48 -0
- package/dist/plugins/rem.js +61 -63
- package/dist/plugins/sourceBuild.d.ts +0 -6
- package/dist/plugins/sourceBuild.js +7 -53
- package/dist/plugins/tsChecker.js +11 -1
- package/package.json +8 -8
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,35 @@
|
|
|
1
1
|
# @modern-js/builder
|
|
2
2
|
|
|
3
|
+
## 2.28.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 7d966a1: feat(builder): source code build feature support project reference by adding tsCheck configuration
|
|
8
|
+
feat(builder): 源码构建增加 tsCheck 配置支持 project reference 的情况
|
|
9
|
+
|
|
10
|
+
### Patch Changes
|
|
11
|
+
|
|
12
|
+
- fb93353: fix(builder): support source code build when ts-loader enable
|
|
13
|
+
fix(builder): 在 ts-loader 开启的时候支持源码构建
|
|
14
|
+
- 362416f: feat(builder): support import Node.js addons when target is node
|
|
15
|
+
|
|
16
|
+
feat(builder): 支持在 target 为 node 时引用 Node.js addons
|
|
17
|
+
|
|
18
|
+
- 820bfe9: feat(builder): add checkSyntax.ecmaVersion option
|
|
19
|
+
|
|
20
|
+
feat(builder): 新增 checkSyntax.ecmaVersion 选项
|
|
21
|
+
|
|
22
|
+
- Updated dependencies [6400d98]
|
|
23
|
+
- Updated dependencies [362416f]
|
|
24
|
+
- Updated dependencies [aa0c0c3]
|
|
25
|
+
- Updated dependencies [9301e46]
|
|
26
|
+
- Updated dependencies [00b58a7]
|
|
27
|
+
- Updated dependencies [820bfe9]
|
|
28
|
+
- Updated dependencies [d3e52e4]
|
|
29
|
+
- @modern-js/builder-shared@2.28.0
|
|
30
|
+
- @modern-js/utils@2.28.0
|
|
31
|
+
- @modern-js/monorepo-utils@2.28.0
|
|
32
|
+
|
|
3
33
|
## 2.27.0
|
|
4
34
|
|
|
5
35
|
### Patch Changes
|
package/dist/plugins/antd.js
CHANGED
|
@@ -18,36 +18,34 @@ _export(exports, {
|
|
|
18
18
|
}
|
|
19
19
|
});
|
|
20
20
|
const _utils = require("@modern-js/utils");
|
|
21
|
-
const builderPluginAntd = () => {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
builderConfig.source.transformImport
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
};
|
|
50
|
-
};
|
|
21
|
+
const builderPluginAntd = () => ({
|
|
22
|
+
name: `builder-plugin-antd`,
|
|
23
|
+
setup(api) {
|
|
24
|
+
api.modifyBuilderConfig((builderConfig) => {
|
|
25
|
+
var _builderConfig_source_transformImport;
|
|
26
|
+
var _builderConfig;
|
|
27
|
+
var _source;
|
|
28
|
+
(_source = (_builderConfig = builderConfig).source) !== null && _source !== void 0 ? _source : _builderConfig.source = {};
|
|
29
|
+
if (builderConfig.source.transformImport === false || ((_builderConfig_source_transformImport = builderConfig.source.transformImport) === null || _builderConfig_source_transformImport === void 0 ? void 0 : _builderConfig_source_transformImport.some((item) => item.libraryName === "antd"))) {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
const antdMajorVersion = (0, _utils.getAntdMajorVersion)(api.context.rootPath);
|
|
33
|
+
if (antdMajorVersion && antdMajorVersion < 5) {
|
|
34
|
+
var _builderConfig1;
|
|
35
|
+
var _source1;
|
|
36
|
+
(_source1 = (_builderConfig1 = builderConfig).source) !== null && _source1 !== void 0 ? _source1 : _builderConfig1.source = {};
|
|
37
|
+
builderConfig.source.transformImport = [
|
|
38
|
+
...builderConfig.source.transformImport || [],
|
|
39
|
+
{
|
|
40
|
+
libraryName: "antd",
|
|
41
|
+
libraryDirectory: useSSR(api.context.target) ? "lib" : "es",
|
|
42
|
+
style: true
|
|
43
|
+
}
|
|
44
|
+
];
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
});
|
|
51
49
|
function useSSR(target) {
|
|
52
50
|
return (Array.isArray(target) ? target : [
|
|
53
51
|
target
|
package/dist/plugins/arco.js
CHANGED
|
@@ -10,37 +10,36 @@ Object.defineProperty(exports, "builderPluginArco", {
|
|
|
10
10
|
});
|
|
11
11
|
const _utils = require("@modern-js/utils");
|
|
12
12
|
const _antd = require("./antd");
|
|
13
|
-
const builderPluginArco = () => {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
};
|
|
13
|
+
const builderPluginArco = () => ({
|
|
14
|
+
name: `builder-plugin-arco`,
|
|
15
|
+
setup(api) {
|
|
16
|
+
const ARCO_NAME = "@arco-design/web-react";
|
|
17
|
+
const ARCO_ICON = `${ARCO_NAME}/icon`;
|
|
18
|
+
api.modifyBuilderConfig((builderConfig) => {
|
|
19
|
+
var _transformImport, _transformImport1;
|
|
20
|
+
var _builderConfig;
|
|
21
|
+
const { transformImport = [] } = builderConfig.source || {};
|
|
22
|
+
if (transformImport === false || !(0, _utils.isPackageInstalled)(ARCO_NAME, api.context.rootPath)) {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
const isUseSSR = (0, _antd.useSSR)(api.context.target);
|
|
26
|
+
if (!((_transformImport = transformImport) === null || _transformImport === void 0 ? void 0 : _transformImport.some((item) => item.libraryName === ARCO_NAME))) {
|
|
27
|
+
transformImport.push({
|
|
28
|
+
libraryName: ARCO_NAME,
|
|
29
|
+
libraryDirectory: isUseSSR ? "lib" : "es",
|
|
30
|
+
camelToDashComponentName: false,
|
|
31
|
+
style: true
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
if (!((_transformImport1 = transformImport) === null || _transformImport1 === void 0 ? void 0 : _transformImport1.some((item) => item.libraryName === ARCO_ICON))) {
|
|
35
|
+
transformImport.push({
|
|
36
|
+
libraryName: ARCO_ICON,
|
|
37
|
+
libraryDirectory: isUseSSR ? "react-icon-cjs" : "react-icon",
|
|
38
|
+
camelToDashComponentName: false
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
(_builderConfig = builderConfig).source || (_builderConfig.source = {});
|
|
42
|
+
builderConfig.source.transformImport = transformImport;
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
});
|
|
@@ -28,7 +28,7 @@ function builderPluginCheckSyntax() {
|
|
|
28
28
|
chain.plugin(CheckSyntaxPlugin.name).use(CheckSyntaxPlugin, [
|
|
29
29
|
{
|
|
30
30
|
targets,
|
|
31
|
-
|
|
31
|
+
...typeof checkSyntax === "object" ? checkSyntax : {}
|
|
32
32
|
}
|
|
33
33
|
]);
|
|
34
34
|
});
|
package/dist/plugins/html.js
CHANGED
|
@@ -23,11 +23,12 @@ 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;
|
|
26
27
|
const { applyOptionsChain } = await Promise.resolve().then(() => /* @__PURE__ */ _interop_require_wildcard._(require("@modern-js/utils")));
|
|
27
28
|
const { mountId, templateParameters, templateParametersByEntries } = config.html;
|
|
28
29
|
const meta = await (0, _buildershared.getMetaTags)(entryName, config);
|
|
29
30
|
const title = (0, _buildershared.getTitle)(entryName, config);
|
|
30
|
-
const templateParams = (templateParametersByEntries === null ||
|
|
31
|
+
const templateParams = ((_templateParametersByEntries = templateParametersByEntries) === null || _templateParametersByEntries === void 0 ? void 0 : _templateParametersByEntries[entryName]) || templateParameters;
|
|
31
32
|
const baseParameters = {
|
|
32
33
|
meta,
|
|
33
34
|
title,
|
package/dist/plugins/index.js
CHANGED
|
@@ -36,6 +36,7 @@ const plugins = {
|
|
|
36
36
|
rem: () => Promise.resolve().then(() => /* @__PURE__ */ _interop_require_wildcard._(require("./rem"))).then((m) => m.builderPluginRem()),
|
|
37
37
|
wasm: () => Promise.resolve().then(() => /* @__PURE__ */ _interop_require_wildcard._(require("./wasm"))).then((m) => m.builderPluginWasm()),
|
|
38
38
|
moment: () => Promise.resolve().then(() => /* @__PURE__ */ _interop_require_wildcard._(require("./moment"))).then((m) => m.builderPluginMoment()),
|
|
39
|
+
nodeAddons: () => Promise.resolve().then(() => /* @__PURE__ */ _interop_require_wildcard._(require("./nodeAddons"))).then((m) => m.builderPluginNodeAddons()),
|
|
39
40
|
externals: () => Promise.resolve().then(() => /* @__PURE__ */ _interop_require_wildcard._(require("./externals"))).then((m) => m.builderPluginExternals()),
|
|
40
41
|
sourceBuild: () => Promise.resolve().then(() => /* @__PURE__ */ _interop_require_wildcard._(require("./sourceBuild"))).then((m) => m.builderPluginSourceBuild({
|
|
41
42
|
sourceField: "source"
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "builderPluginNodeAddons", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return builderPluginNodeAddons;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
|
|
12
|
+
const _buildershared = require("@modern-js/builder-shared");
|
|
13
|
+
const builderPluginNodeAddons = () => ({
|
|
14
|
+
name: "builder-plugin-node-addons",
|
|
15
|
+
setup(api) {
|
|
16
|
+
api.modifyBundlerChain(async (chain, { isServer, isServiceWorker, CHAIN_ID }) => {
|
|
17
|
+
if (!isServer && !isServiceWorker) {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
const { chalk, pkgUp } = await Promise.resolve().then(() => /* @__PURE__ */ _interop_require_wildcard._(require("@modern-js/utils")));
|
|
21
|
+
const getDistName = (resource) => {
|
|
22
|
+
const pkgJSON = pkgUp.sync({
|
|
23
|
+
cwd: resource
|
|
24
|
+
});
|
|
25
|
+
if (!pkgJSON) {
|
|
26
|
+
throw new Error(`Failed to compile Node.js addons, couldn't find the package.json of ${chalk.yellow(resource)}.`);
|
|
27
|
+
}
|
|
28
|
+
const getFilename = (resource2, pkgName2) => {
|
|
29
|
+
var _match;
|
|
30
|
+
const reg = new RegExp(`node_modules/${pkgName2}/(.+)`);
|
|
31
|
+
const match = resource2.match(reg);
|
|
32
|
+
const filename = (_match = match) === null || _match === void 0 ? void 0 : _match[1];
|
|
33
|
+
if (!filename) {
|
|
34
|
+
return "[name].[ext]";
|
|
35
|
+
}
|
|
36
|
+
return `${filename}`;
|
|
37
|
+
};
|
|
38
|
+
const { name: pkgName } = require(pkgJSON);
|
|
39
|
+
const config = api.getNormalizedConfig();
|
|
40
|
+
const serverPath = (0, _buildershared.getDistPath)(config.output, "server");
|
|
41
|
+
return `${serverPath}/${getFilename(resource, pkgName)}`;
|
|
42
|
+
};
|
|
43
|
+
chain.module.rule(CHAIN_ID.RULE.NODE).test(/\.node$/).use(CHAIN_ID.USE.NODE).loader((0, _buildershared.getSharedPkgCompiledPath)("node-loader")).options({
|
|
44
|
+
name: getDistName
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
});
|
package/dist/plugins/rem.js
CHANGED
|
@@ -16,68 +16,66 @@ const defaultOptions = {
|
|
|
16
16
|
enableRuntime: true,
|
|
17
17
|
rootFontSize: 50
|
|
18
18
|
};
|
|
19
|
-
const builderPluginRem = () => {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
api.
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
postcssOptions
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
};
|
|
67
|
-
});
|
|
19
|
+
const builderPluginRem = () => ({
|
|
20
|
+
name: "builder-plugin-rem",
|
|
21
|
+
pre: [
|
|
22
|
+
"builder-plugin-css",
|
|
23
|
+
"builder-plugin-less",
|
|
24
|
+
"builder-plugin-sass",
|
|
25
|
+
"builder-plugin-stylus"
|
|
26
|
+
],
|
|
27
|
+
setup(api) {
|
|
28
|
+
api.modifyBundlerChain(async (chain, { CHAIN_ID, isServer, isWebWorker, HtmlPlugin }) => {
|
|
29
|
+
const config = api.getNormalizedConfig();
|
|
30
|
+
const { output: { convertToRem } } = config;
|
|
31
|
+
if (!convertToRem || isServer || isWebWorker) {
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
const userOptions = {
|
|
35
|
+
...defaultOptions,
|
|
36
|
+
...typeof convertToRem === "boolean" ? {} : convertToRem
|
|
37
|
+
};
|
|
38
|
+
const { default: PxToRemPlugin } = await Promise.resolve((0, _buildershared.getSharedPkgCompiledPath)("postcss-pxtorem")).then((p) => /* @__PURE__ */ _interop_require_wildcard._(require(p)));
|
|
39
|
+
const applyRules = [
|
|
40
|
+
CHAIN_ID.RULE.CSS,
|
|
41
|
+
CHAIN_ID.RULE.LESS,
|
|
42
|
+
CHAIN_ID.RULE.SASS,
|
|
43
|
+
CHAIN_ID.RULE.STYLUS
|
|
44
|
+
];
|
|
45
|
+
const getPxToRemPlugin = () => PxToRemPlugin({
|
|
46
|
+
rootValue: userOptions.rootFontSize,
|
|
47
|
+
unitPrecision: 5,
|
|
48
|
+
propList: [
|
|
49
|
+
"*"
|
|
50
|
+
],
|
|
51
|
+
..._lodash.default.cloneDeep(userOptions.pxtorem || {})
|
|
52
|
+
});
|
|
53
|
+
applyRules.forEach((name) => {
|
|
54
|
+
chain.module.rules.has(name) && chain.module.rule(name).use(CHAIN_ID.USE.POSTCSS).tap((options = {}) => {
|
|
55
|
+
var _options_postcssOptions;
|
|
56
|
+
return {
|
|
57
|
+
...options,
|
|
58
|
+
postcssOptions: {
|
|
59
|
+
...options.postcssOptions || {},
|
|
60
|
+
plugins: [
|
|
61
|
+
...((_options_postcssOptions = options.postcssOptions) === null || _options_postcssOptions === void 0 ? void 0 : _options_postcssOptions.plugins) || [],
|
|
62
|
+
getPxToRemPlugin()
|
|
63
|
+
]
|
|
64
|
+
}
|
|
65
|
+
};
|
|
68
66
|
});
|
|
69
|
-
if (!userOptions.enableRuntime) {
|
|
70
|
-
return;
|
|
71
|
-
}
|
|
72
|
-
const entries = Object.keys(chain.entryPoints.entries() || {});
|
|
73
|
-
const distDir = (0, _buildershared.getDistPath)(config.output, "js");
|
|
74
|
-
chain.plugin(CHAIN_ID.PLUGIN.AUTO_SET_ROOT_SIZE).use(_buildershared.AutoSetRootFontSizePlugin, [
|
|
75
|
-
userOptions,
|
|
76
|
-
entries,
|
|
77
|
-
HtmlPlugin,
|
|
78
|
-
distDir
|
|
79
|
-
]);
|
|
80
67
|
});
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
}
|
|
68
|
+
if (!userOptions.enableRuntime) {
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
const entries = Object.keys(chain.entryPoints.entries() || {});
|
|
72
|
+
const distDir = (0, _buildershared.getDistPath)(config.output, "js");
|
|
73
|
+
chain.plugin(CHAIN_ID.PLUGIN.AUTO_SET_ROOT_SIZE).use(_buildershared.AutoSetRootFontSizePlugin, [
|
|
74
|
+
userOptions,
|
|
75
|
+
entries,
|
|
76
|
+
HtmlPlugin,
|
|
77
|
+
distDir
|
|
78
|
+
]);
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
});
|
|
@@ -9,12 +9,6 @@ export declare const getSourceInclude: (options: {
|
|
|
9
9
|
sourceField: string;
|
|
10
10
|
extraMonorepoStrategies?: ExtraMonorepoStrategies;
|
|
11
11
|
}) => Promise<string[]>;
|
|
12
|
-
export declare const sourceBuildInWebpack: (api: WebpackBuilderPluginAPI, options: {
|
|
13
|
-
sourceField: string;
|
|
14
|
-
projectRootPath: string;
|
|
15
|
-
projectName?: string;
|
|
16
|
-
extraMonorepoStrategies?: ExtraMonorepoStrategies;
|
|
17
|
-
}) => void;
|
|
18
12
|
export interface PluginSourceBuildOptions {
|
|
19
13
|
projectName?: string;
|
|
20
14
|
sourceField?: string;
|
|
@@ -16,14 +16,13 @@ _export(exports, {
|
|
|
16
16
|
getSourceInclude: function() {
|
|
17
17
|
return getSourceInclude;
|
|
18
18
|
},
|
|
19
|
-
sourceBuildInWebpack: function() {
|
|
20
|
-
return sourceBuildInWebpack;
|
|
21
|
-
},
|
|
22
19
|
builderPluginSourceBuild: function() {
|
|
23
20
|
return builderPluginSourceBuild;
|
|
24
21
|
}
|
|
25
22
|
});
|
|
26
23
|
const _monorepoutils = require("@modern-js/monorepo-utils");
|
|
24
|
+
const _utils = require("@modern-js/utils");
|
|
25
|
+
const log = (0, _utils.debug)("BUILDER_PLUGIN_SOURCE_BUILD");
|
|
27
26
|
const pluginName = "builder-plugin-source-build";
|
|
28
27
|
const getSourceInclude = async (options) => {
|
|
29
28
|
const { projectNameOrRootPath, sourceField, extraMonorepoStrategies, findMonorepoStartPath } = options;
|
|
@@ -39,55 +38,9 @@ const getSourceInclude = async (options) => {
|
|
|
39
38
|
field: sourceField
|
|
40
39
|
}));
|
|
41
40
|
}
|
|
41
|
+
log(`get include projects: ${includes}`);
|
|
42
42
|
return includes;
|
|
43
43
|
};
|
|
44
|
-
const sourceBuildInWebpack = (api, options) => {
|
|
45
|
-
const { sourceField, projectRootPath, projectName, extraMonorepoStrategies } = options;
|
|
46
|
-
api.modifyBuilderConfig(async (config) => {
|
|
47
|
-
var _config_experiments;
|
|
48
|
-
const { sourceBuild = true } = (_config_experiments = config.experiments) !== null && _config_experiments !== void 0 ? _config_experiments : {};
|
|
49
|
-
if (!sourceBuild) {
|
|
50
|
-
return;
|
|
51
|
-
}
|
|
52
|
-
const includes = await getSourceInclude({
|
|
53
|
-
projectNameOrRootPath: projectName || projectRootPath,
|
|
54
|
-
sourceField,
|
|
55
|
-
findMonorepoStartPath: projectRootPath,
|
|
56
|
-
extraMonorepoStrategies
|
|
57
|
-
});
|
|
58
|
-
var _config_source;
|
|
59
|
-
config.source = (_config_source = config.source) !== null && _config_source !== void 0 ? _config_source : {};
|
|
60
|
-
var _config_source_include;
|
|
61
|
-
config.source.include = [
|
|
62
|
-
...(_config_source_include = config.source.include) !== null && _config_source_include !== void 0 ? _config_source_include : [],
|
|
63
|
-
...includes
|
|
64
|
-
];
|
|
65
|
-
});
|
|
66
|
-
api.modifyBundlerChain((chain) => {
|
|
67
|
-
const { experiments: { sourceBuild } } = api.getNormalizedConfig();
|
|
68
|
-
if (!sourceBuild) {
|
|
69
|
-
return;
|
|
70
|
-
}
|
|
71
|
-
if (chain.resolve.mainFields.values().length === 0) {
|
|
72
|
-
chain.resolve.mainFields.prepend("...");
|
|
73
|
-
chain.resolve.mainFields.prepend(sourceField);
|
|
74
|
-
}
|
|
75
|
-
});
|
|
76
|
-
api.modifyWebpackConfig(async (config) => {
|
|
77
|
-
const { experiments: { sourceBuild } } = api.getNormalizedConfig();
|
|
78
|
-
if (!sourceBuild) {
|
|
79
|
-
return;
|
|
80
|
-
}
|
|
81
|
-
var _config_resolve;
|
|
82
|
-
config.resolve = (_config_resolve = config.resolve) !== null && _config_resolve !== void 0 ? _config_resolve : {};
|
|
83
|
-
var _config_resolve_conditionNames;
|
|
84
|
-
config.resolve.conditionNames = [
|
|
85
|
-
"...",
|
|
86
|
-
sourceField,
|
|
87
|
-
...(_config_resolve_conditionNames = config.resolve.conditionNames) !== null && _config_resolve_conditionNames !== void 0 ? _config_resolve_conditionNames : []
|
|
88
|
-
];
|
|
89
|
-
});
|
|
90
|
-
};
|
|
91
44
|
function builderPluginSourceBuild(options) {
|
|
92
45
|
const { projectName, sourceField = "source", extraMonorepoStrategies } = options !== null && options !== void 0 ? options : {};
|
|
93
46
|
return {
|
|
@@ -116,15 +69,16 @@ function builderPluginSourceBuild(options) {
|
|
|
116
69
|
];
|
|
117
70
|
});
|
|
118
71
|
api.modifyBundlerChain((chain, { CHAIN_ID }) => {
|
|
119
|
-
const { experiments: { sourceBuild } } = api.getNormalizedConfig();
|
|
72
|
+
const { experiments: { sourceBuild }, tools: { tsLoader } } = api.getNormalizedConfig();
|
|
120
73
|
if (!sourceBuild) {
|
|
121
74
|
return;
|
|
122
75
|
}
|
|
123
|
-
|
|
76
|
+
const useTsLoader = Boolean(tsLoader);
|
|
77
|
+
chain.module.rule(useTsLoader ? CHAIN_ID.RULE.TS : CHAIN_ID.RULE.JS).resolve.mainFields.merge([
|
|
124
78
|
"...",
|
|
125
79
|
sourceField
|
|
126
80
|
]);
|
|
127
|
-
chain.module.rule(CHAIN_ID.RULE.JS).resolve.merge({
|
|
81
|
+
chain.module.rule(useTsLoader ? CHAIN_ID.RULE.TS : CHAIN_ID.RULE.JS).resolve.merge({
|
|
128
82
|
conditionNames: [
|
|
129
83
|
"...",
|
|
130
84
|
sourceField
|
|
@@ -14,6 +14,7 @@ const builderPluginTsChecker = () => {
|
|
|
14
14
|
name: "builder-plugin-ts-checker",
|
|
15
15
|
setup(api) {
|
|
16
16
|
api.modifyBundlerChain(async (chain, { target }) => {
|
|
17
|
+
var _experiments;
|
|
17
18
|
const config = api.getNormalizedConfig();
|
|
18
19
|
if (config.output.disableTsChecker || !api.context.tsconfigPath) {
|
|
19
20
|
return;
|
|
@@ -34,13 +35,22 @@ const builderPluginTsChecker = () => {
|
|
|
34
35
|
logger.warn('"typescript" is not found in current project, Type Checker will not work.');
|
|
35
36
|
return;
|
|
36
37
|
}
|
|
38
|
+
const { experiments } = api.getNormalizedConfig();
|
|
39
|
+
var _experiments_sourceBuild;
|
|
40
|
+
const enableSourceBuild = (_experiments_sourceBuild = (_experiments = experiments) === null || _experiments === void 0 ? void 0 : _experiments.sourceBuild) !== null && _experiments_sourceBuild !== void 0 ? _experiments_sourceBuild : false;
|
|
37
41
|
const tsCheckerOptions = applyOptionsChain({
|
|
38
42
|
typescript: {
|
|
39
43
|
// avoid OOM issue
|
|
40
44
|
memoryLimit: 8192,
|
|
41
45
|
// use tsconfig of user project
|
|
42
46
|
configFile: api.context.tsconfigPath,
|
|
43
|
-
typescriptPath
|
|
47
|
+
typescriptPath,
|
|
48
|
+
// In source build mode, using the project reference generates a TS2307 error,
|
|
49
|
+
// so additional configuration of the tsChecker is required
|
|
50
|
+
...enableSourceBuild ? {
|
|
51
|
+
build: true,
|
|
52
|
+
mode: "readonly"
|
|
53
|
+
} : {}
|
|
44
54
|
},
|
|
45
55
|
issue: {
|
|
46
56
|
exclude: [
|
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.28.0",
|
|
22
22
|
"jsnext:source": "./src/index.ts",
|
|
23
23
|
"types": "./dist/index.d.ts",
|
|
24
24
|
"main": "./dist/index.js",
|
|
@@ -32,18 +32,18 @@
|
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"@svgr/webpack": "8.0.1",
|
|
34
34
|
"@swc/helpers": "0.5.1",
|
|
35
|
-
"@modern-js/builder-shared": "2.
|
|
36
|
-
"@modern-js/monorepo-utils": "2.
|
|
37
|
-
"@modern-js/utils": "2.
|
|
35
|
+
"@modern-js/builder-shared": "2.28.0",
|
|
36
|
+
"@modern-js/monorepo-utils": "2.28.0",
|
|
37
|
+
"@modern-js/utils": "2.28.0"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"@types/babel__core": "^7.20.0",
|
|
41
41
|
"@types/node": "^14",
|
|
42
42
|
"typescript": "^5",
|
|
43
|
-
"@modern-js/builder-webpack-provider": "2.
|
|
44
|
-
"@modern-js/builder-rspack-provider": "2.
|
|
45
|
-
"@scripts/build": "2.
|
|
46
|
-
"@scripts/vitest-config": "2.
|
|
43
|
+
"@modern-js/builder-webpack-provider": "2.28.0",
|
|
44
|
+
"@modern-js/builder-rspack-provider": "2.28.0",
|
|
45
|
+
"@scripts/build": "2.28.0",
|
|
46
|
+
"@scripts/vitest-config": "2.28.0"
|
|
47
47
|
},
|
|
48
48
|
"publishConfig": {
|
|
49
49
|
"registry": "https://registry.npmjs.org/",
|