@modern-js/app-tools 2.35.0 → 2.35.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/analyze/constants.js +1 -0
- package/dist/cjs/analyze/generateCode.js +3 -4
- package/dist/cjs/analyze/getFileSystemEntry.js +1 -2
- package/dist/cjs/analyze/getServerRoutes.js +4 -5
- package/dist/cjs/analyze/nestedRoutes.js +11 -2
- package/dist/cjs/analyze/templates.js +4 -4
- package/dist/cjs/builder/generator/createBuilderProviderConfig.js +1 -2
- package/dist/cjs/builder/index.js +1 -1
- package/dist/cjs/builder/shared/builderPlugins/adapterHtml.js +4 -20
- package/dist/cjs/builder/shared/builderPlugins/adapterSSR.js +12 -14
- package/dist/cjs/builder/shared/bundlerPlugins/RouterPlugin.js +2 -2
- package/dist/cjs/commands/build.js +2 -3
- package/dist/cjs/commands/inspect.js +1 -2
- package/dist/cjs/commands/serve.js +3 -3
- package/dist/cjs/index.js +127 -130
- package/dist/cjs/utils/config.js +1 -1
- package/dist/cjs/utils/printInstructions.js +1 -1
- package/dist/esm/analyze/constants.js +1 -0
- package/dist/esm/analyze/generateCode.js +4 -4
- package/dist/esm/analyze/getFileSystemEntry.js +1 -2
- package/dist/esm/analyze/getServerRoutes.js +4 -5
- package/dist/esm/analyze/nestedRoutes.js +11 -2
- package/dist/esm/analyze/templates.js +4 -4
- package/dist/esm/builder/generator/createBuilderProviderConfig.js +1 -2
- package/dist/esm/builder/index.js +1 -1
- package/dist/esm/builder/shared/builderPlugins/adapterHtml.js +12 -43
- package/dist/esm/builder/shared/builderPlugins/adapterSSR.js +12 -14
- package/dist/esm/builder/shared/bundlerPlugins/RouterPlugin.js +2 -2
- package/dist/esm/commands/build.js +3 -3
- package/dist/esm/commands/inspect.js +2 -2
- package/dist/esm/commands/serve.js +4 -4
- package/dist/esm/index.js +2 -3
- package/dist/esm/utils/config.js +2 -2
- package/dist/esm/utils/printInstructions.js +1 -1
- package/dist/esm-node/analyze/constants.js +1 -0
- package/dist/esm-node/analyze/generateCode.js +3 -4
- package/dist/esm-node/analyze/getFileSystemEntry.js +1 -2
- package/dist/esm-node/analyze/getServerRoutes.js +4 -5
- package/dist/esm-node/analyze/nestedRoutes.js +11 -2
- package/dist/esm-node/analyze/templates.js +4 -4
- package/dist/esm-node/builder/generator/createBuilderProviderConfig.js +1 -2
- package/dist/esm-node/builder/index.js +1 -1
- package/dist/esm-node/builder/shared/builderPlugins/adapterHtml.js +4 -19
- package/dist/esm-node/builder/shared/builderPlugins/adapterSSR.js +12 -14
- package/dist/esm-node/builder/shared/bundlerPlugins/RouterPlugin.js +2 -2
- package/dist/esm-node/commands/build.js +2 -3
- package/dist/esm-node/commands/inspect.js +1 -2
- package/dist/esm-node/commands/serve.js +4 -4
- package/dist/esm-node/index.js +127 -130
- package/dist/esm-node/utils/config.js +2 -2
- package/dist/esm-node/utils/printInstructions.js +1 -1
- package/dist/types/analyze/constants.d.ts +1 -0
- package/dist/types/builder/shared/bundlerPlugins/RouterPlugin.d.ts +1 -0
- package/package.json +24 -25
@@ -116,6 +116,7 @@ const NESTED_ROUTE = {
|
|
116
116
|
PAGE_DATA_FILE: "page.data",
|
117
117
|
PAGE_CLIENT_LOADER: "page.data.client",
|
118
118
|
SPLATE_FILE: "$",
|
119
|
+
SPLATE_CONFIG_FILE: "$.config",
|
119
120
|
SPLATE_LOADER_FILE: "$.loader",
|
120
121
|
SPLATE_DATA_FILE: "$.data",
|
121
122
|
SPLATE_CLIENT_DATA: "$.data.client",
|
@@ -74,13 +74,12 @@ ${initialize || ""}`);
|
|
74
74
|
${initialize || ""}`).join("\n");
|
75
75
|
};
|
76
76
|
const generateCode = async (appContext, config, entrypoints, api) => {
|
77
|
-
var _config, _config1;
|
78
77
|
const { internalDirectory, srcDirectory, internalDirAlias, internalSrcAlias, packageName } = appContext;
|
79
78
|
const hookRunners = api.useHookRunners();
|
80
79
|
const isV5 = (0, _utils.isRouterV5)(config);
|
81
80
|
const getRoutes = isV5 ? _getClientRoutes.getClientRoutesLegacy : _getClientRoutes.getClientRoutes;
|
82
81
|
const importsStatemets = /* @__PURE__ */ new Map();
|
83
|
-
const oldVersion = typeof (
|
82
|
+
const oldVersion = typeof (config === null || config === void 0 ? void 0 : config.runtime.router) === "object" ? Boolean((config === null || config === void 0 ? void 0 : config.runtime.router).oldVersion) : false;
|
84
83
|
await Promise.all(entrypoints.map(generateEntryCode));
|
85
84
|
return {
|
86
85
|
importsStatemets
|
@@ -89,7 +88,7 @@ const generateCode = async (appContext, config, entrypoints, api) => {
|
|
89
88
|
const { entryName, isMainEntry, isAutoMount, fileSystemRoutes } = entrypoint;
|
90
89
|
if (isAutoMount) {
|
91
90
|
if (fileSystemRoutes) {
|
92
|
-
var _config_output
|
91
|
+
var _config_output;
|
93
92
|
let initialRoutes = [];
|
94
93
|
let nestedRoutes = null;
|
95
94
|
if (entrypoint.entry) {
|
@@ -143,7 +142,7 @@ const generateCode = async (appContext, config, entrypoints, api) => {
|
|
143
142
|
nestedRoutesEntry: entrypoint.nestedRoutesEntry,
|
144
143
|
entryName: entrypoint.entryName,
|
145
144
|
internalDirectory,
|
146
|
-
splitRouteChunks:
|
145
|
+
splitRouteChunks: config2 === null || config2 === void 0 ? void 0 : (_config_output = config2.output) === null || _config_output === void 0 ? void 0 : _config_output.splitRouteChunks
|
147
146
|
})
|
148
147
|
});
|
149
148
|
if (entrypoint.nestedRoutesEntry && (0, _utils.isUseSSRBundle)(config2)) {
|
@@ -80,8 +80,7 @@ const getFileSystemEntry = (appContext, config) => {
|
|
80
80
|
const { source: { entriesDir, disableEntryDirs } } = config;
|
81
81
|
let disabledDirs = [];
|
82
82
|
if (disableEntryDirs && Array.isArray(disableEntryDirs)) {
|
83
|
-
|
84
|
-
disabledDirs = (_disableEntryDirs = disableEntryDirs) === null || _disableEntryDirs === void 0 ? void 0 : _disableEntryDirs.map((dir) => (0, _utils.ensureAbsolutePath)(appDirectory, dir));
|
83
|
+
disabledDirs = disableEntryDirs === null || disableEntryDirs === void 0 ? void 0 : disableEntryDirs.map((dir) => (0, _utils.ensureAbsolutePath)(appDirectory, dir));
|
85
84
|
}
|
86
85
|
const src = (0, _utils.ensureAbsolutePath)(appDirectory, entriesDir || "");
|
87
86
|
if (_fs.default.existsSync(src)) {
|
@@ -79,18 +79,17 @@ const applyRouteOptions = (original, routeOptions) => {
|
|
79
79
|
return routes;
|
80
80
|
};
|
81
81
|
const collectHtmlRoutes = (entrypoints, appContext, config) => {
|
82
|
-
var _deploy_worker
|
82
|
+
var _deploy_worker;
|
83
83
|
const { source: { mainEntryName }, html: { disableHtmlFolder }, output: { distPath: { html: htmlPath } = {} }, server: { baseUrl, routes, ssr, ssrByEntries }, deploy } = config;
|
84
84
|
const { packageName } = appContext;
|
85
|
-
const workerSSR =
|
85
|
+
const workerSSR = deploy === null || deploy === void 0 ? void 0 : (_deploy_worker = deploy.worker) === null || _deploy_worker === void 0 ? void 0 : _deploy_worker.ssr;
|
86
86
|
let htmlRoutes = entrypoints.reduce((previous, { entryName }) => {
|
87
|
-
var _routes, _routes1;
|
88
87
|
const isMainEntry = entryName === (mainEntryName || _utils.MAIN_ENTRY_NAME);
|
89
88
|
const entryOptions = (0, _utils.getEntryOptions)(entryName, isMainEntry, ssr, ssrByEntries, packageName);
|
90
89
|
const isSSR = Boolean(entryOptions);
|
91
90
|
const isWorker = Boolean(workerSSR);
|
92
91
|
const isStream = typeof entryOptions === "object" && (entryOptions.mode === "stream" || Boolean(entryOptions.preload));
|
93
|
-
const { resHeaders } = (
|
92
|
+
const { resHeaders } = (routes === null || routes === void 0 ? void 0 : routes[entryName]) || {};
|
94
93
|
let route = {
|
95
94
|
urlPath: `/${isMainEntry ? "" : entryName}`,
|
96
95
|
entryName,
|
@@ -102,7 +101,7 @@ const collectHtmlRoutes = (entrypoints, appContext, config) => {
|
|
102
101
|
worker: isWorker ? `${_utils.SERVER_WORKER_BUNDLE_DIRECTORY}/${entryName}.js` : void 0,
|
103
102
|
bundle: isSSR ? `${_utils.SERVER_BUNDLE_DIRECTORY}/${entryName}.js` : void 0
|
104
103
|
};
|
105
|
-
if (
|
104
|
+
if (routes === null || routes === void 0 ? void 0 : routes.hasOwnProperty(entryName)) {
|
106
105
|
const routeOptions = (0, _utils.isPlainObject)(routes[entryName]) ? routes[entryName] : {
|
107
106
|
route: routes[entryName]
|
108
107
|
};
|
@@ -93,7 +93,7 @@ const optimizeRoute = (routeTree) => {
|
|
93
93
|
}
|
94
94
|
};
|
95
95
|
const walk = async (dirname, rootDir, alias, entryName, isMainEntry, oldVersion) => {
|
96
|
-
var
|
96
|
+
var _finalRoute_children;
|
97
97
|
if (!await _utils.fs.pathExists(dirname)) {
|
98
98
|
return null;
|
99
99
|
}
|
@@ -113,7 +113,7 @@ const walk = async (dirname, rootDir, alias, entryName, isMainEntry, oldVersion)
|
|
113
113
|
}
|
114
114
|
routePath = replaceDynamicPath(routePath);
|
115
115
|
const route = {
|
116
|
-
path:
|
116
|
+
path: routePath === null || routePath === void 0 ? void 0 : routePath.replace(/\$$/, "?"),
|
117
117
|
children: [],
|
118
118
|
isRoot
|
119
119
|
};
|
@@ -124,6 +124,7 @@ const walk = async (dirname, rootDir, alias, entryName, isMainEntry, oldVersion)
|
|
124
124
|
let splatData = "";
|
125
125
|
let splatRoute = null;
|
126
126
|
let pageConfigFile = "";
|
127
|
+
let splatConfigFile = "";
|
127
128
|
const items = await _utils.fs.readdir(dirname);
|
128
129
|
for (const item of items) {
|
129
130
|
const itemPath = _path.join(dirname, item);
|
@@ -190,6 +191,11 @@ const walk = async (dirname, rootDir, alias, entryName, isMainEntry, oldVersion)
|
|
190
191
|
if (itemWithoutExt === _constants.NESTED_ROUTE.SPLATE_CLIENT_DATA) {
|
191
192
|
splatClientData = itemPath;
|
192
193
|
}
|
194
|
+
if (itemWithoutExt === _constants.NESTED_ROUTE.SPLATE_CONFIG_FILE) {
|
195
|
+
if (!route.config) {
|
196
|
+
splatConfigFile = itemPath;
|
197
|
+
}
|
198
|
+
}
|
193
199
|
if (itemWithoutExt === _constants.NESTED_ROUTE.SPLATE_DATA_FILE) {
|
194
200
|
splatData = itemPath;
|
195
201
|
}
|
@@ -208,6 +214,9 @@ const walk = async (dirname, rootDir, alias, entryName, isMainEntry, oldVersion)
|
|
208
214
|
if (splatData) {
|
209
215
|
splatRoute.data = splatData;
|
210
216
|
}
|
217
|
+
if (splatConfigFile) {
|
218
|
+
splatRoute.config = splatConfigFile;
|
219
|
+
}
|
211
220
|
(_route_children2 = route.children) === null || _route_children2 === void 0 ? void 0 : _route_children2.push(splatRoute);
|
212
221
|
}
|
213
222
|
if (itemWithoutExt === _constants.NESTED_ROUTE.LOADING_FILE) {
|
@@ -108,8 +108,8 @@ const routesForServer = ({ routes }) => {
|
|
108
108
|
const traverseRouteTree = (route) => {
|
109
109
|
let children;
|
110
110
|
if ("children" in route && route.children) {
|
111
|
-
var _route_children
|
112
|
-
children =
|
111
|
+
var _route_children;
|
112
|
+
children = route === null || route === void 0 ? void 0 : (_route_children = route.children) === null || _route_children === void 0 ? void 0 : _route_children.map(traverseRouteTree);
|
113
113
|
}
|
114
114
|
let loader;
|
115
115
|
if (route.type === "nested") {
|
@@ -177,8 +177,8 @@ const fileSystemRoutes = async ({ routes, ssrMode, nestedRoutesEntry, entryName,
|
|
177
177
|
const traverseRouteTree = (route) => {
|
178
178
|
let children;
|
179
179
|
if ("children" in route && route.children) {
|
180
|
-
var _route_children
|
181
|
-
children =
|
180
|
+
var _route_children;
|
181
|
+
children = route === null || route === void 0 ? void 0 : (_route_children = route.children) === null || _route_children === void 0 ? void 0 : _route_children.map(traverseRouteTree);
|
182
182
|
}
|
183
183
|
let loading;
|
184
184
|
let error;
|
@@ -10,10 +10,9 @@ Object.defineProperty(exports, "createBuilderProviderConfig", {
|
|
10
10
|
});
|
11
11
|
const _createCopyPattern = require("../builder-webpack/createCopyPattern");
|
12
12
|
function modifyOutputConfig(config, appContext) {
|
13
|
-
var _copy;
|
14
13
|
const defaultCopyPattern = (0, _createCopyPattern.createUploadPattern)(appContext, config);
|
15
14
|
const { copy } = config.output;
|
16
|
-
const copyOptions = Array.isArray(copy) ? copy :
|
15
|
+
const copyOptions = Array.isArray(copy) ? copy : copy === null || copy === void 0 ? void 0 : copy.patterns;
|
17
16
|
const builderCopy = [
|
18
17
|
...copyOptions || [],
|
19
18
|
defaultCopyPattern
|
@@ -16,7 +16,7 @@ async function createBuilderGenerator(bundler) {
|
|
16
16
|
const { createRspackBuilderForModern } = await Promise.resolve().then(() => /* @__PURE__ */ _interop_require_wildcard._(require("./builder-rspack")));
|
17
17
|
const { getRspackVersion } = await Promise.resolve().then(() => /* @__PURE__ */ _interop_require_wildcard._(require("@modern-js/builder-rspack-provider")));
|
18
18
|
const version = await getRspackVersion();
|
19
|
-
_utils.logger.info(`Using Rspack v${version}
|
19
|
+
_utils.logger.info(`Using Rspack v${version}`);
|
20
20
|
return createRspackBuilderForModern;
|
21
21
|
} catch (_) {
|
22
22
|
throw new Error("Failed to use Rspack, please check if you have `@modern-js/builder-rspack-provider` installed");
|
@@ -8,7 +8,6 @@ Object.defineProperty(exports, "builderPluginAdapterHtml", {
|
|
8
8
|
return builderPluginAdapterHtml;
|
9
9
|
}
|
10
10
|
});
|
11
|
-
const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
|
12
11
|
const _buildershared = require("@modern-js/builder-shared");
|
13
12
|
const _utils = require("@modern-js/utils");
|
14
13
|
const _lodash = require("@modern-js/utils/lodash");
|
@@ -27,35 +26,20 @@ const builderPluginAdapterHtml = (options) => ({
|
|
27
26
|
HtmlBundlerPlugin
|
28
27
|
});
|
29
28
|
await injectAssetPrefix({
|
30
|
-
api,
|
31
29
|
chain
|
32
30
|
});
|
33
31
|
}
|
34
32
|
});
|
35
33
|
}
|
36
34
|
});
|
37
|
-
async function injectAssetPrefix({
|
35
|
+
async function injectAssetPrefix({ chain }) {
|
38
36
|
const entries = chain.entryPoints.entries() || {};
|
39
37
|
const entryNames = Object.keys(entries);
|
40
38
|
const assetPrefix = (0, _utils.removeTailSlash)(chain.output.get("publicPath") || "");
|
41
39
|
const code = `window.__assetPrefix__ = '${assetPrefix}';`;
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
const { default: RspackVirtualModulePlugin } = await Promise.resolve().then(() => /* @__PURE__ */ _interop_require_wildcard._(require("rspack-plugin-virtual-module")));
|
46
|
-
entryNames.forEach((entryName) => {
|
47
|
-
entries[entryName].prepend(fileName);
|
48
|
-
chain.plugin("rspack-asset-prefix").use(RspackVirtualModulePlugin, [
|
49
|
-
{
|
50
|
-
[fileName]: code
|
51
|
-
}
|
52
|
-
]);
|
53
|
-
});
|
54
|
-
} else {
|
55
|
-
entryNames.forEach((entryName) => {
|
56
|
-
entries[entryName].prepend((0, _buildershared.createVirtualModule)(code));
|
57
|
-
});
|
58
|
-
}
|
40
|
+
entryNames.forEach((entryName) => {
|
41
|
+
entries[entryName].prepend((0, _buildershared.createVirtualModule)(code));
|
42
|
+
});
|
59
43
|
}
|
60
44
|
function applyBottomHtmlPlugin({ api, chain, options, CHAIN_ID, HtmlBundlerPlugin }) {
|
61
45
|
const { normalizedConfig: modernConfig, appContext } = options;
|
@@ -31,7 +31,7 @@ const builderPluginAdapterSSR = (options) => ({
|
|
31
31
|
api.modifyBundlerChain(async (chain, { target, CHAIN_ID, isProd, HtmlPlugin: HtmlBundlerPlugin, isServer }) => {
|
32
32
|
const builderConfig = api.getNormalizedConfig();
|
33
33
|
const { normalizedConfig: normalizedConfig2 } = options;
|
34
|
-
applyRouterPlugin(chain, options, HtmlBundlerPlugin);
|
34
|
+
applyRouterPlugin(chain, CHAIN_ID.PLUGIN.ROUTER_MANIFEST, options, HtmlBundlerPlugin);
|
35
35
|
if ((0, _utils.isSSR)(normalizedConfig2)) {
|
36
36
|
await applySSRLoaderEntry(chain, options, isServer);
|
37
37
|
applySSRDataLoader(chain, options);
|
@@ -58,13 +58,12 @@ const builderPluginAdapterSSR = (options) => ({
|
|
58
58
|
}
|
59
59
|
});
|
60
60
|
const isStreamingSSR = (userConfig) => {
|
61
|
-
var _server;
|
62
61
|
const isStreaming = (ssr) => ssr && typeof ssr === "object" && ssr.mode === "stream";
|
63
62
|
const { server } = userConfig;
|
64
63
|
if (isStreaming(server.ssr)) {
|
65
64
|
return true;
|
66
65
|
}
|
67
|
-
if ((
|
66
|
+
if ((server === null || server === void 0 ? void 0 : server.ssrByEntries) && typeof server.ssrByEntries === "object") {
|
68
67
|
for (const name of Object.keys(server.ssrByEntries)) {
|
69
68
|
if (isStreaming(server.ssrByEntries[name])) {
|
70
69
|
return true;
|
@@ -80,17 +79,17 @@ function applyAsyncChunkHtmlPlugin({ chain, modernConfig, CHAIN_ID, HtmlBundlerP
|
|
80
79
|
]);
|
81
80
|
}
|
82
81
|
}
|
83
|
-
function applyRouterPlugin(chain, options, HtmlBundlerPlugin) {
|
84
|
-
var _normalizedConfig_runtime,
|
82
|
+
function applyRouterPlugin(chain, pluginName, options, HtmlBundlerPlugin) {
|
83
|
+
var _normalizedConfig_runtime, _normalizedConfig_deploy_worker;
|
85
84
|
const { appContext, normalizedConfig } = options;
|
86
85
|
const { entrypoints } = appContext;
|
87
86
|
const existNestedRoutes = entrypoints.some((entrypoint) => entrypoint.nestedRoutesEntry);
|
88
|
-
const routerConfig =
|
89
|
-
const routerManifest = Boolean(
|
87
|
+
const routerConfig = normalizedConfig === null || normalizedConfig === void 0 ? void 0 : (_normalizedConfig_runtime = normalizedConfig.runtime) === null || _normalizedConfig_runtime === void 0 ? void 0 : _normalizedConfig_runtime.router;
|
88
|
+
const routerManifest = Boolean(routerConfig === null || routerConfig === void 0 ? void 0 : routerConfig.manifest);
|
90
89
|
const workerSSR = Boolean((_normalizedConfig_deploy_worker = normalizedConfig.deploy.worker) === null || _normalizedConfig_deploy_worker === void 0 ? void 0 : _normalizedConfig_deploy_worker.ssr);
|
91
90
|
if (existNestedRoutes || routerManifest || workerSSR) {
|
92
91
|
var _normalizedConfig_output_distPath, _normalizedConfig_output, _normalizedConfig_output1, _normalizedConfig_html, _normalizedConfig_security;
|
93
|
-
chain.plugin(
|
92
|
+
chain.plugin(pluginName).use(_bundlerPlugins.RouterPlugin, [
|
94
93
|
{
|
95
94
|
HtmlBundlerPlugin,
|
96
95
|
enableInlineRouteManifests: normalizedConfig.output.enableInlineRouteManifests,
|
@@ -103,21 +102,21 @@ function applyRouterPlugin(chain, options, HtmlBundlerPlugin) {
|
|
103
102
|
}
|
104
103
|
}
|
105
104
|
function applyFilterEntriesBySSRConfig({ isProd, chain, appNormalizedConfig }) {
|
106
|
-
var
|
105
|
+
var _this;
|
107
106
|
const { server: serverConfig, output: outputConfig } = appNormalizedConfig;
|
108
107
|
const entries = chain.entryPoints.entries();
|
109
|
-
if (isProd && ((
|
108
|
+
if (isProd && ((outputConfig === null || outputConfig === void 0 ? void 0 : outputConfig.ssg) === true || typeof ((_this = outputConfig === null || outputConfig === void 0 ? void 0 : outputConfig.ssg) === null || _this === void 0 ? void 0 : _this[0]) === "function")) {
|
110
109
|
return;
|
111
110
|
}
|
112
111
|
if (typeof entries === "undefined") {
|
113
112
|
throw new Error("No entry found, one of src/routes/layout.tsx, src/App.tsx, src/index.tsx is required");
|
114
113
|
}
|
115
114
|
const entryNames = Object.keys(entries);
|
116
|
-
if (isProd && entryNames.length === 1 && (
|
115
|
+
if (isProd && entryNames.length === 1 && (outputConfig === null || outputConfig === void 0 ? void 0 : outputConfig.ssg)) {
|
117
116
|
return;
|
118
117
|
}
|
119
118
|
const ssgEntries = [];
|
120
|
-
if (isProd && (
|
119
|
+
if (isProd && (outputConfig === null || outputConfig === void 0 ? void 0 : outputConfig.ssg)) {
|
121
120
|
const { ssg } = outputConfig;
|
122
121
|
entryNames.forEach((name) => {
|
123
122
|
if (ssg[name]) {
|
@@ -127,8 +126,7 @@ function applyFilterEntriesBySSRConfig({ isProd, chain, appNormalizedConfig }) {
|
|
127
126
|
}
|
128
127
|
const { ssr, ssrByEntries } = serverConfig || {};
|
129
128
|
entryNames.forEach((name) => {
|
130
|
-
|
131
|
-
if (!ssgEntries.includes(name) && (ssr && ((_ssrByEntries = ssrByEntries) === null || _ssrByEntries === void 0 ? void 0 : _ssrByEntries[name]) === false || !ssr && !((_ssrByEntries1 = ssrByEntries) === null || _ssrByEntries1 === void 0 ? void 0 : _ssrByEntries1[name]))) {
|
129
|
+
if (!ssgEntries.includes(name) && (ssr && (ssrByEntries === null || ssrByEntries === void 0 ? void 0 : ssrByEntries[name]) === false || !ssr && !(ssrByEntries === null || ssrByEntries === void 0 ? void 0 : ssrByEntries[name]))) {
|
132
130
|
chain.entryPoints.delete(name);
|
133
131
|
}
|
134
132
|
});
|
@@ -129,10 +129,9 @@ class RouterPlugin {
|
|
129
129
|
let relatedAssets = {};
|
130
130
|
if (entryChunkFiles.length > 1) {
|
131
131
|
Object.keys(routeAssets).forEach((routeId) => {
|
132
|
-
var _chunkNames;
|
133
132
|
const segments = routeId.split("_");
|
134
133
|
const chunkName = segments[0];
|
135
|
-
if (
|
134
|
+
if (chunkNames === null || chunkNames === void 0 ? void 0 : chunkNames.includes(chunkName)) {
|
136
135
|
relatedAssets[routeId] = routeAssets[routeId];
|
137
136
|
}
|
138
137
|
});
|
@@ -204,6 +203,7 @@ class RouterPlugin {
|
|
204
203
|
});
|
205
204
|
}
|
206
205
|
constructor({ staticJsDir = "static/js", HtmlBundlerPlugin, enableInlineRouteManifests, disableFilenameHash = false, scriptLoading = "defer", nonce }) {
|
206
|
+
_define_property._(this, "name", "RouterPlugin");
|
207
207
|
_define_property._(this, "HtmlBundlerPlugin", void 0);
|
208
208
|
_define_property._(this, "enableInlineRouteManifests", void 0);
|
209
209
|
_define_property._(this, "staticJsDir", void 0);
|
@@ -13,8 +13,7 @@ const _utils = require("@modern-js/utils");
|
|
13
13
|
const _routes = require("../utils/routes");
|
14
14
|
const _config = require("../utils/config");
|
15
15
|
const build = async (api, options) => {
|
16
|
-
|
17
|
-
if ((_options = options) === null || _options === void 0 ? void 0 : _options.analyze) {
|
16
|
+
if (options === null || options === void 0 ? void 0 : options.analyze) {
|
18
17
|
process.env.BUNDLE_ANALYZE = "true";
|
19
18
|
}
|
20
19
|
let resolvedConfig = api.useResolvedConfigContext();
|
@@ -50,7 +49,7 @@ const build = async (api, options) => {
|
|
50
49
|
distDirectory,
|
51
50
|
configFile: serverConfigFile
|
52
51
|
});
|
53
|
-
_utils.logger.info("
|
52
|
+
_utils.logger.info("Starting production build...");
|
54
53
|
if (!appContext.builder) {
|
55
54
|
throw new Error("Expect the Builder to have been initialized, But the appContext.builder received `undefined`");
|
56
55
|
}
|
@@ -10,7 +10,6 @@ Object.defineProperty(exports, "inspect", {
|
|
10
10
|
});
|
11
11
|
const _path = require("path");
|
12
12
|
const inspect = async (api, options) => {
|
13
|
-
var _appContext;
|
14
13
|
const appContext = api.useAppContext();
|
15
14
|
if (!appContext.builder) {
|
16
15
|
throw new Error("Expect the Builder to have been initialized, But the appContext.builder received `undefined`");
|
@@ -18,7 +17,7 @@ const inspect = async (api, options) => {
|
|
18
17
|
return appContext.builder.inspectConfig({
|
19
18
|
env: options.env,
|
20
19
|
verbose: options.verbose,
|
21
|
-
outputPath: (0, _path.join)(
|
20
|
+
outputPath: (0, _path.join)(appContext === null || appContext === void 0 ? void 0 : appContext.builder.context.distPath, options.output),
|
22
21
|
writeToDisk: true
|
23
22
|
});
|
24
23
|
};
|
@@ -15,13 +15,13 @@ const _printInstructions = require("../utils/printInstructions");
|
|
15
15
|
const _createServer = require("../utils/createServer");
|
16
16
|
const _getServerInternalPlugins = require("../utils/getServerInternalPlugins");
|
17
17
|
const start = async (api) => {
|
18
|
-
var _userConfig_source,
|
18
|
+
var _userConfig_source, _userConfig_output_distPath;
|
19
19
|
const appContext = api.useAppContext();
|
20
20
|
const userConfig = api.useResolvedConfigContext();
|
21
21
|
const hookRunners = api.useHookRunners();
|
22
22
|
const { appDirectory, port, serverConfigFile, metaName } = appContext;
|
23
|
-
_utils.logger.
|
24
|
-
const apiOnly = await (0, _utils.isApiOnly)(appContext.appDirectory,
|
23
|
+
_utils.logger.info(`Starting production server...`);
|
24
|
+
const apiOnly = await (0, _utils.isApiOnly)(appContext.appDirectory, userConfig === null || userConfig === void 0 ? void 0 : (_userConfig_source = userConfig.source) === null || _userConfig_source === void 0 ? void 0 : _userConfig_source.entriesDir, appContext.apiDirectory);
|
25
25
|
const serverInternalPlugins = await (0, _getServerInternalPlugins.getServerInternalPlugins)(api);
|
26
26
|
const app = await (0, _prodserver.default)({
|
27
27
|
pwd: appDirectory,
|