@modern-js/builder 2.35.1 → 2.37.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/dist/cli/commands.js +34 -17
- package/dist/cli/config.js +49 -28
- package/dist/cli/index.js +35 -24
- package/dist/cli/provider.js +55 -23
- package/dist/createBuilder.js +33 -16
- package/dist/index.js +30 -21
- package/dist/plugins/antd.js +27 -17
- package/dist/plugins/arco.js +28 -11
- package/dist/plugins/asset.js +41 -15
- package/dist/plugins/assetsRetry.js +38 -12
- package/dist/plugins/bundleAnalyzer.js +35 -9
- package/dist/plugins/cache.js +49 -24
- package/dist/plugins/checkSyntax.js +37 -11
- package/dist/plugins/cleanOutput.js +35 -9
- package/dist/plugins/define.d.ts +2 -0
- package/dist/plugins/define.js +66 -0
- package/dist/plugins/devtool.js +26 -9
- package/dist/plugins/entry.js +36 -10
- package/dist/plugins/externals.js +24 -7
- package/dist/plugins/fileSize.js +60 -38
- package/dist/plugins/html.js +62 -44
- package/dist/plugins/index.js +67 -40
- package/dist/plugins/inlineChunk.js +41 -15
- package/dist/plugins/moment.js +24 -7
- package/dist/plugins/networkPerformance.js +27 -10
- package/dist/plugins/nodeAddons.js +38 -12
- package/dist/plugins/performance.js +24 -7
- package/dist/plugins/preloadOrPrefetch.js +27 -10
- package/dist/plugins/rem.js +40 -15
- package/dist/plugins/sourceBuild.d.ts +1 -1
- package/dist/plugins/sourceBuild.js +45 -27
- package/dist/plugins/splitChunks.js +55 -37
- package/dist/plugins/startUrl.js +39 -21
- package/dist/plugins/svg.js +51 -29
- package/dist/plugins/target.js +26 -9
- package/dist/plugins/toml.js +26 -9
- package/dist/plugins/tsChecker.js +38 -12
- package/dist/plugins/wasm.js +28 -11
- package/dist/plugins/yaml.js +26 -9
- package/package.json +19 -10
package/dist/plugins/asset.js
CHANGED
|
@@ -1,32 +1,58 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
Object.
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
9
17
|
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var asset_exports = {};
|
|
30
|
+
__export(asset_exports, {
|
|
31
|
+
builderAssetPlugin: () => builderAssetPlugin
|
|
10
32
|
});
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
33
|
+
module.exports = __toCommonJS(asset_exports);
|
|
34
|
+
var import_path = __toESM(require("path"));
|
|
35
|
+
var import_builder_shared = require("@modern-js/builder-shared");
|
|
14
36
|
const builderAssetPlugin = (assetType, exts) => ({
|
|
15
37
|
name: `builder-plugin-${assetType}`,
|
|
16
38
|
setup(api) {
|
|
17
39
|
api.modifyBundlerChain((chain, { isProd }) => {
|
|
18
40
|
const config = api.getNormalizedConfig();
|
|
19
|
-
const regExp = (0,
|
|
20
|
-
const distDir = (0,
|
|
21
|
-
const filename = (0,
|
|
41
|
+
const regExp = (0, import_builder_shared.getRegExpForExts)(exts);
|
|
42
|
+
const distDir = (0, import_builder_shared.getDistPath)(config.output, assetType);
|
|
43
|
+
const filename = (0, import_builder_shared.getFilename)(config.output, assetType, isProd);
|
|
22
44
|
const maxSize = config.output.dataUriLimit[assetType];
|
|
23
45
|
const rule = chain.module.rule(assetType).test(regExp);
|
|
24
|
-
(0,
|
|
46
|
+
(0, import_builder_shared.chainStaticAssetRule)({
|
|
25
47
|
rule,
|
|
26
48
|
maxSize,
|
|
27
|
-
filename:
|
|
49
|
+
filename: import_path.default.posix.join(distDir, filename),
|
|
28
50
|
assetType
|
|
29
51
|
});
|
|
30
52
|
});
|
|
31
53
|
}
|
|
32
54
|
});
|
|
55
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
56
|
+
0 && (module.exports = {
|
|
57
|
+
builderAssetPlugin
|
|
58
|
+
});
|
|
@@ -1,26 +1,48 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
Object.
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
9
17
|
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var assetsRetry_exports = {};
|
|
30
|
+
__export(assetsRetry_exports, {
|
|
31
|
+
builderPluginAssetsRetry: () => builderPluginAssetsRetry
|
|
10
32
|
});
|
|
11
|
-
|
|
12
|
-
|
|
33
|
+
module.exports = __toCommonJS(assetsRetry_exports);
|
|
34
|
+
var import_builder_shared = require("@modern-js/builder-shared");
|
|
13
35
|
function builderPluginAssetsRetry() {
|
|
14
36
|
return {
|
|
15
37
|
name: "builder-plugin-assets-retry",
|
|
16
38
|
setup(api) {
|
|
17
39
|
api.modifyBundlerChain(async (chain, { CHAIN_ID, target, HtmlPlugin }) => {
|
|
18
40
|
const config = api.getNormalizedConfig();
|
|
19
|
-
if (!config.output.assetsRetry || (0,
|
|
41
|
+
if (!config.output.assetsRetry || (0, import_builder_shared.isHtmlDisabled)(config, target)) {
|
|
20
42
|
return;
|
|
21
43
|
}
|
|
22
|
-
const { AssetsRetryPlugin } = await Promise.resolve().then(() =>
|
|
23
|
-
const distDir = (0,
|
|
44
|
+
const { AssetsRetryPlugin } = await Promise.resolve().then(() => __toESM(require("@modern-js/builder-shared")));
|
|
45
|
+
const distDir = (0, import_builder_shared.getDistPath)(config.output, "js");
|
|
24
46
|
const { assetsRetry = {} } = config.output;
|
|
25
47
|
if (assetsRetry.crossOrigin === void 0) {
|
|
26
48
|
assetsRetry.crossOrigin = config.html.crossorigin;
|
|
@@ -36,3 +58,7 @@ function builderPluginAssetsRetry() {
|
|
|
36
58
|
}
|
|
37
59
|
};
|
|
38
60
|
}
|
|
61
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
62
|
+
0 && (module.exports = {
|
|
63
|
+
builderPluginAssetsRetry
|
|
64
|
+
});
|
|
@@ -1,14 +1,36 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
Object.
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
9
17
|
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var bundleAnalyzer_exports = {};
|
|
30
|
+
__export(bundleAnalyzer_exports, {
|
|
31
|
+
builderPluginBundleAnalyzer: () => builderPluginBundleAnalyzer
|
|
10
32
|
});
|
|
11
|
-
|
|
33
|
+
module.exports = __toCommonJS(bundleAnalyzer_exports);
|
|
12
34
|
function builderPluginBundleAnalyzer() {
|
|
13
35
|
return {
|
|
14
36
|
name: "builder-plugin-bundle-analyzer",
|
|
@@ -18,7 +40,7 @@ function builderPluginBundleAnalyzer() {
|
|
|
18
40
|
if (!process.env.BUNDLE_ANALYZE && !config.performance.bundleAnalyze) {
|
|
19
41
|
return;
|
|
20
42
|
}
|
|
21
|
-
const { default: BundleAnalyzer } = await Promise.resolve().then(() =>
|
|
43
|
+
const { default: BundleAnalyzer } = await Promise.resolve().then(() => __toESM(require("@modern-js/builder-shared/webpack-bundle-analyzer")));
|
|
22
44
|
chain.plugin(CHAIN_ID.PLUGIN.BUNDLE_ANALYZER).use(BundleAnalyzer.BundleAnalyzerPlugin, [
|
|
23
45
|
{
|
|
24
46
|
analyzerMode: "static",
|
|
@@ -31,3 +53,7 @@ function builderPluginBundleAnalyzer() {
|
|
|
31
53
|
}
|
|
32
54
|
};
|
|
33
55
|
}
|
|
56
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
57
|
+
0 && (module.exports = {
|
|
58
|
+
builderPluginBundleAnalyzer
|
|
59
|
+
});
|
package/dist/plugins/cache.js
CHANGED
|
@@ -1,22 +1,43 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
Object.
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
9
17
|
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var cache_exports = {};
|
|
30
|
+
__export(cache_exports, {
|
|
31
|
+
builderPluginCache: () => builderPluginCache
|
|
10
32
|
});
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
const _buildershared = require("@modern-js/builder-shared");
|
|
33
|
+
module.exports = __toCommonJS(cache_exports);
|
|
34
|
+
var import_crypto = __toESM(require("crypto"));
|
|
35
|
+
var import_path = require("path");
|
|
36
|
+
var import_builder_shared = require("@modern-js/builder-shared");
|
|
16
37
|
async function validateCache(cacheDirectory, buildDependencies) {
|
|
17
|
-
const { fs } = await Promise.resolve().then(() =>
|
|
18
|
-
const configFile = (0,
|
|
19
|
-
if (await (0,
|
|
38
|
+
const { fs } = await Promise.resolve().then(() => __toESM(require("@modern-js/utils")));
|
|
39
|
+
const configFile = (0, import_path.join)(cacheDirectory, "buildDependencies.json");
|
|
40
|
+
if (await (0, import_builder_shared.isFileExists)(configFile)) {
|
|
20
41
|
const prevBuildDependencies = await fs.readJSON(configFile);
|
|
21
42
|
if (JSON.stringify(prevBuildDependencies) === JSON.stringify(buildDependencies)) {
|
|
22
43
|
return;
|
|
@@ -26,22 +47,22 @@ async function validateCache(cacheDirectory, buildDependencies) {
|
|
|
26
47
|
await fs.outputJSON(configFile, buildDependencies);
|
|
27
48
|
}
|
|
28
49
|
function getDigestHash(digest) {
|
|
29
|
-
const fsHash =
|
|
50
|
+
const fsHash = import_crypto.default.createHash("md5");
|
|
30
51
|
const md5 = fsHash.update(JSON.stringify(digest)).digest("hex").slice(0, 8);
|
|
31
52
|
return md5;
|
|
32
53
|
}
|
|
33
54
|
function getCacheDirectory({ cacheDirectory }, context) {
|
|
34
55
|
if (cacheDirectory) {
|
|
35
|
-
return (0,
|
|
56
|
+
return (0, import_path.isAbsolute)(cacheDirectory) ? cacheDirectory : (0, import_path.join)(context.rootPath, cacheDirectory);
|
|
36
57
|
}
|
|
37
|
-
return (0,
|
|
58
|
+
return (0, import_path.join)(context.cachePath, context.bundlerType);
|
|
38
59
|
}
|
|
39
60
|
async function getBuildDependencies(context) {
|
|
40
|
-
const { findExists } = await Promise.resolve().then(() =>
|
|
41
|
-
const rootPackageJson = (0,
|
|
42
|
-
const browserslistConfig = (0,
|
|
61
|
+
const { findExists } = await Promise.resolve().then(() => __toESM(require("@modern-js/utils")));
|
|
62
|
+
const rootPackageJson = (0, import_path.join)(context.rootPath, "package.json");
|
|
63
|
+
const browserslistConfig = (0, import_path.join)(context.rootPath, ".browserslistrc");
|
|
43
64
|
const buildDependencies = {};
|
|
44
|
-
if (await (0,
|
|
65
|
+
if (await (0, import_builder_shared.isFileExists)(rootPackageJson)) {
|
|
45
66
|
buildDependencies.packageJson = [
|
|
46
67
|
rootPackageJson
|
|
47
68
|
];
|
|
@@ -56,7 +77,7 @@ async function getBuildDependencies(context) {
|
|
|
56
77
|
context.tsconfigPath
|
|
57
78
|
];
|
|
58
79
|
}
|
|
59
|
-
if (await (0,
|
|
80
|
+
if (await (0, import_builder_shared.isFileExists)(browserslistConfig)) {
|
|
60
81
|
buildDependencies.browserslistrc = [
|
|
61
82
|
browserslistConfig
|
|
62
83
|
];
|
|
@@ -67,7 +88,7 @@ async function getBuildDependencies(context) {
|
|
|
67
88
|
"cjs",
|
|
68
89
|
"mjs"
|
|
69
90
|
];
|
|
70
|
-
const configs = tailwindExts.map((ext) => (0,
|
|
91
|
+
const configs = tailwindExts.map((ext) => (0, import_path.join)(context.rootPath, `tailwind.config.${ext}`));
|
|
71
92
|
const tailwindConfig = findExists(configs);
|
|
72
93
|
if (tailwindConfig) {
|
|
73
94
|
buildDependencies.tailwindcss = [
|
|
@@ -102,3 +123,7 @@ const builderPluginCache = () => ({
|
|
|
102
123
|
});
|
|
103
124
|
}
|
|
104
125
|
});
|
|
126
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
127
|
+
0 && (module.exports = {
|
|
128
|
+
builderPluginCache
|
|
129
|
+
});
|
|
@@ -1,15 +1,37 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
Object.
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
9
17
|
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var checkSyntax_exports = {};
|
|
30
|
+
__export(checkSyntax_exports, {
|
|
31
|
+
builderPluginCheckSyntax: () => builderPluginCheckSyntax
|
|
10
32
|
});
|
|
11
|
-
|
|
12
|
-
|
|
33
|
+
module.exports = __toCommonJS(checkSyntax_exports);
|
|
34
|
+
var import_builder_shared = require("@modern-js/builder-shared");
|
|
13
35
|
function builderPluginCheckSyntax() {
|
|
14
36
|
return {
|
|
15
37
|
name: "builder-plugin-check-syntax",
|
|
@@ -24,7 +46,7 @@ function builderPluginCheckSyntax() {
|
|
|
24
46
|
return;
|
|
25
47
|
}
|
|
26
48
|
const targets = await getCheckTargets(api.context, config, target, checkSyntax);
|
|
27
|
-
const { CheckSyntaxPlugin } = await Promise.resolve().then(() =>
|
|
49
|
+
const { CheckSyntaxPlugin } = await Promise.resolve().then(() => __toESM(require("@modern-js/builder-shared")));
|
|
28
50
|
chain.plugin(CheckSyntaxPlugin.name).use(CheckSyntaxPlugin, [
|
|
29
51
|
{
|
|
30
52
|
targets,
|
|
@@ -38,10 +60,14 @@ function builderPluginCheckSyntax() {
|
|
|
38
60
|
}
|
|
39
61
|
async function getCheckTargets(builderContext, builderConfig, builderTarget, checkSyntax) {
|
|
40
62
|
var _ref;
|
|
41
|
-
const browserslist = (_ref = await (0,
|
|
63
|
+
const browserslist = (_ref = await (0, import_builder_shared.getBrowserslistWithDefault)(builderContext.rootPath, builderConfig, builderTarget)) !== null && _ref !== void 0 ? _ref : import_builder_shared.DEFAULT_BROWSERSLIST[builderTarget];
|
|
42
64
|
if (checkSyntax === true) {
|
|
43
65
|
return browserslist;
|
|
44
66
|
}
|
|
45
67
|
var _checkSyntax_targets;
|
|
46
68
|
return (_checkSyntax_targets = checkSyntax.targets) !== null && _checkSyntax_targets !== void 0 ? _checkSyntax_targets : browserslist;
|
|
47
69
|
}
|
|
70
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
71
|
+
0 && (module.exports = {
|
|
72
|
+
builderPluginCheckSyntax
|
|
73
|
+
});
|
|
@@ -1,21 +1,43 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
Object.
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
9
17
|
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var cleanOutput_exports = {};
|
|
30
|
+
__export(cleanOutput_exports, {
|
|
31
|
+
builderPluginCleanOutput: () => builderPluginCleanOutput
|
|
10
32
|
});
|
|
11
|
-
|
|
33
|
+
module.exports = __toCommonJS(cleanOutput_exports);
|
|
12
34
|
const builderPluginCleanOutput = () => ({
|
|
13
35
|
name: "builder-plugin-clean-output",
|
|
14
36
|
setup(api) {
|
|
15
37
|
const clean = async () => {
|
|
16
38
|
const config = api.getNormalizedConfig();
|
|
17
39
|
if (config.output.cleanDistPath) {
|
|
18
|
-
const { emptyDir } = await Promise.resolve().then(() =>
|
|
40
|
+
const { emptyDir } = await Promise.resolve().then(() => __toESM(require("@modern-js/utils")));
|
|
19
41
|
const { distPath } = api.context;
|
|
20
42
|
await emptyDir(distPath);
|
|
21
43
|
}
|
|
@@ -24,3 +46,7 @@ const builderPluginCleanOutput = () => ({
|
|
|
24
46
|
api.onBeforeStartDevServer(clean);
|
|
25
47
|
}
|
|
26
48
|
});
|
|
49
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
50
|
+
0 && (module.exports = {
|
|
51
|
+
builderPluginCleanOutput
|
|
52
|
+
});
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var define_exports = {};
|
|
30
|
+
__export(define_exports, {
|
|
31
|
+
builderPluginDefine: () => builderPluginDefine
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(define_exports);
|
|
34
|
+
var import_lodash = require("@modern-js/utils/lodash");
|
|
35
|
+
const builderPluginDefine = () => ({
|
|
36
|
+
name: "builder-plugin-define",
|
|
37
|
+
async setup(api) {
|
|
38
|
+
api.modifyBundlerChain(async (chain, { env, target, CHAIN_ID, bundler }) => {
|
|
39
|
+
const { getNodeEnv, removeTailSlash, applyOptionsChain } = await Promise.resolve().then(() => __toESM(require("@modern-js/utils")));
|
|
40
|
+
const config = api.getNormalizedConfig();
|
|
41
|
+
const publicPath = chain.output.get("publicPath");
|
|
42
|
+
const assetPrefix = publicPath && typeof publicPath === "string" ? publicPath : config.output.assetPrefix;
|
|
43
|
+
const builtinVars = {
|
|
44
|
+
"process.env.NODE_ENV": getNodeEnv(),
|
|
45
|
+
"process.env.ASSET_PREFIX": removeTailSlash(assetPrefix)
|
|
46
|
+
};
|
|
47
|
+
const globalVars = applyOptionsChain(builtinVars, config.source.globalVars, {
|
|
48
|
+
env,
|
|
49
|
+
target
|
|
50
|
+
});
|
|
51
|
+
var _JSON_stringify;
|
|
52
|
+
const serializedVars = (0, import_lodash.mapValues)(globalVars, (value) => (_JSON_stringify = JSON.stringify(value)) !== null && _JSON_stringify !== void 0 ? _JSON_stringify : "undefined");
|
|
53
|
+
const defineExprs = config.source.define;
|
|
54
|
+
chain.plugin(CHAIN_ID.PLUGIN.DEFINE).use(bundler.DefinePlugin, [
|
|
55
|
+
{
|
|
56
|
+
...serializedVars,
|
|
57
|
+
...defineExprs
|
|
58
|
+
}
|
|
59
|
+
]);
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
64
|
+
0 && (module.exports = {
|
|
65
|
+
builderPluginDefine
|
|
66
|
+
});
|
package/dist/plugins/devtool.js
CHANGED
|
@@ -1,20 +1,33 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
Object.
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
9
15
|
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var devtool_exports = {};
|
|
20
|
+
__export(devtool_exports, {
|
|
21
|
+
builderPluginDevtool: () => builderPluginDevtool
|
|
10
22
|
});
|
|
11
|
-
|
|
23
|
+
module.exports = __toCommonJS(devtool_exports);
|
|
24
|
+
var import_builder_shared = require("@modern-js/builder-shared");
|
|
12
25
|
const builderPluginDevtool = () => ({
|
|
13
26
|
name: "builder-plugin-devtool",
|
|
14
27
|
setup(api) {
|
|
15
28
|
api.modifyBundlerChain((chain, { isProd, isServer }) => {
|
|
16
29
|
const config = api.getNormalizedConfig();
|
|
17
|
-
if (!(0,
|
|
30
|
+
if (!(0, import_builder_shared.isUseJsSourceMap)(config)) {
|
|
18
31
|
chain.devtool(false);
|
|
19
32
|
} else {
|
|
20
33
|
const prodDevTool = isServer ? "source-map" : "hidden-source-map";
|
|
@@ -24,3 +37,7 @@ const builderPluginDevtool = () => ({
|
|
|
24
37
|
});
|
|
25
38
|
}
|
|
26
39
|
});
|
|
40
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
41
|
+
0 && (module.exports = {
|
|
42
|
+
builderPluginDevtool
|
|
43
|
+
});
|
package/dist/plugins/entry.js
CHANGED
|
@@ -1,15 +1,37 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
Object.
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
9
17
|
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var entry_exports = {};
|
|
30
|
+
__export(entry_exports, {
|
|
31
|
+
builderPluginEntry: () => builderPluginEntry
|
|
10
32
|
});
|
|
11
|
-
|
|
12
|
-
|
|
33
|
+
module.exports = __toCommonJS(entry_exports);
|
|
34
|
+
var import_lodash = __toESM(require("@modern-js/utils/lodash"));
|
|
13
35
|
const builderPluginEntry = () => ({
|
|
14
36
|
name: "builder-plugin-entry",
|
|
15
37
|
setup(api) {
|
|
@@ -19,8 +41,12 @@ const builderPluginEntry = () => ({
|
|
|
19
41
|
Object.keys(entry).forEach((entryName) => {
|
|
20
42
|
const appendEntry = (file) => chain.entry(entryName).add(file);
|
|
21
43
|
preEntry.forEach(appendEntry);
|
|
22
|
-
|
|
44
|
+
import_lodash.default.castArray(entry[entryName]).forEach(appendEntry);
|
|
23
45
|
});
|
|
24
46
|
});
|
|
25
47
|
}
|
|
26
48
|
});
|
|
49
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
50
|
+
0 && (module.exports = {
|
|
51
|
+
builderPluginEntry
|
|
52
|
+
});
|