@modern-js/app-tools 2.47.1 → 2.48.1
Sign up to get free protection for your applications and to get access to all the features.
- package/bin/modern.js +7 -1
- package/dist/cjs/builder/generator/index.js +3 -2
- package/dist/cjs/builder/shared/builderPlugins/adapterSSR.js +2 -1
- package/dist/cjs/builder/shared/builderPlugins/adapterWorker.js +49 -0
- package/dist/cjs/builder/shared/builderPlugins/index.js +3 -1
- package/dist/cjs/builder/shared/bundlerPlugins/HtmlAsyncChunkPlugin.js +0 -3
- package/dist/cjs/builder/shared/bundlerPlugins/HtmlBottomTemplate.js +2 -5
- package/dist/cjs/builder/shared/bundlerPlugins/RouterPlugin.js +1 -8
- package/dist/cjs/index.js +5 -5
- package/dist/esm/builder/generator/index.js +4 -3
- package/dist/esm/builder/shared/builderPlugins/adapterSSR.js +2 -1
- package/dist/esm/builder/shared/builderPlugins/adapterWorker.js +41 -0
- package/dist/esm/builder/shared/builderPlugins/index.js +1 -0
- package/dist/esm/builder/shared/bundlerPlugins/HtmlAsyncChunkPlugin.js +35 -43
- package/dist/esm/builder/shared/bundlerPlugins/HtmlBottomTemplate.js +24 -32
- package/dist/esm/builder/shared/bundlerPlugins/RouterPlugin.js +240 -261
- package/dist/esm/index.js +20 -19
- package/dist/esm-node/builder/generator/index.js +3 -2
- package/dist/esm-node/builder/shared/builderPlugins/adapterSSR.js +2 -1
- package/dist/esm-node/builder/shared/builderPlugins/adapterWorker.js +25 -0
- package/dist/esm-node/builder/shared/builderPlugins/index.js +1 -0
- package/dist/esm-node/builder/shared/bundlerPlugins/HtmlAsyncChunkPlugin.js +0 -3
- package/dist/esm-node/builder/shared/bundlerPlugins/HtmlBottomTemplate.js +2 -5
- package/dist/esm-node/builder/shared/bundlerPlugins/RouterPlugin.js +1 -8
- package/dist/esm-node/index.js +6 -6
- package/dist/types/builder/shared/builderPlugins/adapterWorker.d.ts +2 -0
- package/dist/types/builder/shared/builderPlugins/index.d.ts +1 -0
- package/dist/types/config/legacy/index.d.ts +1 -1
- package/dist/types/defineConfig.d.ts +1 -1
- package/dist/types/types/config/index.d.ts +4 -3
- package/dist/types/types/config/tools.d.ts +5 -3
- package/dist/types/types/index.d.ts +2 -2
- package/package.json +21 -23
package/bin/modern.js
CHANGED
@@ -5,11 +5,17 @@ const {
|
|
5
5
|
INTERNAL_APP_TOOLS_RUNTIME_PLUGINS,
|
6
6
|
} = require('@modern-js/utils');
|
7
7
|
|
8
|
+
const { version } = require('../package.json');
|
9
|
+
|
10
|
+
if (!process.env.MODERN_JS_VERSION) {
|
11
|
+
process.env.MODERN_JS_VERSION = version;
|
12
|
+
}
|
13
|
+
|
8
14
|
require('@modern-js/core/runBin').run({
|
9
15
|
internalPlugins: {
|
10
16
|
cli: INTERNAL_APP_TOOLS_PLUGINS,
|
11
17
|
server: INTERNAL_SERVER_PLUGINS,
|
12
18
|
autoLoad: INTERNAL_APP_TOOLS_RUNTIME_PLUGINS,
|
13
19
|
},
|
14
|
-
initialLog: `Modern.js Framework v${
|
20
|
+
initialLog: `Modern.js Framework v${version}`,
|
15
21
|
});
|
@@ -49,11 +49,12 @@ async function generateBuilder(options, bundlerType) {
|
|
49
49
|
return builder;
|
50
50
|
}
|
51
51
|
async function applyBuilderPlugins(builder, options) {
|
52
|
-
const { builderPluginAdapterBasic, builderPluginAdapterHtml, builderPluginAdapterSSR } = await Promise.resolve().then(() => __toESM(require("../shared/builderPlugins")));
|
52
|
+
const { builderPluginAdapterBasic, builderPluginAdapterHtml, builderPluginAdapterSSR, builderPluginAdapterWorker } = await Promise.resolve().then(() => __toESM(require("../shared/builderPlugins")));
|
53
53
|
builder.addPlugins([
|
54
54
|
builderPluginAdapterBasic(),
|
55
55
|
builderPluginAdapterSSR(options),
|
56
|
-
builderPluginAdapterHtml(options)
|
56
|
+
builderPluginAdapterHtml(options),
|
57
|
+
builderPluginAdapterWorker()
|
57
58
|
]);
|
58
59
|
const { normalizedConfig } = options;
|
59
60
|
if (!normalizedConfig.output.disableNodePolyfill) {
|
@@ -33,6 +33,7 @@ __export(adapterSSR_exports, {
|
|
33
33
|
module.exports = __toCommonJS(adapterSSR_exports);
|
34
34
|
var path = __toESM(require("path"));
|
35
35
|
var import_shared = require("@rsbuild/shared");
|
36
|
+
var import_core = require("@rsbuild/core");
|
36
37
|
var import_utils = require("@modern-js/utils");
|
37
38
|
var import_bundlerPlugins = require("../bundlerPlugins");
|
38
39
|
var import_utils2 = require("../../../analyze/utils");
|
@@ -42,7 +43,7 @@ const builderPluginAdapterSSR = (options) => ({
|
|
42
43
|
const { normalizedConfig } = options;
|
43
44
|
api.modifyRsbuildConfig((config) => {
|
44
45
|
if (isStreamingSSR(normalizedConfig)) {
|
45
|
-
return (0,
|
46
|
+
return (0, import_core.mergeRsbuildConfig)(config, {
|
46
47
|
html: {
|
47
48
|
inject: "body"
|
48
49
|
}
|
@@ -0,0 +1,49 @@
|
|
1
|
+
"use strict";
|
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 });
|
15
|
+
}
|
16
|
+
return to;
|
17
|
+
};
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
19
|
+
var adapterWorker_exports = {};
|
20
|
+
__export(adapterWorker_exports, {
|
21
|
+
builderPluginAdapterWorker: () => builderPluginAdapterWorker
|
22
|
+
});
|
23
|
+
module.exports = __toCommonJS(adapterWorker_exports);
|
24
|
+
var import_path = require("path");
|
25
|
+
const getDistPath = (outputConfig, type) => {
|
26
|
+
const { distPath } = outputConfig;
|
27
|
+
const ret = distPath[type];
|
28
|
+
if (typeof ret !== "string") {
|
29
|
+
throw new Error(`unknown key ${type} in "output.distPath"`);
|
30
|
+
}
|
31
|
+
return ret;
|
32
|
+
};
|
33
|
+
const builderPluginAdapterWorker = () => ({
|
34
|
+
name: "builder-plugin-adapter-worker",
|
35
|
+
setup(api) {
|
36
|
+
api.modifyBundlerChain(async (chain, { isServiceWorker }) => {
|
37
|
+
const config = api.getNormalizedConfig();
|
38
|
+
if (isServiceWorker) {
|
39
|
+
const workerPath = getDistPath(config.output, "worker");
|
40
|
+
const filename = import_path.posix.join(workerPath, `[name].js`);
|
41
|
+
chain.output.filename(filename).chunkFilename(filename).libraryTarget("commonjs2");
|
42
|
+
}
|
43
|
+
});
|
44
|
+
}
|
45
|
+
});
|
46
|
+
// Annotate the CommonJS export names for ESM import in node:
|
47
|
+
0 && (module.exports = {
|
48
|
+
builderPluginAdapterWorker
|
49
|
+
});
|
@@ -18,9 +18,11 @@ module.exports = __toCommonJS(builderPlugins_exports);
|
|
18
18
|
__reExport(builderPlugins_exports, require("./adapterBasic"), module.exports);
|
19
19
|
__reExport(builderPlugins_exports, require("./adapterHtml"), module.exports);
|
20
20
|
__reExport(builderPlugins_exports, require("./adapterSSR"), module.exports);
|
21
|
+
__reExport(builderPlugins_exports, require("./adapterWorker"), module.exports);
|
21
22
|
// Annotate the CommonJS export names for ESM import in node:
|
22
23
|
0 && (module.exports = {
|
23
24
|
...require("./adapterBasic"),
|
24
25
|
...require("./adapterHtml"),
|
25
|
-
...require("./adapterSSR")
|
26
|
+
...require("./adapterSSR"),
|
27
|
+
...require("./adapterWorker")
|
26
28
|
});
|
@@ -21,7 +21,6 @@ __export(HtmlAsyncChunkPlugin_exports, {
|
|
21
21
|
HtmlAsyncChunkPlugin: () => HtmlAsyncChunkPlugin
|
22
22
|
});
|
23
23
|
module.exports = __toCommonJS(HtmlAsyncChunkPlugin_exports);
|
24
|
-
var import_define_property = require("@swc/helpers/_/_define_property");
|
25
24
|
class HtmlAsyncChunkPlugin {
|
26
25
|
apply(compiler) {
|
27
26
|
compiler.hooks.compilation.tap(this.name, (compilation) => {
|
@@ -45,8 +44,6 @@ class HtmlAsyncChunkPlugin {
|
|
45
44
|
});
|
46
45
|
}
|
47
46
|
constructor(htmlWebpackPlugin) {
|
48
|
-
(0, import_define_property._)(this, "name", void 0);
|
49
|
-
(0, import_define_property._)(this, "htmlWebpackPlugin", void 0);
|
50
47
|
this.name = "HtmlAsyncChunkPlugin";
|
51
48
|
this.htmlWebpackPlugin = htmlWebpackPlugin;
|
52
49
|
}
|
@@ -21,7 +21,6 @@ __export(HtmlBottomTemplate_exports, {
|
|
21
21
|
BottomTemplatePlugin: () => BottomTemplatePlugin
|
22
22
|
});
|
23
23
|
module.exports = __toCommonJS(HtmlBottomTemplate_exports);
|
24
|
-
var import_define_property = require("@swc/helpers/_/_define_property");
|
25
24
|
class BottomTemplatePlugin {
|
26
25
|
apply(compiler) {
|
27
26
|
compiler.hooks.compilation.tap(this.name, (compilation) => {
|
@@ -44,10 +43,8 @@ ${match}`);
|
|
44
43
|
});
|
45
44
|
}
|
46
45
|
constructor(htmlWebpackPlugin) {
|
47
|
-
|
48
|
-
|
49
|
-
(0, import_define_property._)(this, "bodyRegExp", /(<\/\s*body\s*>)/i);
|
50
|
-
(0, import_define_property._)(this, "name", void 0);
|
46
|
+
this.bottomTemplateReg = /<!--<\?-\s*bottomTemplate\s*\?>-->/;
|
47
|
+
this.bodyRegExp = /(<\/\s*body\s*>)/i;
|
51
48
|
this.htmlWebpackPlugin = htmlWebpackPlugin;
|
52
49
|
this.name = "bottom-template";
|
53
50
|
}
|
@@ -21,7 +21,6 @@ __export(RouterPlugin_exports, {
|
|
21
21
|
RouterPlugin: () => RouterPlugin
|
22
22
|
});
|
23
23
|
module.exports = __toCommonJS(RouterPlugin_exports);
|
24
|
-
var import_define_property = require("@swc/helpers/_/_define_property");
|
25
24
|
var import_crypto = require("crypto");
|
26
25
|
var import_lodash = require("@modern-js/utils/lodash");
|
27
26
|
var import_utils = require("@modern-js/utils");
|
@@ -229,13 +228,7 @@ class RouterPlugin {
|
|
229
228
|
});
|
230
229
|
}
|
231
230
|
constructor({ staticJsDir = "static/js", HtmlBundlerPlugin, enableInlineRouteManifests, disableFilenameHash = false, scriptLoading = "defer", nonce }) {
|
232
|
-
|
233
|
-
(0, import_define_property._)(this, "HtmlBundlerPlugin", void 0);
|
234
|
-
(0, import_define_property._)(this, "enableInlineRouteManifests", void 0);
|
235
|
-
(0, import_define_property._)(this, "staticJsDir", void 0);
|
236
|
-
(0, import_define_property._)(this, "disableFilenameHash", void 0);
|
237
|
-
(0, import_define_property._)(this, "scriptLoading", void 0);
|
238
|
-
(0, import_define_property._)(this, "nonce", void 0);
|
231
|
+
this.name = "RouterPlugin";
|
239
232
|
this.HtmlBundlerPlugin = HtmlBundlerPlugin;
|
240
233
|
this.enableInlineRouteManifests = enableInlineRouteManifests;
|
241
234
|
this.staticJsDir = staticJsDir;
|
package/dist/cjs/index.js
CHANGED
@@ -162,18 +162,18 @@ const appTools = (options = {
|
|
162
162
|
process.exit(0);
|
163
163
|
});
|
164
164
|
program.command("new").usage("[options]").description(import_locale.i18n.t(import_locale.localeKeys.command.new.describe)).option("--config-file <configFile>", import_locale.i18n.t(import_locale.localeKeys.command.shared.config)).option("--lang <lang>", import_locale.i18n.t(import_locale.localeKeys.command.new.lang)).option("-c, --config <config>", import_locale.i18n.t(import_locale.localeKeys.command.new.config)).option("-d, --debug", import_locale.i18n.t(import_locale.localeKeys.command.new.debug), false).option("--dist-tag <tag>", import_locale.i18n.t(import_locale.localeKeys.command.new.distTag)).option("--registry", import_locale.i18n.t(import_locale.localeKeys.command.new.registry)).option("--no-need-install", import_locale.i18n.t(import_locale.localeKeys.command.shared.noNeedInstall)).action(async (options2) => {
|
165
|
-
|
166
|
-
await MWANewAction({
|
165
|
+
await (0, import_utils.newAction)({
|
167
166
|
...options2,
|
168
167
|
locale: options2.lang || locale
|
169
|
-
});
|
168
|
+
}, "mwa");
|
170
169
|
});
|
171
170
|
program.command("inspect").description("inspect the internal configs").option(`--env <env>`, import_locale.i18n.t(import_locale.localeKeys.command.inspect.env), "development").option("--output <output>", import_locale.i18n.t(import_locale.localeKeys.command.inspect.output), "/").option("--verbose", import_locale.i18n.t(import_locale.localeKeys.command.inspect.verbose)).option("-c --config <config>", import_locale.i18n.t(import_locale.localeKeys.command.shared.config)).action(async (options2) => {
|
172
171
|
const { inspect } = await Promise.resolve().then(() => __toESM(require("./commands/inspect")));
|
173
172
|
inspect(api, options2);
|
174
173
|
});
|
175
|
-
|
176
|
-
|
174
|
+
program.command("upgrade").allowUnknownOption().option("-h --help", "Show help").action(async () => {
|
175
|
+
await (0, import_utils.upgradeAction)();
|
176
|
+
});
|
177
177
|
},
|
178
178
|
async prepare() {
|
179
179
|
const command = (0, import_utils.getCommand)();
|
@@ -48,7 +48,7 @@ function applyBuilderPlugins(builder, options) {
|
|
48
48
|
}
|
49
49
|
function _applyBuilderPlugins() {
|
50
50
|
_applyBuilderPlugins = _async_to_generator(function(builder, options) {
|
51
|
-
var _ref, builderPluginAdapterBasic, builderPluginAdapterHtml, builderPluginAdapterSSR, normalizedConfig, pluginNodePolyfill;
|
51
|
+
var _ref, builderPluginAdapterBasic, builderPluginAdapterHtml, builderPluginAdapterSSR, builderPluginAdapterWorker, normalizedConfig, pluginNodePolyfill;
|
52
52
|
return _ts_generator(this, function(_state) {
|
53
53
|
switch (_state.label) {
|
54
54
|
case 0:
|
@@ -57,11 +57,12 @@ function _applyBuilderPlugins() {
|
|
57
57
|
import("../shared/builderPlugins")
|
58
58
|
];
|
59
59
|
case 1:
|
60
|
-
_ref = _state.sent(), builderPluginAdapterBasic = _ref.builderPluginAdapterBasic, builderPluginAdapterHtml = _ref.builderPluginAdapterHtml, builderPluginAdapterSSR = _ref.builderPluginAdapterSSR;
|
60
|
+
_ref = _state.sent(), builderPluginAdapterBasic = _ref.builderPluginAdapterBasic, builderPluginAdapterHtml = _ref.builderPluginAdapterHtml, builderPluginAdapterSSR = _ref.builderPluginAdapterSSR, builderPluginAdapterWorker = _ref.builderPluginAdapterWorker;
|
61
61
|
builder.addPlugins([
|
62
62
|
builderPluginAdapterBasic(),
|
63
63
|
builderPluginAdapterSSR(options),
|
64
|
-
builderPluginAdapterHtml(options)
|
64
|
+
builderPluginAdapterHtml(options),
|
65
|
+
builderPluginAdapterWorker()
|
65
66
|
]);
|
66
67
|
normalizedConfig = options.normalizedConfig;
|
67
68
|
if (!!normalizedConfig.output.disableNodePolyfill)
|
@@ -1,7 +1,8 @@
|
|
1
1
|
import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator";
|
2
2
|
import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
|
3
3
|
import * as path from "path";
|
4
|
-
import { isHtmlDisabled
|
4
|
+
import { isHtmlDisabled } from "@rsbuild/shared";
|
5
|
+
import { mergeRsbuildConfig } from "@rsbuild/core";
|
5
6
|
import { isSSR, fs } from "@modern-js/utils";
|
6
7
|
import { HtmlAsyncChunkPlugin, RouterPlugin } from "../bundlerPlugins";
|
7
8
|
import { getServerCombinedModueFile } from "../../../analyze/utils";
|
@@ -0,0 +1,41 @@
|
|
1
|
+
import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator";
|
2
|
+
import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
|
3
|
+
import { posix } from "path";
|
4
|
+
var getDistPath = function(outputConfig, type) {
|
5
|
+
var distPath = outputConfig.distPath;
|
6
|
+
var ret = distPath[type];
|
7
|
+
if (typeof ret !== "string") {
|
8
|
+
throw new Error("unknown key ".concat(type, ' in "output.distPath"'));
|
9
|
+
}
|
10
|
+
return ret;
|
11
|
+
};
|
12
|
+
var builderPluginAdapterWorker = function() {
|
13
|
+
return {
|
14
|
+
name: "builder-plugin-adapter-worker",
|
15
|
+
setup: function setup(api) {
|
16
|
+
api.modifyBundlerChain(function() {
|
17
|
+
var _ref = _async_to_generator(function(chain, param) {
|
18
|
+
var isServiceWorker, config, workerPath, filename;
|
19
|
+
return _ts_generator(this, function(_state) {
|
20
|
+
isServiceWorker = param.isServiceWorker;
|
21
|
+
config = api.getNormalizedConfig();
|
22
|
+
if (isServiceWorker) {
|
23
|
+
workerPath = getDistPath(config.output, "worker");
|
24
|
+
filename = posix.join(workerPath, "[name].js");
|
25
|
+
chain.output.filename(filename).chunkFilename(filename).libraryTarget("commonjs2");
|
26
|
+
}
|
27
|
+
return [
|
28
|
+
2
|
29
|
+
];
|
30
|
+
});
|
31
|
+
});
|
32
|
+
return function(chain, _) {
|
33
|
+
return _ref.apply(this, arguments);
|
34
|
+
};
|
35
|
+
}());
|
36
|
+
}
|
37
|
+
};
|
38
|
+
};
|
39
|
+
export {
|
40
|
+
builderPluginAdapterWorker
|
41
|
+
};
|
@@ -1,57 +1,49 @@
|
|
1
1
|
import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check";
|
2
|
-
import { _ as _create_class } from "@swc/helpers/_/_create_class";
|
3
|
-
import { _ as _define_property } from "@swc/helpers/_/_define_property";
|
4
2
|
import { _ as _to_consumable_array } from "@swc/helpers/_/_to_consumable_array";
|
5
3
|
var HtmlAsyncChunkPlugin = /* @__PURE__ */ function() {
|
6
4
|
"use strict";
|
7
5
|
function HtmlAsyncChunkPlugin2(htmlWebpackPlugin) {
|
8
6
|
_class_call_check(this, HtmlAsyncChunkPlugin2);
|
9
|
-
_define_property(this, "name", void 0);
|
10
|
-
_define_property(this, "htmlWebpackPlugin", void 0);
|
11
7
|
this.name = "HtmlAsyncChunkPlugin";
|
12
8
|
this.htmlWebpackPlugin = htmlWebpackPlugin;
|
13
9
|
}
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
attributes.async = true;
|
31
|
-
delete attributes.defer;
|
32
|
-
}
|
33
|
-
}
|
34
|
-
}
|
35
|
-
} catch (err) {
|
36
|
-
_didIteratorError = true;
|
37
|
-
_iteratorError = err;
|
38
|
-
} finally {
|
39
|
-
try {
|
40
|
-
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
41
|
-
_iterator.return();
|
42
|
-
}
|
43
|
-
} finally {
|
44
|
-
if (_didIteratorError) {
|
45
|
-
throw _iteratorError;
|
46
|
-
}
|
10
|
+
var _proto = HtmlAsyncChunkPlugin2.prototype;
|
11
|
+
_proto.apply = function apply(compiler) {
|
12
|
+
var _this = this;
|
13
|
+
compiler.hooks.compilation.tap(this.name, function(compilation) {
|
14
|
+
var hooks = _this.htmlWebpackPlugin.getHooks(compilation);
|
15
|
+
hooks.alterAssetTagGroups.tap(_this.name, function(assets) {
|
16
|
+
var tags = _to_consumable_array(assets.headTags).concat(_to_consumable_array(assets.bodyTags));
|
17
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
|
18
|
+
try {
|
19
|
+
for (var _iterator = tags[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
20
|
+
var tag = _step.value;
|
21
|
+
if (tag.tagName === "script") {
|
22
|
+
var attributes = tag.attributes;
|
23
|
+
if (attributes && attributes.defer === true) {
|
24
|
+
attributes.async = true;
|
25
|
+
delete attributes.defer;
|
47
26
|
}
|
48
27
|
}
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
28
|
+
}
|
29
|
+
} catch (err) {
|
30
|
+
_didIteratorError = true;
|
31
|
+
_iteratorError = err;
|
32
|
+
} finally {
|
33
|
+
try {
|
34
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
35
|
+
_iterator.return();
|
36
|
+
}
|
37
|
+
} finally {
|
38
|
+
if (_didIteratorError) {
|
39
|
+
throw _iteratorError;
|
40
|
+
}
|
41
|
+
}
|
42
|
+
}
|
43
|
+
return assets;
|
44
|
+
});
|
45
|
+
});
|
46
|
+
};
|
55
47
|
return HtmlAsyncChunkPlugin2;
|
56
48
|
}();
|
57
49
|
export {
|
@@ -1,43 +1,35 @@
|
|
1
1
|
import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check";
|
2
|
-
import { _ as _create_class } from "@swc/helpers/_/_create_class";
|
3
|
-
import { _ as _define_property } from "@swc/helpers/_/_define_property";
|
4
2
|
var BottomTemplatePlugin = /* @__PURE__ */ function() {
|
5
3
|
"use strict";
|
6
4
|
function BottomTemplatePlugin2(htmlWebpackPlugin) {
|
7
5
|
_class_call_check(this, BottomTemplatePlugin2);
|
8
|
-
|
9
|
-
|
10
|
-
_define_property(this, "bodyRegExp", /(<\/\s*body\s*>)/i);
|
11
|
-
_define_property(this, "name", void 0);
|
6
|
+
this.bottomTemplateReg = /<!--<\?-\s*bottomTemplate\s*\?>-->/;
|
7
|
+
this.bodyRegExp = /(<\/\s*body\s*>)/i;
|
12
8
|
this.htmlWebpackPlugin = htmlWebpackPlugin;
|
13
9
|
this.name = "bottom-template";
|
14
10
|
}
|
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
|
-
]);
|
11
|
+
var _proto = BottomTemplatePlugin2.prototype;
|
12
|
+
_proto.apply = function apply(compiler) {
|
13
|
+
var _this = this;
|
14
|
+
compiler.hooks.compilation.tap(this.name, function(compilation) {
|
15
|
+
_this.htmlWebpackPlugin.getHooks(compilation).beforeEmit.tap(_this.name, function(data) {
|
16
|
+
var _data_plugin_options;
|
17
|
+
if (!((_data_plugin_options = data.plugin.options) === null || _data_plugin_options === void 0 ? void 0 : _data_plugin_options.__internal__)) {
|
18
|
+
return data;
|
19
|
+
}
|
20
|
+
if (_this.bottomTemplateReg.test(data.html)) {
|
21
|
+
data.html = data.html.replace(_this.bottomTemplateReg, "");
|
22
|
+
var bottomTemplate = data.plugin.options.bottomTemplate;
|
23
|
+
if (bottomTemplate) {
|
24
|
+
data.html = data.html.replace(_this.bodyRegExp, function(match) {
|
25
|
+
return "\n".concat(bottomTemplate, "\n").concat(match);
|
26
|
+
});
|
27
|
+
}
|
28
|
+
}
|
29
|
+
return data;
|
30
|
+
});
|
31
|
+
});
|
32
|
+
};
|
41
33
|
return BottomTemplatePlugin2;
|
42
34
|
}();
|
43
35
|
export {
|