@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/svg.js
CHANGED
|
@@ -1,84 +1,67 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "builderPluginSvg", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return builderPluginSvg;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _interop_require_default = require("@swc/helpers/_/_interop_require_default");
|
|
12
|
+
const _path = /* @__PURE__ */ _interop_require_default._(require("path"));
|
|
13
|
+
const _buildershared = require("@modern-js/builder-shared");
|
|
9
14
|
const builderPluginSvg = () => {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
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
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
});
|
|
63
|
-
rule
|
|
64
|
-
.oneOf(CHAIN_ID.ONE_OF.SVG)
|
|
65
|
-
.type('javascript/auto')
|
|
66
|
-
.use(CHAIN_ID.USE.SVGR)
|
|
67
|
-
.loader(require.resolve('@svgr/webpack'))
|
|
68
|
-
.options({
|
|
69
|
-
svgo: true,
|
|
70
|
-
svgoConfig: (0, builder_shared_1.getSvgoDefaultConfig)(),
|
|
71
|
-
})
|
|
72
|
-
.end()
|
|
73
|
-
.when(defaultExport === 'url', c => c
|
|
74
|
-
.use(CHAIN_ID.USE.URL)
|
|
75
|
-
.loader((0, builder_shared_1.getSharedPkgCompiledPath)('url-loader'))
|
|
76
|
-
.options({
|
|
77
|
-
limit: config.output.dataUriLimit.svg,
|
|
78
|
-
name: outputName,
|
|
79
|
-
}));
|
|
80
|
-
});
|
|
81
|
-
},
|
|
82
|
-
};
|
|
15
|
+
return {
|
|
16
|
+
name: "builder-plugin-svg",
|
|
17
|
+
setup(api) {
|
|
18
|
+
api.modifyBundlerChain(async (chain, { isProd, CHAIN_ID }) => {
|
|
19
|
+
const config = api.getNormalizedConfig();
|
|
20
|
+
const defaultExport = config.output.svgDefaultExport;
|
|
21
|
+
const assetType = "svg";
|
|
22
|
+
const distDir = (0, _buildershared.getDistPath)(config.output, "svg");
|
|
23
|
+
const filename = (0, _buildershared.getFilename)(config.output, "svg", isProd);
|
|
24
|
+
const outputName = _path.default.posix.join(distDir, filename);
|
|
25
|
+
const maxSize = config.output.dataUriLimit[assetType];
|
|
26
|
+
const rule = chain.module.rule(CHAIN_ID.RULE.SVG).test(_buildershared.SVG_REGEX);
|
|
27
|
+
if (config.output.disableSvgr) {
|
|
28
|
+
(0, _buildershared.chainStaticAssetRule)({
|
|
29
|
+
rule,
|
|
30
|
+
maxSize,
|
|
31
|
+
filename: _path.default.posix.join(distDir, filename),
|
|
32
|
+
assetType
|
|
33
|
+
});
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
(0, _buildershared.chainStaticAssetRule)({
|
|
37
|
+
rule,
|
|
38
|
+
maxSize,
|
|
39
|
+
filename: _path.default.posix.join(distDir, filename),
|
|
40
|
+
assetType,
|
|
41
|
+
issuer: {
|
|
42
|
+
// The issuer option ensures that SVGR will only apply if the SVG is imported from a JS file.
|
|
43
|
+
not: [
|
|
44
|
+
_buildershared.JS_REGEX,
|
|
45
|
+
_buildershared.TS_REGEX
|
|
46
|
+
]
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
rule.oneOf(CHAIN_ID.ONE_OF.SVG_INLINE).type("javascript/auto").resourceQuery(/inline/).use(CHAIN_ID.USE.URL).loader((0, _buildershared.getSharedPkgCompiledPath)("url-loader")).options({
|
|
50
|
+
limit: Infinity,
|
|
51
|
+
name: outputName
|
|
52
|
+
});
|
|
53
|
+
rule.oneOf(CHAIN_ID.ONE_OF.SVG_URL).type("javascript/auto").resourceQuery(/url/).use(CHAIN_ID.USE.URL).loader((0, _buildershared.getSharedPkgCompiledPath)("url-loader")).options({
|
|
54
|
+
limit: false,
|
|
55
|
+
name: outputName
|
|
56
|
+
});
|
|
57
|
+
rule.oneOf(CHAIN_ID.ONE_OF.SVG).type("javascript/auto").use(CHAIN_ID.USE.SVGR).loader(require.resolve("@svgr/webpack")).options({
|
|
58
|
+
svgo: true,
|
|
59
|
+
svgoConfig: (0, _buildershared.getSvgoDefaultConfig)()
|
|
60
|
+
}).end().when(defaultExport === "url", (c) => c.use(CHAIN_ID.USE.URL).loader((0, _buildershared.getSharedPkgCompiledPath)("url-loader")).options({
|
|
61
|
+
limit: config.output.dataUriLimit.svg,
|
|
62
|
+
name: outputName
|
|
63
|
+
}));
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
};
|
|
83
67
|
};
|
|
84
|
-
exports.builderPluginSvg = builderPluginSvg;
|
package/dist/plugins/target.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { DefaultBuilderPlugin } from '@modern-js/builder-shared';
|
|
2
|
-
export declare const builderPluginTarget: () => DefaultBuilderPlugin;
|
|
2
|
+
export declare const builderPluginTarget: () => DefaultBuilderPlugin;
|
package/dist/plugins/target.js
CHANGED
|
@@ -1,35 +1,56 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "builderPluginTarget", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return builderPluginTarget;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _buildershared = require("@modern-js/builder-shared");
|
|
5
12
|
const builderPluginTarget = () => ({
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
13
|
+
name: "builder-plugin-target",
|
|
14
|
+
setup(api) {
|
|
15
|
+
api.modifyBundlerChain(async (chain, { target }) => {
|
|
16
|
+
if (target === "node") {
|
|
17
|
+
chain.target("node");
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
if (target === "service-worker") {
|
|
21
|
+
chain.target("webworker");
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
if (target === "web-worker") {
|
|
25
|
+
chain.target([
|
|
26
|
+
"webworker",
|
|
27
|
+
"es5"
|
|
28
|
+
]);
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
const browserslist = await (0, _buildershared.getBrowserslist)(api.context.rootPath);
|
|
32
|
+
if (browserslist) {
|
|
33
|
+
chain.merge({
|
|
34
|
+
target: [
|
|
35
|
+
"web",
|
|
36
|
+
"browserslist"
|
|
37
|
+
]
|
|
38
|
+
});
|
|
39
|
+
} else if (target === "modern-web") {
|
|
40
|
+
chain.merge({
|
|
41
|
+
target: [
|
|
42
|
+
"web",
|
|
43
|
+
"es2015"
|
|
44
|
+
]
|
|
45
|
+
});
|
|
46
|
+
} else {
|
|
47
|
+
chain.merge({
|
|
48
|
+
target: [
|
|
49
|
+
"web",
|
|
50
|
+
"es5"
|
|
51
|
+
]
|
|
32
52
|
});
|
|
33
|
-
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
}
|
|
34
56
|
});
|
|
35
|
-
exports.builderPluginTarget = builderPluginTarget;
|
package/dist/plugins/toml.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { DefaultBuilderPlugin } from '@modern-js/builder-shared';
|
|
2
|
-
export declare const builderPluginToml: () => DefaultBuilderPlugin;
|
|
2
|
+
export declare const builderPluginToml: () => DefaultBuilderPlugin;
|
package/dist/plugins/toml.js
CHANGED
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "builderPluginToml", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return builderPluginToml;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _buildershared = require("@modern-js/builder-shared");
|
|
5
12
|
const builderPluginToml = () => ({
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
.test(/\.toml$/)
|
|
13
|
-
.use(CHAIN_ID.USE.TOML)
|
|
14
|
-
.loader((0, builder_shared_1.getSharedPkgCompiledPath)('toml-loader'));
|
|
15
|
-
});
|
|
16
|
-
},
|
|
13
|
+
name: "builder-plugin-toml",
|
|
14
|
+
setup(api) {
|
|
15
|
+
api.modifyBundlerChain((chain, { CHAIN_ID }) => {
|
|
16
|
+
chain.module.rule(CHAIN_ID.RULE.TOML).type("javascript/auto").test(/\.toml$/).use(CHAIN_ID.USE.TOML).loader((0, _buildershared.getSharedPkgCompiledPath)("toml-loader"));
|
|
17
|
+
});
|
|
18
|
+
}
|
|
17
19
|
});
|
|
18
|
-
exports.builderPluginToml = builderPluginToml;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { DefaultBuilderPlugin } from '@modern-js/builder-shared';
|
|
2
|
-
export declare const builderPluginTsChecker: () => DefaultBuilderPlugin;
|
|
2
|
+
export declare const builderPluginTsChecker: () => DefaultBuilderPlugin;
|
|
@@ -1,96 +1,73 @@
|
|
|
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.builderPluginTsChecker = void 0;
|
|
5
|
+
Object.defineProperty(exports, "builderPluginTsChecker", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return builderPluginTsChecker;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
|
|
27
12
|
const builderPluginTsChecker = () => {
|
|
28
|
-
|
|
29
|
-
|
|
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
|
-
|
|
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
|
-
chain
|
|
90
|
-
.plugin(CHAIN_ID.PLUGIN.TS_CHECKER)
|
|
91
|
-
.use(ForkTsCheckerWebpackPlugin, [tsCheckerOptions]);
|
|
92
|
-
});
|
|
93
|
-
},
|
|
94
|
-
};
|
|
13
|
+
return {
|
|
14
|
+
name: "builder-plugin-ts-checker",
|
|
15
|
+
setup(api) {
|
|
16
|
+
api.modifyBundlerChain(async (chain, { target }) => {
|
|
17
|
+
const config = api.getNormalizedConfig();
|
|
18
|
+
if (config.output.disableTsChecker || !api.context.tsconfigPath) {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
if (Array.isArray(api.context.target) && target !== api.context.target[0]) {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
const { default: ForkTsCheckerWebpackPlugin } = await Promise.resolve().then(() => /* @__PURE__ */ _interop_require_wildcard._(require("@modern-js/builder-shared/fork-ts-checker-webpack-plugin")));
|
|
25
|
+
const { logger, CHAIN_ID, applyOptionsChain } = await Promise.resolve().then(() => /* @__PURE__ */ _interop_require_wildcard._(require("@modern-js/utils")));
|
|
26
|
+
let typescriptPath;
|
|
27
|
+
try {
|
|
28
|
+
typescriptPath = require.resolve("typescript", {
|
|
29
|
+
paths: [
|
|
30
|
+
api.context.rootPath
|
|
31
|
+
]
|
|
32
|
+
});
|
|
33
|
+
} catch (err) {
|
|
34
|
+
logger.warn('"typescript" is not found in current project, Type Checker will not work.');
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
const tsCheckerOptions = applyOptionsChain({
|
|
38
|
+
typescript: {
|
|
39
|
+
// avoid OOM issue
|
|
40
|
+
memoryLimit: 8192,
|
|
41
|
+
// use tsconfig of user project
|
|
42
|
+
configFile: api.context.tsconfigPath,
|
|
43
|
+
typescriptPath
|
|
44
|
+
},
|
|
45
|
+
issue: {
|
|
46
|
+
exclude: [
|
|
47
|
+
{
|
|
48
|
+
file: "**/*.(spec|test).ts"
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
file: "**/node_modules/**/*"
|
|
52
|
+
}
|
|
53
|
+
]
|
|
54
|
+
},
|
|
55
|
+
logger: {
|
|
56
|
+
log() {
|
|
57
|
+
},
|
|
58
|
+
error(message) {
|
|
59
|
+
console.error(message.replace(/ERROR/g, "Type Error"));
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}, typeof config.tools.tsChecker === "object" ? config.tools.tsChecker : {});
|
|
63
|
+
if (api.context.bundlerType === "rspack" && chain.get("mode") === "production") {
|
|
64
|
+
logger.info("ts-checker running...");
|
|
65
|
+
logger.info("ts-checker is running slowly and will block builds until it is complete, please be patient and wait.");
|
|
66
|
+
}
|
|
67
|
+
chain.plugin(CHAIN_ID.PLUGIN.TS_CHECKER).use(ForkTsCheckerWebpackPlugin, [
|
|
68
|
+
tsCheckerOptions
|
|
69
|
+
]);
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
};
|
|
95
73
|
};
|
|
96
|
-
exports.builderPluginTsChecker = builderPluginTsChecker;
|
package/dist/plugins/wasm.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { type DefaultBuilderPlugin } from '@modern-js/builder-shared';
|
|
2
|
-
export declare const builderPluginWasm: () => DefaultBuilderPlugin;
|
|
2
|
+
export declare const builderPluginWasm: () => DefaultBuilderPlugin;
|
package/dist/plugins/wasm.js
CHANGED
|
@@ -1,35 +1,34 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "builderPluginWasm", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return builderPluginWasm;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _path = require("path");
|
|
12
|
+
const _buildershared = require("@modern-js/builder-shared");
|
|
6
13
|
const builderPluginWasm = () => ({
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
})
|
|
28
|
-
.type('asset/resource')
|
|
29
|
-
.set('generator', {
|
|
30
|
-
filename: wasmFilename,
|
|
31
|
-
});
|
|
32
|
-
});
|
|
33
|
-
},
|
|
14
|
+
name: "builder-plugin-wasm",
|
|
15
|
+
setup(api) {
|
|
16
|
+
api.modifyBundlerChain(async (chain, { CHAIN_ID }) => {
|
|
17
|
+
const config = api.getNormalizedConfig();
|
|
18
|
+
const distPath = (0, _buildershared.getDistPath)(config.output, "wasm");
|
|
19
|
+
chain.experiments({
|
|
20
|
+
...chain.get("experiments"),
|
|
21
|
+
asyncWebAssembly: true
|
|
22
|
+
});
|
|
23
|
+
const wasmFilename = (0, _path.join)(distPath, "[hash].module.wasm");
|
|
24
|
+
chain.output.merge({
|
|
25
|
+
webassemblyModuleFilename: wasmFilename
|
|
26
|
+
});
|
|
27
|
+
chain.module.rule(CHAIN_ID.RULE.WASM).test(/\.wasm$/).merge({
|
|
28
|
+
dependency: "url"
|
|
29
|
+
}).type("asset/resource").set("generator", {
|
|
30
|
+
filename: wasmFilename
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
34
|
});
|
|
35
|
-
exports.builderPluginWasm = builderPluginWasm;
|
package/dist/plugins/yaml.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { DefaultBuilderPlugin } from '@modern-js/builder-shared';
|
|
2
|
-
export declare const builderPluginYaml: () => DefaultBuilderPlugin;
|
|
2
|
+
export declare const builderPluginYaml: () => DefaultBuilderPlugin;
|
package/dist/plugins/yaml.js
CHANGED
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "builderPluginYaml", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return builderPluginYaml;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _buildershared = require("@modern-js/builder-shared");
|
|
5
12
|
const builderPluginYaml = () => ({
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
.test(/\.ya?ml$/)
|
|
13
|
-
.use(CHAIN_ID.USE.YAML)
|
|
14
|
-
.loader((0, builder_shared_1.getSharedPkgCompiledPath)('yaml-loader'));
|
|
15
|
-
});
|
|
16
|
-
},
|
|
13
|
+
name: "builder-plugin-yaml",
|
|
14
|
+
setup(api) {
|
|
15
|
+
api.modifyBundlerChain((chain, { CHAIN_ID }) => {
|
|
16
|
+
chain.module.rule(CHAIN_ID.RULE.YAML).type("javascript/auto").test(/\.ya?ml$/).use(CHAIN_ID.USE.YAML).loader((0, _buildershared.getSharedPkgCompiledPath)("yaml-loader"));
|
|
17
|
+
});
|
|
18
|
+
}
|
|
17
19
|
});
|
|
18
|
-
exports.builderPluginYaml = builderPluginYaml;
|
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.27.0",
|
|
22
22
|
"jsnext:source": "./src/index.ts",
|
|
23
23
|
"types": "./dist/index.d.ts",
|
|
24
24
|
"main": "./dist/index.js",
|
|
@@ -31,17 +31,19 @@
|
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"@svgr/webpack": "8.0.1",
|
|
34
|
-
"@
|
|
35
|
-
"@modern-js/
|
|
36
|
-
"@modern-js/utils": "2.
|
|
34
|
+
"@swc/helpers": "0.5.1",
|
|
35
|
+
"@modern-js/builder-shared": "2.27.0",
|
|
36
|
+
"@modern-js/monorepo-utils": "2.27.0",
|
|
37
|
+
"@modern-js/utils": "2.27.0"
|
|
37
38
|
},
|
|
38
39
|
"devDependencies": {
|
|
39
40
|
"@types/babel__core": "^7.20.0",
|
|
40
41
|
"@types/node": "^14",
|
|
41
42
|
"typescript": "^5",
|
|
42
|
-
"@modern-js/builder-webpack-provider": "2.
|
|
43
|
-
"@modern-js/builder-rspack-provider": "2.
|
|
44
|
-
"@scripts/
|
|
43
|
+
"@modern-js/builder-webpack-provider": "2.27.0",
|
|
44
|
+
"@modern-js/builder-rspack-provider": "2.27.0",
|
|
45
|
+
"@scripts/build": "2.27.0",
|
|
46
|
+
"@scripts/vitest-config": "2.27.0"
|
|
45
47
|
},
|
|
46
48
|
"publishConfig": {
|
|
47
49
|
"registry": "https://registry.npmjs.org/",
|
|
@@ -50,8 +52,8 @@
|
|
|
50
52
|
},
|
|
51
53
|
"scripts": {
|
|
52
54
|
"new": "modern new",
|
|
53
|
-
"build": "
|
|
54
|
-
"dev": "
|
|
55
|
+
"build": "modern-lib build",
|
|
56
|
+
"dev": "modern-lib build --watch",
|
|
55
57
|
"test": "vitest run",
|
|
56
58
|
"test:watch": "vitest dev --no-coverage",
|
|
57
59
|
"test:ui": "vitest --ui"
|