@modern-js/builder 2.26.0 → 2.27.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 +19 -0
- package/dist/createBuilder.d.ts +1 -1
- package/dist/createBuilder.js +48 -38
- package/dist/index.d.ts +1 -1
- package/dist/index.js +24 -8
- package/dist/plugins/antd.d.ts +1 -1
- package/dist/plugins/antd.js +52 -30
- package/dist/plugins/arco.d.ts +1 -1
- package/dist/plugins/arco.js +43 -35
- package/dist/plugins/asset.d.ts +1 -1
- package/dist/plugins/asset.js +29 -25
- package/dist/plugins/assetsRetry.d.ts +1 -1
- package/dist/plugins/assetsRetry.js +34 -51
- package/dist/plugins/bundleAnalyzer.d.ts +1 -1
- package/dist/plugins/bundleAnalyzer.js +29 -50
- package/dist/plugins/cache.d.ts +1 -1
- package/dist/plugins/cache.js +68 -87
- package/dist/plugins/checkSyntax.d.ts +1 -1
- package/dist/plugins/checkSyntax.js +40 -54
- package/dist/plugins/cleanOutput.d.ts +1 -1
- package/dist/plugins/cleanOutput.js +22 -38
- package/dist/plugins/devtool.d.ts +1 -1
- package/dist/plugins/devtool.js +23 -21
- package/dist/plugins/entry.d.ts +1 -1
- package/dist/plugins/entry.js +23 -19
- package/dist/plugins/externals.d.ts +1 -1
- package/dist/plugins/externals.js +28 -25
- package/dist/plugins/fileSize.d.ts +1 -1
- package/dist/plugins/fileSize.js +124 -130
- package/dist/plugins/html.d.ts +1 -1
- package/dist/plugins/html.js +203 -206
- package/dist/plugins/index.d.ts +1 -1
- package/dist/plugins/index.js +40 -53
- package/dist/plugins/inlineChunk.d.ts +1 -1
- package/dist/plugins/inlineChunk.js +50 -59
- package/dist/plugins/moment.d.ts +1 -1
- package/dist/plugins/moment.js +23 -20
- package/dist/plugins/rem.d.ts +1 -1
- package/dist/plugins/rem.js +74 -97
- package/dist/plugins/sourceBuild.d.ts +12 -12
- package/dist/plugins/sourceBuild.js +125 -109
- package/dist/plugins/splitChunks.d.ts +1 -1
- package/dist/plugins/splitChunks.js +206 -229
- package/dist/plugins/startUrl.d.ts +1 -1
- package/dist/plugins/startUrl.js +62 -78
- package/dist/plugins/svg.d.ts +1 -1
- package/dist/plugins/svg.js +64 -81
- package/dist/plugins/target.d.ts +1 -1
- package/dist/plugins/target.js +52 -31
- package/dist/plugins/toml.d.ts +1 -1
- package/dist/plugins/toml.js +16 -15
- package/dist/plugins/tsChecker.d.ts +1 -1
- package/dist/plugins/tsChecker.js +69 -92
- package/dist/plugins/wasm.d.ts +1 -1
- package/dist/plugins/wasm.js +31 -32
- package/dist/plugins/yaml.d.ts +1 -1
- package/dist/plugins/yaml.js +16 -15
- package/package.json +11 -9
package/dist/plugins/cache.js
CHANGED
|
@@ -1,96 +1,77 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
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;
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "builderPluginCache", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return builderPluginCache;
|
|
9
|
+
}
|
|
17
10
|
});
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
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.builderPluginCache = void 0;
|
|
27
|
-
const path_1 = require("path");
|
|
28
|
-
const builder_shared_1 = require("@modern-js/builder-shared");
|
|
11
|
+
const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
|
|
12
|
+
const _path = require("path");
|
|
13
|
+
const _buildershared = require("@modern-js/builder-shared");
|
|
29
14
|
async function validateCache(cacheDirectory, buildDependencies) {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
return;
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* If the filenames in the buildDependencies are changed, webpack will not invalidate the previous cache.
|
|
40
|
-
* So we need to remove the cache directory to make sure the cache is invalidated.
|
|
41
|
-
*/
|
|
42
|
-
await fs.remove(cacheDirectory);
|
|
15
|
+
const { fs } = await Promise.resolve().then(() => /* @__PURE__ */ _interop_require_wildcard._(require("@modern-js/utils")));
|
|
16
|
+
const configFile = (0, _path.join)(cacheDirectory, "buildDependencies.json");
|
|
17
|
+
if (await (0, _buildershared.isFileExists)(configFile)) {
|
|
18
|
+
const prevBuildDependencies = await fs.readJSON(configFile);
|
|
19
|
+
if (JSON.stringify(prevBuildDependencies) === JSON.stringify(buildDependencies)) {
|
|
20
|
+
return;
|
|
43
21
|
}
|
|
44
|
-
await fs.
|
|
22
|
+
await fs.remove(cacheDirectory);
|
|
23
|
+
}
|
|
24
|
+
await fs.outputJSON(configFile, buildDependencies);
|
|
45
25
|
}
|
|
46
26
|
function getCacheDirectory({ cacheDirectory }, context) {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
}
|
|
52
|
-
return (0, path_1.join)(context.cachePath, context.bundlerType);
|
|
27
|
+
if (cacheDirectory) {
|
|
28
|
+
return (0, _path.isAbsolute)(cacheDirectory) ? cacheDirectory : (0, _path.join)(context.rootPath, cacheDirectory);
|
|
29
|
+
}
|
|
30
|
+
return (0, _path.join)(context.cachePath, context.bundlerType);
|
|
53
31
|
}
|
|
54
32
|
const builderPluginCache = () => ({
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
33
|
+
name: "builder-plugin-cache",
|
|
34
|
+
setup(api) {
|
|
35
|
+
api.modifyBundlerChain(async (chain, { target, env }) => {
|
|
36
|
+
const { buildCache } = api.getNormalizedConfig().performance;
|
|
37
|
+
if (buildCache === false) {
|
|
38
|
+
chain.cache(false);
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
const { context } = api;
|
|
42
|
+
const cacheConfig = typeof buildCache === "boolean" ? {} : buildCache;
|
|
43
|
+
const cacheDirectory = getCacheDirectory(cacheConfig, context);
|
|
44
|
+
const rootPackageJson = (0, _path.join)(context.rootPath, "package.json");
|
|
45
|
+
const browserslistConfig = (0, _path.join)(context.rootPath, ".browserslistrc");
|
|
46
|
+
const buildDependencies = {
|
|
47
|
+
packageJson: [
|
|
48
|
+
rootPackageJson
|
|
49
|
+
]
|
|
50
|
+
};
|
|
51
|
+
if (context.configPath) {
|
|
52
|
+
buildDependencies.config = [
|
|
53
|
+
context.configPath
|
|
54
|
+
];
|
|
55
|
+
}
|
|
56
|
+
if (context.tsconfigPath) {
|
|
57
|
+
buildDependencies.tsconfig = [
|
|
58
|
+
context.tsconfigPath
|
|
59
|
+
];
|
|
60
|
+
}
|
|
61
|
+
if (await (0, _buildershared.isFileExists)(browserslistConfig)) {
|
|
62
|
+
buildDependencies.browserslistrc = [
|
|
63
|
+
browserslistConfig
|
|
64
|
+
];
|
|
65
|
+
}
|
|
66
|
+
await validateCache(cacheDirectory, buildDependencies);
|
|
67
|
+
chain.cache({
|
|
68
|
+
// The default cache name of webpack is '${name}-${env}', and the `name` is `default` by default.
|
|
69
|
+
// We set cache name to avoid cache conflicts of different targets.
|
|
70
|
+
name: `${target}-${env}`,
|
|
71
|
+
type: "filesystem",
|
|
72
|
+
cacheDirectory,
|
|
73
|
+
buildDependencies
|
|
74
|
+
});
|
|
75
|
+
});
|
|
76
|
+
}
|
|
95
77
|
});
|
|
96
|
-
exports.builderPluginCache = builderPluginCache;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { DefaultBuilderPlugin } from '@modern-js/builder-shared';
|
|
2
|
-
export declare function builderPluginCheckSyntax(): DefaultBuilderPlugin;
|
|
2
|
+
export declare function builderPluginCheckSyntax(): DefaultBuilderPlugin;
|
|
@@ -1,60 +1,46 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
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;
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "builderPluginCheckSyntax", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return builderPluginCheckSyntax;
|
|
9
|
+
}
|
|
17
10
|
});
|
|
18
|
-
|
|
19
|
-
|
|
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.builderPluginCheckSyntax = void 0;
|
|
27
|
-
const builder_shared_1 = require("@modern-js/builder-shared");
|
|
11
|
+
const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
|
|
12
|
+
const _buildershared = require("@modern-js/builder-shared");
|
|
28
13
|
function builderPluginCheckSyntax() {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
}
|
|
14
|
+
return {
|
|
15
|
+
name: "builder-plugin-check-syntax",
|
|
16
|
+
setup(api) {
|
|
17
|
+
api.modifyBundlerChain(async (chain, { isProd, target }) => {
|
|
18
|
+
const config = api.getNormalizedConfig();
|
|
19
|
+
const { checkSyntax } = config.security;
|
|
20
|
+
if (!isProd || [
|
|
21
|
+
"node",
|
|
22
|
+
"web-worker"
|
|
23
|
+
].includes(target) || !checkSyntax) {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
const targets = await getCheckTargets(api.context, config, target, checkSyntax);
|
|
27
|
+
const { CheckSyntaxPlugin } = await Promise.resolve().then(() => /* @__PURE__ */ _interop_require_wildcard._(require("@modern-js/builder-shared")));
|
|
28
|
+
chain.plugin(CheckSyntaxPlugin.name).use(CheckSyntaxPlugin, [
|
|
29
|
+
{
|
|
30
|
+
targets,
|
|
31
|
+
exclude: typeof checkSyntax === "object" ? checkSyntax.exclude : void 0
|
|
32
|
+
}
|
|
33
|
+
]);
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
};
|
|
51
37
|
}
|
|
52
|
-
exports.builderPluginCheckSyntax = builderPluginCheckSyntax;
|
|
53
38
|
async function getCheckTargets(builderContext, builderConfig, builderTarget, checkSyntax) {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
39
|
+
var _ref;
|
|
40
|
+
const browserslist = (_ref = await (0, _buildershared.getBrowserslistWithDefault)(builderContext.rootPath, builderConfig, builderTarget)) !== null && _ref !== void 0 ? _ref : _buildershared.DEFAULT_BROWSERSLIST[builderTarget];
|
|
41
|
+
if (checkSyntax === true) {
|
|
42
|
+
return browserslist;
|
|
43
|
+
}
|
|
44
|
+
var _checkSyntax_targets;
|
|
45
|
+
return (_checkSyntax_targets = checkSyntax.targets) !== null && _checkSyntax_targets !== void 0 ? _checkSyntax_targets : browserslist;
|
|
60
46
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { DefaultBuilderPlugin } from '@modern-js/builder-shared';
|
|
2
|
-
export declare const builderPluginCleanOutput: () => DefaultBuilderPlugin;
|
|
2
|
+
export declare const builderPluginCleanOutput: () => DefaultBuilderPlugin;
|
|
@@ -1,42 +1,26 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
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;
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
17
4
|
});
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.builderPluginCleanOutput = void 0;
|
|
5
|
+
Object.defineProperty(exports, "builderPluginCleanOutput", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return builderPluginCleanOutput;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
|
|
27
12
|
const builderPluginCleanOutput = () => ({
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
13
|
+
name: "builder-plugin-clean-output",
|
|
14
|
+
setup(api) {
|
|
15
|
+
const clean = async () => {
|
|
16
|
+
const config = api.getNormalizedConfig();
|
|
17
|
+
if (config.output.cleanDistPath) {
|
|
18
|
+
const { emptyDir } = await Promise.resolve().then(() => /* @__PURE__ */ _interop_require_wildcard._(require("@modern-js/utils")));
|
|
19
|
+
const { distPath } = api.context;
|
|
20
|
+
await emptyDir(distPath);
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
api.onBeforeBuild(clean);
|
|
24
|
+
api.onBeforeStartDevServer(clean);
|
|
25
|
+
}
|
|
41
26
|
});
|
|
42
|
-
exports.builderPluginCleanOutput = builderPluginCleanOutput;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { DefaultBuilderPlugin } from '@modern-js/builder-shared';
|
|
2
|
-
export declare const builderPluginDevtool: () => DefaultBuilderPlugin;
|
|
2
|
+
export declare const builderPluginDevtool: () => DefaultBuilderPlugin;
|
package/dist/plugins/devtool.js
CHANGED
|
@@ -1,24 +1,26 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "builderPluginDevtool", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return builderPluginDevtool;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _buildershared = require("@modern-js/builder-shared");
|
|
5
12
|
const builderPluginDevtool = () => ({
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
chain.devtool(devtool);
|
|
20
|
-
}
|
|
21
|
-
});
|
|
22
|
-
},
|
|
13
|
+
name: "builder-plugin-devtool",
|
|
14
|
+
setup(api) {
|
|
15
|
+
api.modifyBundlerChain((chain, { isProd, isServer }) => {
|
|
16
|
+
const config = api.getNormalizedConfig();
|
|
17
|
+
if (!(0, _buildershared.isUseJsSourceMap)(config)) {
|
|
18
|
+
chain.devtool(false);
|
|
19
|
+
} else {
|
|
20
|
+
const prodDevTool = isServer ? "source-map" : "hidden-source-map";
|
|
21
|
+
const devtool = isProd ? prodDevTool : "cheap-module-source-map";
|
|
22
|
+
chain.devtool(devtool);
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
}
|
|
23
26
|
});
|
|
24
|
-
exports.builderPluginDevtool = builderPluginDevtool;
|
package/dist/plugins/entry.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { DefaultBuilderPlugin } from '@modern-js/builder-shared';
|
|
2
|
-
export declare const builderPluginEntry: () => DefaultBuilderPlugin;
|
|
2
|
+
export declare const builderPluginEntry: () => DefaultBuilderPlugin;
|
package/dist/plugins/entry.js
CHANGED
|
@@ -1,22 +1,26 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "
|
|
6
|
-
|
|
7
|
-
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "builderPluginEntry", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return builderPluginEntry;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _interop_require_default = require("@swc/helpers/_/_interop_require_default");
|
|
12
|
+
const _lodash = /* @__PURE__ */ _interop_require_default._(require("@modern-js/utils/lodash"));
|
|
8
13
|
const builderPluginEntry = () => ({
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
14
|
+
name: "builder-plugin-entry",
|
|
15
|
+
setup(api) {
|
|
16
|
+
api.modifyBundlerChain(async (chain) => {
|
|
17
|
+
const { entry } = api.context;
|
|
18
|
+
const { preEntry } = api.getNormalizedConfig().source;
|
|
19
|
+
Object.keys(entry).forEach((entryName) => {
|
|
20
|
+
const appendEntry = (file) => chain.entry(entryName).add(file);
|
|
21
|
+
preEntry.forEach(appendEntry);
|
|
22
|
+
_lodash.default.castArray(entry[entryName]).forEach(appendEntry);
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
}
|
|
21
26
|
});
|
|
22
|
-
exports.builderPluginEntry = builderPluginEntry;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { DefaultBuilderPlugin } from '@modern-js/builder-shared';
|
|
2
|
-
export declare function builderPluginExternals(): DefaultBuilderPlugin;
|
|
2
|
+
export declare function builderPluginExternals(): DefaultBuilderPlugin;
|
|
@@ -1,28 +1,31 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "builderPluginExternals", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return builderPluginExternals;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
4
11
|
function builderPluginExternals() {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
});
|
|
25
|
-
},
|
|
26
|
-
};
|
|
12
|
+
return {
|
|
13
|
+
name: "builder-plugin-externals",
|
|
14
|
+
setup(api) {
|
|
15
|
+
api.modifyBundlerChain((chain) => {
|
|
16
|
+
const { externals } = api.getNormalizedConfig().output;
|
|
17
|
+
if (externals) {
|
|
18
|
+
chain.externals(externals);
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
api.onBeforeCreateCompiler(({ bundlerConfigs }) => {
|
|
22
|
+
bundlerConfigs.forEach((config) => {
|
|
23
|
+
const isWebWorker = Array.isArray(config.target) ? config.target.includes("webworker") : config.target === "webworker";
|
|
24
|
+
if (isWebWorker && config.externals) {
|
|
25
|
+
delete config.externals;
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
};
|
|
27
31
|
}
|
|
28
|
-
exports.builderPluginExternals = builderPluginExternals;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { DefaultBuilderPlugin } from '@modern-js/builder-shared';
|
|
2
2
|
/** Filter source map and license files */
|
|
3
3
|
export declare const filterAsset: (asset: string) => boolean;
|
|
4
|
-
export declare const builderPluginFileSize: () => DefaultBuilderPlugin;
|
|
4
|
+
export declare const builderPluginFileSize: () => DefaultBuilderPlugin;
|