@modern-js/app-tools 2.12.0 → 2.13.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 +65 -0
- package/dist/cjs/analyze/templates.js +8 -14
- package/dist/cjs/builder/builder-rspack/index.js +1 -22
- package/dist/cjs/builder/builder-webpack/index.js +0 -4
- package/dist/cjs/builder/generator/index.js +5 -0
- package/dist/cjs/builder/shared/builderPlugins/adapterHtml.js +39 -2
- package/dist/cjs/builder/shared/builderPlugins/adapterSSR.js +20 -0
- package/dist/cjs/config/legacy/index.js +3 -2
- package/dist/cjs/defineConfig.js +8 -4
- package/dist/cjs/index.js +7 -4
- package/dist/cjs/initialize/index.js +14 -2
- package/dist/cjs/locale/index.js +1 -1
- package/dist/esm/analyze/templates.js +5 -6
- package/dist/esm/builder/builder-rspack/index.js +1 -169
- package/dist/esm/builder/builder-webpack/index.js +5 -20
- package/dist/esm/builder/generator/index.js +17 -1
- package/dist/esm/builder/shared/builderPlugins/adapterHtml.js +216 -14
- package/dist/esm/builder/shared/builderPlugins/adapterSSR.js +10 -0
- package/dist/esm/config/legacy/index.js +2 -2
- package/dist/esm/defineConfig.js +3 -1
- package/dist/esm/index.js +3 -2
- package/dist/esm/initialize/index.js +13 -2
- package/dist/esm/locale/index.js +1 -1
- package/dist/esm-node/analyze/templates.js +8 -14
- package/dist/esm-node/builder/builder-rspack/index.js +1 -12
- package/dist/esm-node/builder/builder-webpack/index.js +0 -4
- package/dist/esm-node/builder/generator/index.js +5 -0
- package/dist/esm-node/builder/shared/builderPlugins/adapterHtml.js +35 -3
- package/dist/esm-node/builder/shared/builderPlugins/adapterSSR.js +10 -0
- package/dist/esm-node/config/legacy/index.js +3 -2
- package/dist/esm-node/defineConfig.js +8 -4
- package/dist/esm-node/index.js +4 -2
- package/dist/esm-node/initialize/index.js +14 -2
- package/dist/esm-node/locale/index.js +1 -1
- package/dist/types/builder/builder-rspack/index.d.ts +1 -2
- package/dist/types/builder/shared/builderPlugins/adapterHtml.d.ts +1 -1
- package/dist/types/defineConfig.d.ts +3 -2
- package/dist/types/index.d.ts +1 -0
- package/package.json +25 -24
- package/dist/cjs/utils/language.js +0 -31
- package/dist/esm/utils/language.js +0 -6
- package/dist/esm-node/utils/language.js +0 -8
- package/dist/types/utils/language.d.ts +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,70 @@
|
|
|
1
1
|
# @modern-js/app-tools
|
|
2
2
|
|
|
3
|
+
## 2.13.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 3d5086b: feat: the rspack unsupport inline loader, so we move data-loader to bundler.module.rules
|
|
8
|
+
feat: rspack 不支持 inline loader, 所以我们将 data-loader 移动到 bundler.module.rules 配置中去。
|
|
9
|
+
|
|
10
|
+
### Patch Changes
|
|
11
|
+
|
|
12
|
+
- 69eed51: refactor: move add builder-plugin-node-polyfill action to builder-generator
|
|
13
|
+
refactor: 将添加 builder-plugin-node-polyfill 的行为移动到 builder-generator
|
|
14
|
+
- e9b1656: fix: plugin config hook can not get bundlerType, so we can't set babelConfig correctly in ssr plugin
|
|
15
|
+
fix: 插件的 config 钩子不能获得 bundlerType,所以我们在 ssr 插件不能正确的设置 babelConfig
|
|
16
|
+
- e5e4ba0: refactor(app-tools): inject **assetPrefix** by entry
|
|
17
|
+
|
|
18
|
+
refactor(app-tools): 通过 entry 来注入 **assetPrefix** 变量
|
|
19
|
+
|
|
20
|
+
- 20d694a: fix: the `defineLegacyConfig` should set autoLoadPlugins = true by default.
|
|
21
|
+
fix: `defineLegacyConfig` 应该默认将 autoLoadPlugins 设置为 true
|
|
22
|
+
- e91ec97: feat(app-tools): export mergeConfig function
|
|
23
|
+
|
|
24
|
+
feat(app-tools): 导出 mergeConfig 函数
|
|
25
|
+
|
|
26
|
+
- 034f36b: feat: set the default language of CLI to English
|
|
27
|
+
|
|
28
|
+
feat: 将命令行的默认语言设置为英文
|
|
29
|
+
|
|
30
|
+
- 034f36b: fix(upgrade): i18n of upgrade command not work
|
|
31
|
+
|
|
32
|
+
fix(upgrade): 修复 upgrade 命令的 i18n 配置不生效的问题
|
|
33
|
+
|
|
34
|
+
- Updated dependencies [1feacdc]
|
|
35
|
+
- Updated dependencies [384406c]
|
|
36
|
+
- Updated dependencies [e9b1656]
|
|
37
|
+
- Updated dependencies [c89de05]
|
|
38
|
+
- Updated dependencies [d69c0b9]
|
|
39
|
+
- Updated dependencies [3d5086b]
|
|
40
|
+
- Updated dependencies [5deb1fb]
|
|
41
|
+
- Updated dependencies [348306d]
|
|
42
|
+
- Updated dependencies [e91ec97]
|
|
43
|
+
- Updated dependencies [034f36b]
|
|
44
|
+
- Updated dependencies [384e393]
|
|
45
|
+
- Updated dependencies [78431f4]
|
|
46
|
+
- Updated dependencies [034f36b]
|
|
47
|
+
- Updated dependencies [9c0572e]
|
|
48
|
+
- Updated dependencies [538d1a8]
|
|
49
|
+
- @modern-js/builder-shared@2.13.0
|
|
50
|
+
- @modern-js/builder@2.13.0
|
|
51
|
+
- @modern-js/core@2.13.0
|
|
52
|
+
- @modern-js/builder-webpack-provider@2.13.0
|
|
53
|
+
- @modern-js/builder-rspack-provider@2.13.0
|
|
54
|
+
- @modern-js/plugin-data-loader@2.13.0
|
|
55
|
+
- @modern-js/plugin-i18n@2.13.0
|
|
56
|
+
- @modern-js/upgrade@2.13.0
|
|
57
|
+
- @modern-js/plugin@2.13.0
|
|
58
|
+
- @modern-js/builder-plugin-esbuild@2.13.0
|
|
59
|
+
- @modern-js/builder-plugin-node-polyfill@2.13.0
|
|
60
|
+
- @modern-js/plugin-lint@2.13.0
|
|
61
|
+
- @modern-js/new-action@2.13.0
|
|
62
|
+
- @modern-js/prod-server@2.13.0
|
|
63
|
+
- @modern-js/server@2.13.0
|
|
64
|
+
- @modern-js/node-bundle-require@2.13.0
|
|
65
|
+
- @modern-js/types@2.13.0
|
|
66
|
+
- @modern-js/utils@2.13.0
|
|
67
|
+
|
|
3
68
|
## 2.12.0
|
|
4
69
|
|
|
5
70
|
### Patch Changes
|
|
@@ -105,9 +105,6 @@ const html = (partials) => `
|
|
|
105
105
|
|
|
106
106
|
${partials.top.join("\n")}
|
|
107
107
|
|
|
108
|
-
<script>
|
|
109
|
-
window.__assetPrefix__ = '<%= assetPrefix %>';
|
|
110
|
-
</script>
|
|
111
108
|
${partials.head.join("\n")}
|
|
112
109
|
|
|
113
110
|
</head>
|
|
@@ -205,13 +202,10 @@ const fileSystemRoutes = async ({
|
|
|
205
202
|
if (!ssrMode) {
|
|
206
203
|
return "";
|
|
207
204
|
}
|
|
208
|
-
let dataLoaderPath = require.resolve("@modern-js/plugin-data-loader/loader");
|
|
209
205
|
if (nestedRoutesEntry) {
|
|
210
|
-
|
|
211
|
-
loadersMapFile
|
|
212
|
-
)}&loaderId=${loaderId}!`;
|
|
206
|
+
return `?mapFile=${(0, import_utils.slash)(loadersMapFile)}&loaderId=${loaderId}`;
|
|
213
207
|
}
|
|
214
|
-
return
|
|
208
|
+
return "";
|
|
215
209
|
};
|
|
216
210
|
const traverseRouteTree = (route) => {
|
|
217
211
|
var _a;
|
|
@@ -329,14 +323,14 @@ const fileSystemRoutes = async ({
|
|
|
329
323
|
let importLoadersCode = "";
|
|
330
324
|
for (const [key, loaderInfo] of Object.entries(loadersMap)) {
|
|
331
325
|
if (loaderInfo.inline) {
|
|
332
|
-
importLoadersCode += `import { loader as ${key} } from "${
|
|
333
|
-
|
|
334
|
-
)}${(
|
|
326
|
+
importLoadersCode += `import { loader as ${key} } from "${(0, import_utils.slash)(
|
|
327
|
+
loaderInfo.filePath
|
|
328
|
+
)}${getDataLoaderPath(key)}";
|
|
335
329
|
`;
|
|
336
330
|
} else {
|
|
337
|
-
importLoadersCode += `import ${key} from "${
|
|
338
|
-
|
|
339
|
-
)}${(
|
|
331
|
+
importLoadersCode += `import ${key} from "${(0, import_utils.slash)(
|
|
332
|
+
loaderInfo.filePath
|
|
333
|
+
)}${getDataLoaderPath(key)}";
|
|
340
334
|
`;
|
|
341
335
|
}
|
|
342
336
|
}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
var __create = Object.create;
|
|
2
1
|
var __defProp = Object.defineProperty;
|
|
3
2
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
3
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
6
4
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
5
|
var __export = (target, all) => {
|
|
8
6
|
for (var name in all)
|
|
@@ -16,14 +14,6 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
14
|
}
|
|
17
15
|
return to;
|
|
18
16
|
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
-
mod
|
|
26
|
-
));
|
|
27
17
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
18
|
var builder_rspack_exports = {};
|
|
29
19
|
__export(builder_rspack_exports, {
|
|
@@ -33,18 +23,7 @@ module.exports = __toCommonJS(builder_rspack_exports);
|
|
|
33
23
|
var import_builder_rspack_provider = require("@modern-js/builder-rspack-provider");
|
|
34
24
|
var import_generator = require("../generator");
|
|
35
25
|
function createRspackBuilderForModern(options) {
|
|
36
|
-
return (0, import_generator.generateBuilder)(options, import_builder_rspack_provider.builderRspackProvider
|
|
37
|
-
async modifyBuilderInstance(builder) {
|
|
38
|
-
applyBuilderPlugins(builder, options);
|
|
39
|
-
}
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
async function applyBuilderPlugins(builder, options) {
|
|
43
|
-
const { normalizedConfig } = options;
|
|
44
|
-
if (!normalizedConfig.output.disableNodePolyfill) {
|
|
45
|
-
const { builderPluginNodePolyfill } = await Promise.resolve().then(() => __toESM(require("@modern-js/builder-plugin-node-polyfill")));
|
|
46
|
-
builder.addPlugins([builderPluginNodePolyfill()]);
|
|
47
|
-
}
|
|
26
|
+
return (0, import_generator.generateBuilder)(options, import_builder_rspack_provider.builderRspackProvider);
|
|
48
27
|
}
|
|
49
28
|
// Annotate the CommonJS export names for ESM import in node:
|
|
50
29
|
0 && (module.exports = {
|
|
@@ -59,10 +59,6 @@ function modifyOutputConfig(config, appContext) {
|
|
|
59
59
|
}
|
|
60
60
|
async function applyBuilderPlugins(builder, options) {
|
|
61
61
|
const { normalizedConfig } = options;
|
|
62
|
-
if (!normalizedConfig.output.disableNodePolyfill) {
|
|
63
|
-
const { builderPluginNodePolyfill } = await Promise.resolve().then(() => __toESM(require("@modern-js/builder-plugin-node-polyfill")));
|
|
64
|
-
builder.addPlugins([builderPluginNodePolyfill()]);
|
|
65
|
-
}
|
|
66
62
|
if (normalizedConfig.tools.esbuild) {
|
|
67
63
|
const { esbuild: esbuildOptions } = normalizedConfig.tools;
|
|
68
64
|
const { builderPluginEsbuild } = await Promise.resolve().then(() => __toESM(require("@modern-js/builder-plugin-esbuild")));
|
|
@@ -63,6 +63,11 @@ async function applyBuilderPlugins(builder, options) {
|
|
|
63
63
|
builderPluginAdapterSSR(options),
|
|
64
64
|
builderPluginAdapterHtml(options)
|
|
65
65
|
]);
|
|
66
|
+
const { normalizedConfig } = options;
|
|
67
|
+
if (!normalizedConfig.output.disableNodePolyfill) {
|
|
68
|
+
const { builderPluginNodePolyfill } = await Promise.resolve().then(() => __toESM(require("@modern-js/builder-plugin-node-polyfill")));
|
|
69
|
+
builder.addPlugins([builderPluginNodePolyfill()]);
|
|
70
|
+
}
|
|
66
71
|
}
|
|
67
72
|
// Annotate the CommonJS export names for ESM import in node:
|
|
68
73
|
0 && (module.exports = {
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
1
2
|
var __defProp = Object.defineProperty;
|
|
2
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
4
6
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
7
|
var __export = (target, all) => {
|
|
6
8
|
for (var name in all)
|
|
@@ -14,6 +16,14 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
14
16
|
}
|
|
15
17
|
return to;
|
|
16
18
|
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
17
27
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
28
|
var adapterHtml_exports = {};
|
|
19
29
|
__export(adapterHtml_exports, {
|
|
@@ -21,6 +31,7 @@ __export(adapterHtml_exports, {
|
|
|
21
31
|
isHtmlEnabled: () => isHtmlEnabled
|
|
22
32
|
});
|
|
23
33
|
module.exports = __toCommonJS(adapterHtml_exports);
|
|
34
|
+
var import_builder_shared = require("@modern-js/builder-shared");
|
|
24
35
|
var import_utils = require("@modern-js/utils");
|
|
25
36
|
var import_lodash = require("@modern-js/utils/lodash");
|
|
26
37
|
var import_bundlerPlugins = require("../bundlerPlugins");
|
|
@@ -29,10 +40,10 @@ function isHtmlEnabled(config, target) {
|
|
|
29
40
|
return ((_a = config.tools) == null ? void 0 : _a.htmlPlugin) !== false && target !== "node" && target !== "service-worker" && target !== "web-worker";
|
|
30
41
|
}
|
|
31
42
|
const builderPluginAdapterHtml = (options) => ({
|
|
32
|
-
name: "builder-plugin-
|
|
43
|
+
name: "builder-plugin-adapter-modern-html",
|
|
33
44
|
setup(api) {
|
|
34
45
|
api.modifyBundlerChain(
|
|
35
|
-
(chain, { CHAIN_ID, target, HtmlPlugin: HtmlBundlerPlugin }) => {
|
|
46
|
+
async (chain, { CHAIN_ID, target, HtmlPlugin: HtmlBundlerPlugin }) => {
|
|
36
47
|
const builderConfig = api.getNormalizedConfig();
|
|
37
48
|
if (isHtmlEnabled(builderConfig, target)) {
|
|
38
49
|
applyBottomHtmlPlugin({
|
|
@@ -42,11 +53,37 @@ const builderPluginAdapterHtml = (options) => ({
|
|
|
42
53
|
CHAIN_ID,
|
|
43
54
|
HtmlBundlerPlugin
|
|
44
55
|
});
|
|
56
|
+
await injectAssetPrefix({
|
|
57
|
+
api,
|
|
58
|
+
chain
|
|
59
|
+
});
|
|
45
60
|
}
|
|
46
61
|
}
|
|
47
62
|
);
|
|
48
63
|
}
|
|
49
64
|
});
|
|
65
|
+
async function injectAssetPrefix({
|
|
66
|
+
api,
|
|
67
|
+
chain
|
|
68
|
+
}) {
|
|
69
|
+
const entries = chain.entryPoints.entries() || {};
|
|
70
|
+
const entryNames = Object.keys(entries);
|
|
71
|
+
const assetPrefix = (0, import_utils.removeTailSlash)(chain.output.get("publicPath") || "");
|
|
72
|
+
const code = `window.__assetPrefix__ = '${assetPrefix}';`;
|
|
73
|
+
const isRspack = api.context.bundlerType === "rspack";
|
|
74
|
+
if (isRspack) {
|
|
75
|
+
const fileName = "rspack-asset-prefix";
|
|
76
|
+
const { default: RspackVirtualModulePlugin } = await Promise.resolve().then(() => __toESM(require("rspack-plugin-virtual-module")));
|
|
77
|
+
entryNames.forEach((entryName) => {
|
|
78
|
+
entries[entryName].prepend(fileName);
|
|
79
|
+
chain.plugin("rspack-asset-prefix").use(RspackVirtualModulePlugin, [{ [fileName]: code }]);
|
|
80
|
+
});
|
|
81
|
+
} else {
|
|
82
|
+
entryNames.forEach((entryName) => {
|
|
83
|
+
entries[entryName].prepend((0, import_builder_shared.createVirtualModule)(code));
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
}
|
|
50
87
|
function applyBottomHtmlPlugin({
|
|
51
88
|
api,
|
|
52
89
|
chain,
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
1
2
|
var __defProp = Object.defineProperty;
|
|
2
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
4
6
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
7
|
var __export = (target, all) => {
|
|
6
8
|
for (var name in all)
|
|
@@ -14,12 +16,21 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
14
16
|
}
|
|
15
17
|
return to;
|
|
16
18
|
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
17
27
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
28
|
var adapterSSR_exports = {};
|
|
19
29
|
__export(adapterSSR_exports, {
|
|
20
30
|
builderPluginAdapterSSR: () => builderPluginAdapterSSR
|
|
21
31
|
});
|
|
22
32
|
module.exports = __toCommonJS(adapterSSR_exports);
|
|
33
|
+
var path = __toESM(require("path"));
|
|
23
34
|
var import_builder_shared = require("@modern-js/builder-shared");
|
|
24
35
|
var import_utils = require("@modern-js/utils");
|
|
25
36
|
var import_bundlerPlugins = require("../bundlerPlugins");
|
|
@@ -46,6 +57,7 @@ const builderPluginAdapterSSR = (options) => ({
|
|
|
46
57
|
applyRouterPlugin(chain, options);
|
|
47
58
|
if ((0, import_utils.isSSR)(normalizedConfig2)) {
|
|
48
59
|
await applySSRLoaderEntry(chain, options, isServer);
|
|
60
|
+
applySSRDataLoader(chain, options);
|
|
49
61
|
}
|
|
50
62
|
if (["node", "service-worker"].includes(target)) {
|
|
51
63
|
applyFilterEntriesBySSRConfig({
|
|
@@ -161,6 +173,14 @@ async function applySSRLoaderEntry(chain, optinos, isServer) {
|
|
|
161
173
|
})
|
|
162
174
|
);
|
|
163
175
|
}
|
|
176
|
+
function applySSRDataLoader(chain, options) {
|
|
177
|
+
const { normalizedConfig, appContext } = options;
|
|
178
|
+
const { appDirectory } = appContext;
|
|
179
|
+
const { entriesDir = "./src" } = normalizedConfig.source;
|
|
180
|
+
const absolutePath = path.resolve(appDirectory, entriesDir);
|
|
181
|
+
const reg = new RegExp(`${absolutePath}.*\\.loader\\.[t|j]s$`);
|
|
182
|
+
chain.module.rule("ssr-data-loader").test(reg).use("data-loader").loader(require.resolve("@modern-js/plugin-data-loader/loader")).end();
|
|
183
|
+
}
|
|
164
184
|
// Annotate the CommonJS export names for ESM import in node:
|
|
165
185
|
0 && (module.exports = {
|
|
166
186
|
builderPluginAdapterSSR
|
|
@@ -39,7 +39,8 @@ function transformNormalizedConfig(config) {
|
|
|
39
39
|
server,
|
|
40
40
|
cliOptions,
|
|
41
41
|
plugins,
|
|
42
|
-
testing
|
|
42
|
+
testing,
|
|
43
|
+
autoLoadPlugins
|
|
43
44
|
} = config;
|
|
44
45
|
return {
|
|
45
46
|
source,
|
|
@@ -59,7 +60,7 @@ function transformNormalizedConfig(config) {
|
|
|
59
60
|
security: {},
|
|
60
61
|
_raw: {},
|
|
61
62
|
experiments: {},
|
|
62
|
-
autoLoadPlugins
|
|
63
|
+
autoLoadPlugins,
|
|
63
64
|
performance: {
|
|
64
65
|
removeMomentLocale: true
|
|
65
66
|
}
|
package/dist/cjs/defineConfig.js
CHANGED
|
@@ -22,10 +22,14 @@ __export(defineConfig_exports, {
|
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(defineConfig_exports);
|
|
24
24
|
const defineConfig = (config) => config;
|
|
25
|
-
const defineLegacyConfig = (config) =>
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
25
|
+
const defineLegacyConfig = (config) => {
|
|
26
|
+
var _a;
|
|
27
|
+
return {
|
|
28
|
+
...config,
|
|
29
|
+
legacy: true,
|
|
30
|
+
autoLoadPlugins: (_a = config.autoLoadPlugins) != null ? _a : true
|
|
31
|
+
};
|
|
32
|
+
};
|
|
29
33
|
// Annotate the CommonJS export names for ESM import in node:
|
|
30
34
|
0 && (module.exports = {
|
|
31
35
|
defineConfig,
|
package/dist/cjs/index.js
CHANGED
|
@@ -30,20 +30,22 @@ var src_exports = {};
|
|
|
30
30
|
__export(src_exports, {
|
|
31
31
|
buildCommand: () => buildCommand,
|
|
32
32
|
default: () => src_default,
|
|
33
|
-
devCommand: () => devCommand
|
|
33
|
+
devCommand: () => devCommand,
|
|
34
|
+
mergeConfig: () => import_core2.mergeConfig
|
|
34
35
|
});
|
|
35
36
|
module.exports = __toCommonJS(src_exports);
|
|
36
37
|
var import_path = __toESM(require("path"));
|
|
37
38
|
var import_plugin_lint = __toESM(require("@modern-js/plugin-lint"));
|
|
38
39
|
var import_utils = require("@modern-js/utils");
|
|
39
40
|
var import_lodash = require("@modern-js/utils/lodash");
|
|
41
|
+
var import_language_detector = require("@modern-js/plugin-i18n/language-detector");
|
|
40
42
|
var import_analyze = __toESM(require("./analyze"));
|
|
41
43
|
var import_initialize = __toESM(require("./initialize"));
|
|
42
44
|
var import_hooks = require("./hooks");
|
|
43
45
|
var import_locale = require("./locale");
|
|
44
|
-
var import_language = require("./utils/language");
|
|
45
46
|
var import_restart = require("./utils/restart");
|
|
46
47
|
var import_generateWatchFiles = require("./utils/generateWatchFiles");
|
|
48
|
+
var import_core2 = require("@modern-js/core");
|
|
47
49
|
__reExport(src_exports, require("./defineConfig"), module.exports);
|
|
48
50
|
__reExport(src_exports, require("./types"), module.exports);
|
|
49
51
|
const upgradeModel = import_utils.Import.lazy(
|
|
@@ -119,7 +121,7 @@ var src_default = (options = {
|
|
|
119
121
|
(0, import_plugin_lint.default)()
|
|
120
122
|
],
|
|
121
123
|
setup: (api) => {
|
|
122
|
-
const locale = (0,
|
|
124
|
+
const locale = (0, import_language_detector.getLocaleLanguage)();
|
|
123
125
|
import_locale.i18n.changeLanguage({ locale });
|
|
124
126
|
return {
|
|
125
127
|
async commands({ program }) {
|
|
@@ -199,5 +201,6 @@ var src_default = (options = {
|
|
|
199
201
|
// Annotate the CommonJS export names for ESM import in node:
|
|
200
202
|
0 && (module.exports = {
|
|
201
203
|
buildCommand,
|
|
202
|
-
devCommand
|
|
204
|
+
devCommand,
|
|
205
|
+
mergeConfig
|
|
203
206
|
});
|
|
@@ -27,10 +27,22 @@ var initialize_default = ({
|
|
|
27
27
|
bundler
|
|
28
28
|
}) => ({
|
|
29
29
|
name: "@modern-js/plugin-initialize",
|
|
30
|
+
post: [
|
|
31
|
+
"@modern-js/plugin-ssr",
|
|
32
|
+
"@modern-js/plugin-document",
|
|
33
|
+
"@modern-js/plugin-state",
|
|
34
|
+
"@modern-js/plugin-router",
|
|
35
|
+
"@modern-js/plugin-router-v5",
|
|
36
|
+
"@modern-js/plugin-polyfill"
|
|
37
|
+
],
|
|
30
38
|
setup(api) {
|
|
31
39
|
const config = () => {
|
|
32
40
|
const appContext = api.useAppContext();
|
|
33
41
|
const userConfig = api.useConfigContext();
|
|
42
|
+
api.setAppContext({
|
|
43
|
+
...appContext,
|
|
44
|
+
bundlerType: bundler
|
|
45
|
+
});
|
|
34
46
|
return (0, import_config.checkIsLegacyConfig)(userConfig) ? (0, import_config.createLegacyDefaultConfig)(appContext) : (0, import_config.createDefaultConfig)(appContext, bundler);
|
|
35
47
|
};
|
|
36
48
|
const validateSchema = () => {
|
|
@@ -42,7 +54,7 @@ var initialize_default = ({
|
|
|
42
54
|
config,
|
|
43
55
|
validateSchema,
|
|
44
56
|
async resolvedConfig({ resolved }) {
|
|
45
|
-
var _a;
|
|
57
|
+
var _a, _b;
|
|
46
58
|
let appContext = api.useAppContext();
|
|
47
59
|
const userConfig = api.useConfigContext();
|
|
48
60
|
const port = await getServerPort(resolved);
|
|
@@ -61,7 +73,7 @@ var initialize_default = ({
|
|
|
61
73
|
...normalizedConfig.server || {},
|
|
62
74
|
port
|
|
63
75
|
};
|
|
64
|
-
resolved.autoLoadPlugins = normalizedConfig.autoLoadPlugins
|
|
76
|
+
resolved.autoLoadPlugins = (_b = normalizedConfig.autoLoadPlugins) != null ? _b : false;
|
|
65
77
|
stabilizeConfig(resolved, normalizedConfig, [
|
|
66
78
|
"source",
|
|
67
79
|
"bff",
|
package/dist/cjs/locale/index.js
CHANGED
|
@@ -25,7 +25,7 @@ var import_plugin_i18n = require("@modern-js/plugin-i18n");
|
|
|
25
25
|
var import_zh = require("./zh");
|
|
26
26
|
var import_en = require("./en");
|
|
27
27
|
const i18n = new import_plugin_i18n.I18n();
|
|
28
|
-
const localeKeys = i18n.init("
|
|
28
|
+
const localeKeys = i18n.init("en", { zh: import_zh.ZH_LOCALE, en: import_en.EN_LOCALE });
|
|
29
29
|
// Annotate the CommonJS export names for ESM import in node:
|
|
30
30
|
0 && (module.exports = {
|
|
31
31
|
i18n,
|
|
@@ -237,7 +237,7 @@ var renderFunction = function(param) {
|
|
|
237
237
|
}).join("\n"), "\n ]\n })(").concat(fileSystemRoutes2 ? "" : "App", ")\n\n\n if(!AppWrapper.init && typeof appInit !== 'undefined') {\n AppWrapper.init = appInit;\n }\n\n\n if (IS_BROWSER) {\n ").concat(customBootstrap ? "customBootstrap(AppWrapper, () => ".concat(bootstrap, ");") : "".concat(bootstrap, ";"), "\n }\n\n return AppWrapper\n");
|
|
238
238
|
};
|
|
239
239
|
var html = function(partials) {
|
|
240
|
-
return "\n<!DOCTYPE html>\n<html>\n<head>\n <%= meta %>\n <title><%= title %></title>\n\n ".concat(partials.top.join("\n"), "\n\n
|
|
240
|
+
return "\n<!DOCTYPE html>\n<html>\n<head>\n <%= meta %>\n <title><%= title %></title>\n\n ".concat(partials.top.join("\n"), "\n\n ").concat(partials.head.join("\n"), "\n\n</head>\n\n<body>\n <noscript>\n We're sorry but react app doesn't work properly without JavaScript enabled. Please enable it to continue.\n </noscript>\n <div id=\"<%= mountId %>\"><!--<?- html ?>--></div>\n ").concat(partials.body.join("\n"), "\n <!--<?- chunksMap.js ?>-->\n <!--<?- SSRDataScript ?>-->\n <!--<?- bottomTemplate ?>-->\n</body>\n\n</html>\n");
|
|
241
241
|
};
|
|
242
242
|
var routesForServer = function(param) {
|
|
243
243
|
var routes = param.routes;
|
|
@@ -318,11 +318,10 @@ var fileSystemRoutes = function() {
|
|
|
318
318
|
if (!ssrMode) {
|
|
319
319
|
return "";
|
|
320
320
|
}
|
|
321
|
-
var dataLoaderPath = require.resolve("@modern-js/plugin-data-loader/loader");
|
|
322
321
|
if (nestedRoutesEntry) {
|
|
323
|
-
|
|
322
|
+
return "?mapFile=".concat(slash(loadersMapFile), "&loaderId=").concat(loaderId);
|
|
324
323
|
}
|
|
325
|
-
return
|
|
324
|
+
return "";
|
|
326
325
|
};
|
|
327
326
|
traverseRouteTree = function(route) {
|
|
328
327
|
var children;
|
|
@@ -459,9 +458,9 @@ var fileSystemRoutes = function() {
|
|
|
459
458
|
for(_iterator1 = Object.entries(loadersMap)[Symbol.iterator](); !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true){
|
|
460
459
|
_step_value = _slicedToArray(_step1.value, 2), key = _step_value[0], loaderInfo = _step_value[1];
|
|
461
460
|
if (loaderInfo.inline) {
|
|
462
|
-
importLoadersCode += "import { loader as ".concat(key, ' } from "').concat(
|
|
461
|
+
importLoadersCode += "import { loader as ".concat(key, ' } from "').concat(slash(loaderInfo.filePath)).concat(getDataLoaderPath(key), '";\n');
|
|
463
462
|
} else {
|
|
464
|
-
importLoadersCode += "import ".concat(key, ' from "').concat(
|
|
463
|
+
importLoadersCode += "import ".concat(key, ' from "').concat(slash(loaderInfo.filePath)).concat(getDataLoaderPath(key), '";\n');
|
|
465
464
|
}
|
|
466
465
|
}
|
|
467
466
|
} catch (err) {
|
|
@@ -1,174 +1,6 @@
|
|
|
1
|
-
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
2
|
-
try {
|
|
3
|
-
var info = gen[key](arg);
|
|
4
|
-
var value = info.value;
|
|
5
|
-
} catch (error) {
|
|
6
|
-
reject(error);
|
|
7
|
-
return;
|
|
8
|
-
}
|
|
9
|
-
if (info.done) {
|
|
10
|
-
resolve(value);
|
|
11
|
-
} else {
|
|
12
|
-
Promise.resolve(value).then(_next, _throw);
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
function _asyncToGenerator(fn) {
|
|
16
|
-
return function() {
|
|
17
|
-
var self = this, args = arguments;
|
|
18
|
-
return new Promise(function(resolve, reject) {
|
|
19
|
-
var gen = fn.apply(self, args);
|
|
20
|
-
function _next(value) {
|
|
21
|
-
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
22
|
-
}
|
|
23
|
-
function _throw(err) {
|
|
24
|
-
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
25
|
-
}
|
|
26
|
-
_next(undefined);
|
|
27
|
-
});
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
var __generator = this && this.__generator || function(thisArg, body) {
|
|
31
|
-
var f, y, t, g, _ = {
|
|
32
|
-
label: 0,
|
|
33
|
-
sent: function() {
|
|
34
|
-
if (t[0] & 1) throw t[1];
|
|
35
|
-
return t[1];
|
|
36
|
-
},
|
|
37
|
-
trys: [],
|
|
38
|
-
ops: []
|
|
39
|
-
};
|
|
40
|
-
return g = {
|
|
41
|
-
next: verb(0),
|
|
42
|
-
"throw": verb(1),
|
|
43
|
-
"return": verb(2)
|
|
44
|
-
}, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
|
45
|
-
return this;
|
|
46
|
-
}), g;
|
|
47
|
-
function verb(n) {
|
|
48
|
-
return function(v) {
|
|
49
|
-
return step([
|
|
50
|
-
n,
|
|
51
|
-
v
|
|
52
|
-
]);
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
function step(op) {
|
|
56
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
57
|
-
while(_)try {
|
|
58
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
59
|
-
if (y = 0, t) op = [
|
|
60
|
-
op[0] & 2,
|
|
61
|
-
t.value
|
|
62
|
-
];
|
|
63
|
-
switch(op[0]){
|
|
64
|
-
case 0:
|
|
65
|
-
case 1:
|
|
66
|
-
t = op;
|
|
67
|
-
break;
|
|
68
|
-
case 4:
|
|
69
|
-
_.label++;
|
|
70
|
-
return {
|
|
71
|
-
value: op[1],
|
|
72
|
-
done: false
|
|
73
|
-
};
|
|
74
|
-
case 5:
|
|
75
|
-
_.label++;
|
|
76
|
-
y = op[1];
|
|
77
|
-
op = [
|
|
78
|
-
0
|
|
79
|
-
];
|
|
80
|
-
continue;
|
|
81
|
-
case 7:
|
|
82
|
-
op = _.ops.pop();
|
|
83
|
-
_.trys.pop();
|
|
84
|
-
continue;
|
|
85
|
-
default:
|
|
86
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
87
|
-
_ = 0;
|
|
88
|
-
continue;
|
|
89
|
-
}
|
|
90
|
-
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
91
|
-
_.label = op[1];
|
|
92
|
-
break;
|
|
93
|
-
}
|
|
94
|
-
if (op[0] === 6 && _.label < t[1]) {
|
|
95
|
-
_.label = t[1];
|
|
96
|
-
t = op;
|
|
97
|
-
break;
|
|
98
|
-
}
|
|
99
|
-
if (t && _.label < t[2]) {
|
|
100
|
-
_.label = t[2];
|
|
101
|
-
_.ops.push(op);
|
|
102
|
-
break;
|
|
103
|
-
}
|
|
104
|
-
if (t[2]) _.ops.pop();
|
|
105
|
-
_.trys.pop();
|
|
106
|
-
continue;
|
|
107
|
-
}
|
|
108
|
-
op = body.call(thisArg, _);
|
|
109
|
-
} catch (e) {
|
|
110
|
-
op = [
|
|
111
|
-
6,
|
|
112
|
-
e
|
|
113
|
-
];
|
|
114
|
-
y = 0;
|
|
115
|
-
} finally{
|
|
116
|
-
f = t = 0;
|
|
117
|
-
}
|
|
118
|
-
if (op[0] & 5) throw op[1];
|
|
119
|
-
return {
|
|
120
|
-
value: op[0] ? op[1] : void 0,
|
|
121
|
-
done: true
|
|
122
|
-
};
|
|
123
|
-
}
|
|
124
|
-
};
|
|
125
1
|
import { builderRspackProvider } from "@modern-js/builder-rspack-provider";
|
|
126
2
|
import { generateBuilder } from "../generator";
|
|
127
3
|
function createRspackBuilderForModern(options) {
|
|
128
|
-
return generateBuilder(options, builderRspackProvider
|
|
129
|
-
modifyBuilderInstance: function modifyBuilderInstance(builder) {
|
|
130
|
-
return _asyncToGenerator(function() {
|
|
131
|
-
return __generator(this, function(_state) {
|
|
132
|
-
applyBuilderPlugins(builder, options);
|
|
133
|
-
return [
|
|
134
|
-
2
|
|
135
|
-
];
|
|
136
|
-
});
|
|
137
|
-
})();
|
|
138
|
-
}
|
|
139
|
-
});
|
|
140
|
-
}
|
|
141
|
-
function applyBuilderPlugins(builder, options) {
|
|
142
|
-
return _applyBuilderPlugins.apply(this, arguments);
|
|
143
|
-
}
|
|
144
|
-
function _applyBuilderPlugins() {
|
|
145
|
-
_applyBuilderPlugins = _asyncToGenerator(function(builder, options) {
|
|
146
|
-
var normalizedConfig, builderPluginNodePolyfill;
|
|
147
|
-
return __generator(this, function(_state) {
|
|
148
|
-
switch(_state.label){
|
|
149
|
-
case 0:
|
|
150
|
-
normalizedConfig = options.normalizedConfig;
|
|
151
|
-
if (!!normalizedConfig.output.disableNodePolyfill) return [
|
|
152
|
-
3,
|
|
153
|
-
2
|
|
154
|
-
];
|
|
155
|
-
return [
|
|
156
|
-
4,
|
|
157
|
-
import("@modern-js/builder-plugin-node-polyfill")
|
|
158
|
-
];
|
|
159
|
-
case 1:
|
|
160
|
-
builderPluginNodePolyfill = _state.sent().builderPluginNodePolyfill;
|
|
161
|
-
builder.addPlugins([
|
|
162
|
-
builderPluginNodePolyfill()
|
|
163
|
-
]);
|
|
164
|
-
_state.label = 2;
|
|
165
|
-
case 2:
|
|
166
|
-
return [
|
|
167
|
-
2
|
|
168
|
-
];
|
|
169
|
-
}
|
|
170
|
-
});
|
|
171
|
-
});
|
|
172
|
-
return _applyBuilderPlugins.apply(this, arguments);
|
|
4
|
+
return generateBuilder(options, builderRspackProvider);
|
|
173
5
|
}
|
|
174
6
|
export { createRspackBuilderForModern };
|