@modern-js/app-tools 2.39.2 → 2.41.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/dist/cjs/analyze/getBundleEntry.js +2 -1
- package/dist/cjs/analyze/getHtmlTemplate.js +5 -5
- package/dist/cjs/analyze/index.js +0 -8
- package/dist/cjs/analyze/nestedRoutes.js +1 -2
- package/dist/cjs/analyze/utils.js +10 -0
- package/dist/cjs/builder/shared/bundlerPlugins/RouterPlugin.js +1 -1
- package/dist/cjs/defineConfig.js +8 -6
- package/dist/cjs/initialize/index.js +0 -7
- package/dist/esm/analyze/getBundleEntry.js +2 -1
- package/dist/esm/analyze/getHtmlTemplate.js +5 -5
- package/dist/esm/analyze/index.js +0 -8
- package/dist/esm/analyze/nestedRoutes.js +1 -4
- package/dist/esm/analyze/utils.js +9 -0
- package/dist/esm/builder/shared/bundlerPlugins/RouterPlugin.js +1 -1
- package/dist/esm/config/initialize/inits.js +19 -19
- package/dist/esm/defineConfig.js +1 -1
- package/dist/esm/initialize/index.js +0 -7
- package/dist/esm-node/analyze/getBundleEntry.js +2 -1
- package/dist/esm-node/analyze/getHtmlTemplate.js +5 -5
- package/dist/esm-node/analyze/index.js +0 -8
- package/dist/esm-node/analyze/nestedRoutes.js +1 -2
- package/dist/esm-node/analyze/utils.js +9 -0
- package/dist/esm-node/builder/shared/bundlerPlugins/RouterPlugin.js +1 -1
- package/dist/esm-node/defineConfig.js +8 -6
- package/dist/esm-node/initialize/index.js +0 -7
- package/dist/types/analyze/utils.d.ts +2 -1
- package/package.json +26 -26
- package/dist/cjs/schema/Schema.js +0 -66
- package/dist/cjs/schema/index.js +0 -205
- package/dist/cjs/schema/legacy.js +0 -364
- package/dist/esm/schema/Schema.js +0 -82
- package/dist/esm/schema/index.js +0 -169
- package/dist/esm/schema/legacy.js +0 -333
- package/dist/esm-node/schema/Schema.js +0 -42
- package/dist/esm-node/schema/index.js +0 -170
- package/dist/esm-node/schema/legacy.js +0 -344
- package/dist/types/schema/Schema.d.ts +0 -14
- package/dist/types/schema/index.d.ts +0 -4
- package/dist/types/schema/legacy.d.ts +0 -3
@@ -35,6 +35,7 @@ var import_path = __toESM(require("path"));
|
|
35
35
|
var import_utils = require("@modern-js/utils");
|
36
36
|
var import_getFileSystemEntry = require("./getFileSystemEntry");
|
37
37
|
var import_constants = require("./constants");
|
38
|
+
var import_utils2 = require("./utils");
|
38
39
|
const ensureExtensions = (file) => {
|
39
40
|
if (!import_path.default.extname(file)) {
|
40
41
|
return (0, import_utils.findExists)(import_constants.JS_EXTENSIONS.map((ext) => `${file}${ext}`)) || file;
|
@@ -47,7 +48,7 @@ const ifAlreadyExists = (entrypoints, checked) => entrypoints.some((entrypoint)
|
|
47
48
|
checked.entryName = entrypoint.entryName;
|
48
49
|
return true;
|
49
50
|
}
|
50
|
-
if (entrypoint.entry
|
51
|
+
if ((0, import_utils2.isSubDirOrEqual)(entrypoint.entry, checked.entry) || (0, import_utils2.isSubDirOrEqual)(checked.entry, entrypoint.entry)) {
|
51
52
|
throw new Error(`Entry configuration conflicts
|
52
53
|
Your configuration: ${checked.entry}.
|
53
54
|
Default entrypoint: ${entrypoint.entry}
|
@@ -63,7 +63,7 @@ const getHtmlTemplate = async (entrypoints, api, { appContext, config }) => {
|
|
63
63
|
for (const entrypoint of entrypoints) {
|
64
64
|
const { entryName, isMainEntry } = entrypoint;
|
65
65
|
const name = entrypoints.length === 1 && isMainEntry ? "" : entryName;
|
66
|
-
const customIndexTemplate = findPartials(htmlDir, name,
|
66
|
+
const customIndexTemplate = findPartials(htmlDir, name, "index");
|
67
67
|
if (customIndexTemplate) {
|
68
68
|
htmlTemplates[entryName] = customIndexTemplate.file;
|
69
69
|
} else {
|
@@ -71,9 +71,9 @@ const getHtmlTemplate = async (entrypoints, api, { appContext, config }) => {
|
|
71
71
|
const { partials } = await hookRunners.htmlPartials({
|
72
72
|
entrypoint,
|
73
73
|
partials: [
|
74
|
-
|
75
|
-
|
76
|
-
|
74
|
+
"top",
|
75
|
+
"head",
|
76
|
+
"body"
|
77
77
|
].reduce((previous, position) => {
|
78
78
|
const found = findPartials(htmlDir, name, position);
|
79
79
|
previous[position] = found ? [
|
@@ -90,7 +90,7 @@ const getHtmlTemplate = async (entrypoints, api, { appContext, config }) => {
|
|
90
90
|
import_utils.fs.outputFileSync(templatePath, templates.html(partials), "utf8");
|
91
91
|
htmlTemplates[entryName] = templatePath;
|
92
92
|
partialsByEntrypoint[entryName] = partials;
|
93
|
-
const bottomTemplate = findPartials(htmlDir, name,
|
93
|
+
const bottomTemplate = findPartials(htmlDir, name, "bottom");
|
94
94
|
if (bottomTemplate) {
|
95
95
|
htmlTemplates[`__${entryName}-bottom__`] = bottomTemplate.content;
|
96
96
|
}
|
@@ -246,14 +246,6 @@ var analyze_default = ({ bundler }) => ({
|
|
246
246
|
imports
|
247
247
|
};
|
248
248
|
},
|
249
|
-
validateSchema() {
|
250
|
-
return {
|
251
|
-
target: "output.splitRouteChunks",
|
252
|
-
schema: {
|
253
|
-
type: "boolean"
|
254
|
-
}
|
255
|
-
};
|
256
|
-
},
|
257
249
|
async fileChange(e) {
|
258
250
|
const appContext = api.useAppContext();
|
259
251
|
const { appDirectory } = appContext;
|
@@ -78,8 +78,7 @@ const optimizeRoute = (routeTree) => {
|
|
78
78
|
];
|
79
79
|
}
|
80
80
|
const { children } = routeTree;
|
81
|
-
|
82
|
-
if (!routeTree._component && !routeTree.error && !routeTree.loading && !routeTree.config && !routeTree.clientData && !hasPage) {
|
81
|
+
if (!routeTree._component && !routeTree.error && !routeTree.loading && !routeTree.config && !routeTree.clientData) {
|
83
82
|
const newRoutes = children.map((child) => {
|
84
83
|
const routePath = `${routeTree.path ? routeTree.path : ""}${child.path ? `/${child.path}` : ""}`;
|
85
84
|
const newRoute = {
|
@@ -35,6 +35,7 @@ __export(utils_exports, {
|
|
35
35
|
hasAction: () => hasAction,
|
36
36
|
hasLoader: () => hasLoader,
|
37
37
|
isPageComponentFile: () => isPageComponentFile,
|
38
|
+
isSubDirOrEqual: () => isSubDirOrEqual,
|
38
39
|
parseModule: () => parseModule,
|
39
40
|
replaceWithAlias: () => replaceWithAlias,
|
40
41
|
walkDirectory: () => walkDirectory
|
@@ -211,6 +212,14 @@ const checkIsBuildCommands = () => {
|
|
211
212
|
const command = (0, import_utils.getCommand)();
|
212
213
|
return buildCommands.includes(command);
|
213
214
|
};
|
215
|
+
const isSubDirOrEqual = (parent, child) => {
|
216
|
+
if (parent === child) {
|
217
|
+
return true;
|
218
|
+
}
|
219
|
+
const relative = import_path.default.relative(parent, child);
|
220
|
+
const isSubdir = relative && !relative.startsWith("..") && !import_path.default.isAbsolute(relative);
|
221
|
+
return Boolean(isSubdir);
|
222
|
+
};
|
214
223
|
// Annotate the CommonJS export names for ESM import in node:
|
215
224
|
0 && (module.exports = {
|
216
225
|
checkIsBuildCommands,
|
@@ -220,6 +229,7 @@ const checkIsBuildCommands = () => {
|
|
220
229
|
hasAction,
|
221
230
|
hasLoader,
|
222
231
|
isPageComponentFile,
|
232
|
+
isSubDirOrEqual,
|
223
233
|
parseModule,
|
224
234
|
replaceWithAlias,
|
225
235
|
walkDirectory
|
@@ -62,7 +62,7 @@ class RouterPlugin {
|
|
62
62
|
return;
|
63
63
|
}
|
64
64
|
const { webpack } = compiler;
|
65
|
-
const isRspack = webpack
|
65
|
+
const isRspack = "rspackVersion" in webpack;
|
66
66
|
const { Compilation, sources } = webpack;
|
67
67
|
const { RawSource } = sources;
|
68
68
|
const normalizePath = (path) => {
|
package/dist/cjs/defineConfig.js
CHANGED
@@ -23,12 +23,14 @@ __export(defineConfig_exports, {
|
|
23
23
|
});
|
24
24
|
module.exports = __toCommonJS(defineConfig_exports);
|
25
25
|
const defineConfig = (config) => config;
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
26
|
+
const defineLegacyConfig = (config) => {
|
27
|
+
var _config_autoLoadPlugins;
|
28
|
+
return {
|
29
|
+
...config,
|
30
|
+
legacy: true,
|
31
|
+
autoLoadPlugins: (_config_autoLoadPlugins = config.autoLoadPlugins) !== null && _config_autoLoadPlugins !== void 0 ? _config_autoLoadPlugins : true
|
32
|
+
};
|
33
|
+
};
|
32
34
|
// Annotate the CommonJS export names for ESM import in node:
|
33
35
|
0 && (module.exports = {
|
34
36
|
defineConfig,
|
@@ -22,7 +22,6 @@ __export(initialize_exports, {
|
|
22
22
|
});
|
23
23
|
module.exports = __toCommonJS(initialize_exports);
|
24
24
|
var import_utils = require("@modern-js/utils");
|
25
|
-
var import_schema = require("../schema");
|
26
25
|
var import_config = require("../config");
|
27
26
|
var initialize_default = ({ bundler }) => ({
|
28
27
|
name: "@modern-js/plugin-initialize",
|
@@ -44,14 +43,8 @@ var initialize_default = ({ bundler }) => ({
|
|
44
43
|
});
|
45
44
|
return (0, import_config.checkIsLegacyConfig)(userConfig) ? (0, import_config.createLegacyDefaultConfig)(appContext) : (0, import_config.createDefaultConfig)(appContext, bundler);
|
46
45
|
};
|
47
|
-
const validateSchema = () => {
|
48
|
-
const userConfig = api.useConfigContext();
|
49
|
-
const schemas = (0, import_config.checkIsLegacyConfig)(userConfig) ? import_schema.legacySchema : import_schema.schema;
|
50
|
-
return schemas.generate();
|
51
|
-
};
|
52
46
|
return {
|
53
47
|
config,
|
54
|
-
validateSchema,
|
55
48
|
async resolvedConfig({ resolved }) {
|
56
49
|
var _resolved_output_distPath;
|
57
50
|
let appContext = api.useAppContext();
|
@@ -2,6 +2,7 @@ import path from "path";
|
|
2
2
|
import { ensureAbsolutePath, fs, findExists, MAIN_ENTRY_NAME, isRouterV5 } from "@modern-js/utils";
|
3
3
|
import { getFileSystemEntry } from "./getFileSystemEntry";
|
4
4
|
import { JS_EXTENSIONS } from "./constants";
|
5
|
+
import { isSubDirOrEqual } from "./utils";
|
5
6
|
var ensureExtensions = function(file) {
|
6
7
|
if (!path.extname(file)) {
|
7
8
|
return findExists(JS_EXTENSIONS.map(function(ext) {
|
@@ -19,7 +20,7 @@ var ifAlreadyExists = function(entrypoints, checked) {
|
|
19
20
|
checked.entryName = entrypoint.entryName;
|
20
21
|
return true;
|
21
22
|
}
|
22
|
-
if (entrypoint.entry
|
23
|
+
if (isSubDirOrEqual(entrypoint.entry, checked.entry) || isSubDirOrEqual(checked.entry, entrypoint.entry)) {
|
23
24
|
throw new Error("Entry configuration conflicts\n Your configuration: ".concat(checked.entry, ".\n Default entrypoint: ").concat(entrypoint.entry, "\n Please reset source.entries or set source.disableDefaultEntries to disable the default entry rules."));
|
24
25
|
}
|
25
26
|
return false;
|
@@ -59,7 +59,7 @@ var getHtmlTemplate = function() {
|
|
59
59
|
entrypoint = _step.value;
|
60
60
|
entryName = entrypoint.entryName, isMainEntry = entrypoint.isMainEntry;
|
61
61
|
name = entrypoints.length === 1 && isMainEntry ? "" : entryName;
|
62
|
-
customIndexTemplate = findPartials(htmlDir, name,
|
62
|
+
customIndexTemplate = findPartials(htmlDir, name, "index");
|
63
63
|
if (!customIndexTemplate)
|
64
64
|
return [
|
65
65
|
3,
|
@@ -77,9 +77,9 @@ var getHtmlTemplate = function() {
|
|
77
77
|
hookRunners.htmlPartials({
|
78
78
|
entrypoint,
|
79
79
|
partials: [
|
80
|
-
|
81
|
-
|
82
|
-
|
80
|
+
"top",
|
81
|
+
"head",
|
82
|
+
"body"
|
83
83
|
].reduce(function(previous, position) {
|
84
84
|
var found = findPartials(htmlDir, name, position);
|
85
85
|
previous[position] = found ? [
|
@@ -99,7 +99,7 @@ var getHtmlTemplate = function() {
|
|
99
99
|
fs.outputFileSync(templatePath, templates.html(partials), "utf8");
|
100
100
|
htmlTemplates[entryName] = templatePath;
|
101
101
|
partialsByEntrypoint[entryName] = partials;
|
102
|
-
bottomTemplate = findPartials(htmlDir, name,
|
102
|
+
bottomTemplate = findPartials(htmlDir, name, "bottom");
|
103
103
|
if (bottomTemplate) {
|
104
104
|
htmlTemplates["__".concat(entryName, "-bottom__")] = bottomTemplate.content;
|
105
105
|
}
|
@@ -457,14 +457,6 @@ function analyze_default(param) {
|
|
457
457
|
})();
|
458
458
|
}
|
459
459
|
),
|
460
|
-
validateSchema: function validateSchema() {
|
461
|
-
return {
|
462
|
-
target: "output.splitRouteChunks",
|
463
|
-
schema: {
|
464
|
-
type: "boolean"
|
465
|
-
}
|
466
|
-
};
|
467
|
-
},
|
468
460
|
fileChange: function fileChange(e) {
|
469
461
|
return _async_to_generator(function() {
|
470
462
|
var appContext, appDirectory, filename, eventType, isPageFile, absoluteFilePath, isRouteComponent, resolvedConfig, generateCode, entrypoints;
|
@@ -45,10 +45,7 @@ var optimizeRoute = function(routeTree) {
|
|
45
45
|
];
|
46
46
|
}
|
47
47
|
var children = routeTree.children;
|
48
|
-
|
49
|
-
return child.index;
|
50
|
-
});
|
51
|
-
if (!routeTree._component && !routeTree.error && !routeTree.loading && !routeTree.config && !routeTree.clientData && !hasPage) {
|
48
|
+
if (!routeTree._component && !routeTree.error && !routeTree.loading && !routeTree.config && !routeTree.clientData) {
|
52
49
|
var newRoutes = children.map(function(child) {
|
53
50
|
var routePath = "".concat(routeTree.path ? routeTree.path : "").concat(child.path ? "/".concat(child.path) : "");
|
54
51
|
var newRoute = _object_spread_props(_object_spread({}, child), {
|
@@ -286,6 +286,14 @@ var checkIsBuildCommands = function() {
|
|
286
286
|
var command = getCommand();
|
287
287
|
return buildCommands.includes(command);
|
288
288
|
};
|
289
|
+
var isSubDirOrEqual = function(parent, child) {
|
290
|
+
if (parent === child) {
|
291
|
+
return true;
|
292
|
+
}
|
293
|
+
var relative = path.relative(parent, child);
|
294
|
+
var isSubdir = relative && !relative.startsWith("..") && !path.isAbsolute(relative);
|
295
|
+
return Boolean(isSubdir);
|
296
|
+
};
|
289
297
|
export {
|
290
298
|
checkIsBuildCommands,
|
291
299
|
getDefaultImports,
|
@@ -294,6 +302,7 @@ export {
|
|
294
302
|
hasAction,
|
295
303
|
hasLoader,
|
296
304
|
isPageComponentFile,
|
305
|
+
isSubDirOrEqual,
|
297
306
|
parseModule,
|
298
307
|
replaceWithAlias,
|
299
308
|
walkDirectory
|
@@ -80,7 +80,7 @@ var RouterPlugin = /* @__PURE__ */ function() {
|
|
80
80
|
return;
|
81
81
|
}
|
82
82
|
var webpack = compiler.webpack;
|
83
|
-
var isRspack = webpack
|
83
|
+
var isRspack = "rspackVersion" in webpack;
|
84
84
|
var Compilation = webpack.Compilation, sources = webpack.sources;
|
85
85
|
var RawSource = sources.RawSource;
|
86
86
|
var normalizePath = function(path) {
|
@@ -1,31 +1,31 @@
|
|
1
1
|
import path, { isAbsolute } from "path";
|
2
2
|
import { findExists } from "@modern-js/utils";
|
3
3
|
function initHtmlConfig(config, appContext) {
|
4
|
-
var
|
4
|
+
var ICON_EXTENSIONS = [
|
5
|
+
"png",
|
6
|
+
"jpg",
|
7
|
+
"jpeg",
|
8
|
+
"svg",
|
9
|
+
"ico"
|
10
|
+
];
|
11
|
+
config.html.appIcon = createBuilderAppIcon(config, appContext);
|
12
|
+
config.html.favicon = createBuilderFavicon(config, appContext);
|
13
|
+
return config.html;
|
14
|
+
function createBuilderAppIcon(config2, appContext2) {
|
5
15
|
var configDir = config2.source.configDir;
|
6
16
|
var appIcon = findExists(ICON_EXTENSIONS.map(function(ext) {
|
7
17
|
return path.resolve(appContext2.appDirectory, configDir || "./config", "icon.".concat(ext));
|
8
18
|
}));
|
9
19
|
return typeof appIcon === "string" ? appIcon : void 0;
|
10
|
-
}
|
11
|
-
|
20
|
+
}
|
21
|
+
function createBuilderFavicon(config2, appContext2) {
|
12
22
|
var configDir = config2.source.configDir;
|
13
23
|
var favicon = config2.html.favicon;
|
14
24
|
var defaultFavicon = findExists(ICON_EXTENSIONS.map(function(ext) {
|
15
25
|
return path.resolve(appContext2.appDirectory, configDir || "./config", "favicon.".concat(ext));
|
16
26
|
}));
|
17
27
|
return favicon || defaultFavicon || void 0;
|
18
|
-
}
|
19
|
-
var ICON_EXTENSIONS = [
|
20
|
-
"png",
|
21
|
-
"jpg",
|
22
|
-
"jpeg",
|
23
|
-
"svg",
|
24
|
-
"ico"
|
25
|
-
];
|
26
|
-
config.html.appIcon = createBuilderAppIcon(config, appContext);
|
27
|
-
config.html.favicon = createBuilderFavicon(config, appContext);
|
28
|
-
return config.html;
|
28
|
+
}
|
29
29
|
}
|
30
30
|
function initSourceConfig(config, appContext, bundler) {
|
31
31
|
config.source.include = createBuilderInclude(config, appContext);
|
@@ -50,11 +50,6 @@ function createBuilderInclude(config, appContext) {
|
|
50
50
|
return transformInclude;
|
51
51
|
}
|
52
52
|
function createBuilderModuleScope(config) {
|
53
|
-
var isPrimitiveScope = function isPrimitiveScope2(items) {
|
54
|
-
return items.every(function(item) {
|
55
|
-
return typeof item === "string" || Object.prototype.toString.call(item) === "[object RegExp]";
|
56
|
-
});
|
57
|
-
};
|
58
53
|
var moduleScopes = config.source.moduleScopes;
|
59
54
|
if (moduleScopes) {
|
60
55
|
var DEFAULT_SCOPES = [
|
@@ -67,6 +62,11 @@ function createBuilderModuleScope(config) {
|
|
67
62
|
} else {
|
68
63
|
return void 0;
|
69
64
|
}
|
65
|
+
function isPrimitiveScope(items) {
|
66
|
+
return items.every(function(item) {
|
67
|
+
return typeof item === "string" || Object.prototype.toString.call(item) === "[object RegExp]";
|
68
|
+
});
|
69
|
+
}
|
70
70
|
function applyScopeOptions(defaults, options) {
|
71
71
|
if (Array.isArray(options)) {
|
72
72
|
if (isPrimitiveScope(options)) {
|
package/dist/esm/defineConfig.js
CHANGED
@@ -3,8 +3,8 @@ import { _ as _object_spread_props } from "@swc/helpers/_/_object_spread_props";
|
|
3
3
|
var defineConfig = function(config) {
|
4
4
|
return config;
|
5
5
|
};
|
6
|
-
var _config_autoLoadPlugins;
|
7
6
|
var defineLegacyConfig = function(config) {
|
7
|
+
var _config_autoLoadPlugins;
|
8
8
|
return _object_spread_props(_object_spread({}, config), {
|
9
9
|
legacy: true,
|
10
10
|
autoLoadPlugins: (_config_autoLoadPlugins = config.autoLoadPlugins) !== null && _config_autoLoadPlugins !== void 0 ? _config_autoLoadPlugins : true
|
@@ -3,7 +3,6 @@ import { _ as _object_spread } from "@swc/helpers/_/_object_spread";
|
|
3
3
|
import { _ as _object_spread_props } from "@swc/helpers/_/_object_spread_props";
|
4
4
|
import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
|
5
5
|
import { ensureAbsolutePath, getPort, isDev, isDevCommand } from "@modern-js/utils";
|
6
|
-
import { legacySchema, schema } from "../schema";
|
7
6
|
import { checkIsLegacyConfig, createDefaultConfig, createLegacyDefaultConfig, transformNormalizedConfig } from "../config";
|
8
7
|
function initialize_default(param) {
|
9
8
|
var bundler = param.bundler;
|
@@ -26,14 +25,8 @@ function initialize_default(param) {
|
|
26
25
|
}));
|
27
26
|
return checkIsLegacyConfig(userConfig) ? createLegacyDefaultConfig(appContext) : createDefaultConfig(appContext, bundler);
|
28
27
|
};
|
29
|
-
var validateSchema = function() {
|
30
|
-
var userConfig = api.useConfigContext();
|
31
|
-
var schemas = checkIsLegacyConfig(userConfig) ? legacySchema : schema;
|
32
|
-
return schemas.generate();
|
33
|
-
};
|
34
28
|
return {
|
35
29
|
config,
|
36
|
-
validateSchema,
|
37
30
|
resolvedConfig: function resolvedConfig(param2) {
|
38
31
|
var resolved = param2.resolved;
|
39
32
|
return _async_to_generator(function() {
|
@@ -2,6 +2,7 @@ import path from "path";
|
|
2
2
|
import { ensureAbsolutePath, fs, findExists, MAIN_ENTRY_NAME, isRouterV5 } from "@modern-js/utils";
|
3
3
|
import { getFileSystemEntry } from "./getFileSystemEntry";
|
4
4
|
import { JS_EXTENSIONS } from "./constants";
|
5
|
+
import { isSubDirOrEqual } from "./utils";
|
5
6
|
const ensureExtensions = (file) => {
|
6
7
|
if (!path.extname(file)) {
|
7
8
|
return findExists(JS_EXTENSIONS.map((ext) => `${file}${ext}`)) || file;
|
@@ -14,7 +15,7 @@ const ifAlreadyExists = (entrypoints, checked) => entrypoints.some((entrypoint)
|
|
14
15
|
checked.entryName = entrypoint.entryName;
|
15
16
|
return true;
|
16
17
|
}
|
17
|
-
if (entrypoint.entry
|
18
|
+
if (isSubDirOrEqual(entrypoint.entry, checked.entry) || isSubDirOrEqual(checked.entry, entrypoint.entry)) {
|
18
19
|
throw new Error(`Entry configuration conflicts
|
19
20
|
Your configuration: ${checked.entry}.
|
20
21
|
Default entrypoint: ${entrypoint.entry}
|
@@ -30,7 +30,7 @@ const getHtmlTemplate = async (entrypoints, api, { appContext, config }) => {
|
|
30
30
|
for (const entrypoint of entrypoints) {
|
31
31
|
const { entryName, isMainEntry } = entrypoint;
|
32
32
|
const name = entrypoints.length === 1 && isMainEntry ? "" : entryName;
|
33
|
-
const customIndexTemplate = findPartials(htmlDir, name,
|
33
|
+
const customIndexTemplate = findPartials(htmlDir, name, "index");
|
34
34
|
if (customIndexTemplate) {
|
35
35
|
htmlTemplates[entryName] = customIndexTemplate.file;
|
36
36
|
} else {
|
@@ -38,9 +38,9 @@ const getHtmlTemplate = async (entrypoints, api, { appContext, config }) => {
|
|
38
38
|
const { partials } = await hookRunners.htmlPartials({
|
39
39
|
entrypoint,
|
40
40
|
partials: [
|
41
|
-
|
42
|
-
|
43
|
-
|
41
|
+
"top",
|
42
|
+
"head",
|
43
|
+
"body"
|
44
44
|
].reduce((previous, position) => {
|
45
45
|
const found = findPartials(htmlDir, name, position);
|
46
46
|
previous[position] = found ? [
|
@@ -57,7 +57,7 @@ const getHtmlTemplate = async (entrypoints, api, { appContext, config }) => {
|
|
57
57
|
fs.outputFileSync(templatePath, templates.html(partials), "utf8");
|
58
58
|
htmlTemplates[entryName] = templatePath;
|
59
59
|
partialsByEntrypoint[entryName] = partials;
|
60
|
-
const bottomTemplate = findPartials(htmlDir, name,
|
60
|
+
const bottomTemplate = findPartials(htmlDir, name, "bottom");
|
61
61
|
if (bottomTemplate) {
|
62
62
|
htmlTemplates[`__${entryName}-bottom__`] = bottomTemplate.content;
|
63
63
|
}
|
@@ -213,14 +213,6 @@ var analyze_default = ({ bundler }) => ({
|
|
213
213
|
imports
|
214
214
|
};
|
215
215
|
},
|
216
|
-
validateSchema() {
|
217
|
-
return {
|
218
|
-
target: "output.splitRouteChunks",
|
219
|
-
schema: {
|
220
|
-
type: "boolean"
|
221
|
-
}
|
222
|
-
};
|
223
|
-
},
|
224
216
|
async fileChange(e) {
|
225
217
|
const appContext = api.useAppContext();
|
226
218
|
const { appDirectory } = appContext;
|
@@ -43,8 +43,7 @@ const optimizeRoute = (routeTree) => {
|
|
43
43
|
];
|
44
44
|
}
|
45
45
|
const { children } = routeTree;
|
46
|
-
|
47
|
-
if (!routeTree._component && !routeTree.error && !routeTree.loading && !routeTree.config && !routeTree.clientData && !hasPage) {
|
46
|
+
if (!routeTree._component && !routeTree.error && !routeTree.loading && !routeTree.config && !routeTree.clientData) {
|
48
47
|
const newRoutes = children.map((child) => {
|
49
48
|
const routePath = `${routeTree.path ? routeTree.path : ""}${child.path ? `/${child.path}` : ""}`;
|
50
49
|
const newRoute = {
|
@@ -169,6 +169,14 @@ const checkIsBuildCommands = () => {
|
|
169
169
|
const command = getCommand();
|
170
170
|
return buildCommands.includes(command);
|
171
171
|
};
|
172
|
+
const isSubDirOrEqual = (parent, child) => {
|
173
|
+
if (parent === child) {
|
174
|
+
return true;
|
175
|
+
}
|
176
|
+
const relative = path.relative(parent, child);
|
177
|
+
const isSubdir = relative && !relative.startsWith("..") && !path.isAbsolute(relative);
|
178
|
+
return Boolean(isSubdir);
|
179
|
+
};
|
172
180
|
export {
|
173
181
|
checkIsBuildCommands,
|
174
182
|
getDefaultImports,
|
@@ -177,6 +185,7 @@ export {
|
|
177
185
|
hasAction,
|
178
186
|
hasLoader,
|
179
187
|
isPageComponentFile,
|
188
|
+
isSubDirOrEqual,
|
180
189
|
parseModule,
|
181
190
|
replaceWithAlias,
|
182
191
|
walkDirectory
|
@@ -39,7 +39,7 @@ class RouterPlugin {
|
|
39
39
|
return;
|
40
40
|
}
|
41
41
|
const { webpack } = compiler;
|
42
|
-
const isRspack = webpack
|
42
|
+
const isRspack = "rspackVersion" in webpack;
|
43
43
|
const { Compilation, sources } = webpack;
|
44
44
|
const { RawSource } = sources;
|
45
45
|
const normalizePath = (path) => {
|
@@ -1,10 +1,12 @@
|
|
1
1
|
const defineConfig = (config) => config;
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
2
|
+
const defineLegacyConfig = (config) => {
|
3
|
+
var _config_autoLoadPlugins;
|
4
|
+
return {
|
5
|
+
...config,
|
6
|
+
legacy: true,
|
7
|
+
autoLoadPlugins: (_config_autoLoadPlugins = config.autoLoadPlugins) !== null && _config_autoLoadPlugins !== void 0 ? _config_autoLoadPlugins : true
|
8
|
+
};
|
9
|
+
};
|
8
10
|
export {
|
9
11
|
defineConfig,
|
10
12
|
defineLegacyConfig
|
@@ -1,5 +1,4 @@
|
|
1
1
|
import { ensureAbsolutePath, getPort, isDev, isDevCommand } from "@modern-js/utils";
|
2
|
-
import { legacySchema, schema } from "../schema";
|
3
2
|
import { checkIsLegacyConfig, createDefaultConfig, createLegacyDefaultConfig, transformNormalizedConfig } from "../config";
|
4
3
|
var initialize_default = ({ bundler }) => ({
|
5
4
|
name: "@modern-js/plugin-initialize",
|
@@ -21,14 +20,8 @@ var initialize_default = ({ bundler }) => ({
|
|
21
20
|
});
|
22
21
|
return checkIsLegacyConfig(userConfig) ? createLegacyDefaultConfig(appContext) : createDefaultConfig(appContext, bundler);
|
23
22
|
};
|
24
|
-
const validateSchema = () => {
|
25
|
-
const userConfig = api.useConfigContext();
|
26
|
-
const schemas = checkIsLegacyConfig(userConfig) ? legacySchema : schema;
|
27
|
-
return schemas.generate();
|
28
|
-
};
|
29
23
|
return {
|
30
24
|
config,
|
31
|
-
validateSchema,
|
32
25
|
async resolvedConfig({ resolved }) {
|
33
26
|
var _resolved_output_distPath;
|
34
27
|
let appContext = api.useAppContext();
|
@@ -27,4 +27,5 @@ export declare const hasLoader: (filename: string, source?: string) => Promise<b
|
|
27
27
|
export declare const hasAction: (filename: string, source?: string) => Promise<boolean>;
|
28
28
|
export declare const getServerLoadersFile: (internalDirectory: string, entryName: string) => string;
|
29
29
|
export declare const getServerCombinedModueFile: (internalDirectory: string, entryName: string) => string;
|
30
|
-
export declare const checkIsBuildCommands: () => boolean;
|
30
|
+
export declare const checkIsBuildCommands: () => boolean;
|
31
|
+
export declare const isSubDirOrEqual: (parent: string, child: string) => boolean;
|
package/package.json
CHANGED
@@ -15,7 +15,7 @@
|
|
15
15
|
"modern",
|
16
16
|
"modern.js"
|
17
17
|
],
|
18
|
-
"version": "2.
|
18
|
+
"version": "2.41.0",
|
19
19
|
"jsnext:source": "./src/index.ts",
|
20
20
|
"types": "./dist/types/index.d.ts",
|
21
21
|
"main": "./dist/cjs/index.js",
|
@@ -71,40 +71,40 @@
|
|
71
71
|
"@babel/types": "^7.22.15",
|
72
72
|
"es-module-lexer": "^1.1.0",
|
73
73
|
"esbuild": "0.17.19",
|
74
|
-
"@swc/helpers": "0.5.
|
75
|
-
"@modern-js/builder": "2.
|
76
|
-
"@modern-js/builder-plugin-esbuild": "2.
|
77
|
-
"@modern-js/builder-plugin-node-polyfill": "2.
|
78
|
-
"@modern-js/builder-shared": "2.
|
79
|
-
"@modern-js/builder-webpack-provider": "2.
|
80
|
-
"@modern-js/
|
81
|
-
"@modern-js/
|
82
|
-
"@modern-js/
|
83
|
-
"@modern-js/plugin-data-loader": "2.
|
84
|
-
"@modern-js/plugin": "2.
|
85
|
-
"@modern-js/
|
86
|
-
"@modern-js/plugin-lint": "2.
|
87
|
-
"@modern-js/prod-server": "2.
|
88
|
-
"@modern-js/server": "2.
|
89
|
-
"@modern-js/types": "2.
|
90
|
-
"@modern-js/
|
91
|
-
"@modern-js/
|
92
|
-
"@modern-js/
|
74
|
+
"@swc/helpers": "0.5.3",
|
75
|
+
"@modern-js/builder": "2.41.0",
|
76
|
+
"@modern-js/builder-plugin-esbuild": "2.41.0",
|
77
|
+
"@modern-js/builder-plugin-node-polyfill": "2.41.0",
|
78
|
+
"@modern-js/builder-shared": "2.41.0",
|
79
|
+
"@modern-js/builder-webpack-provider": "2.41.0",
|
80
|
+
"@modern-js/new-action": "2.41.0",
|
81
|
+
"@modern-js/plugin": "2.41.0",
|
82
|
+
"@modern-js/core": "2.41.0",
|
83
|
+
"@modern-js/plugin-data-loader": "2.41.0",
|
84
|
+
"@modern-js/plugin-i18n": "2.41.0",
|
85
|
+
"@modern-js/node-bundle-require": "2.41.0",
|
86
|
+
"@modern-js/plugin-lint": "2.41.0",
|
87
|
+
"@modern-js/prod-server": "2.41.0",
|
88
|
+
"@modern-js/server": "2.41.0",
|
89
|
+
"@modern-js/types": "2.41.0",
|
90
|
+
"@modern-js/utils": "2.41.0",
|
91
|
+
"@modern-js/server-core": "2.41.0",
|
92
|
+
"@modern-js/upgrade": "2.41.0"
|
93
93
|
},
|
94
94
|
"devDependencies": {
|
95
|
-
"@types/babel__traverse": "
|
95
|
+
"@types/babel__traverse": "7.18.5",
|
96
96
|
"@types/jest": "^29",
|
97
97
|
"@types/node": "^14",
|
98
98
|
"jest": "^29",
|
99
99
|
"typescript": "^5",
|
100
100
|
"webpack": "^5.88.1",
|
101
|
-
"@modern-js/builder-
|
102
|
-
"@modern-js/builder-
|
103
|
-
"@scripts/
|
104
|
-
"@scripts/
|
101
|
+
"@modern-js/builder-rspack-provider": "2.41.0",
|
102
|
+
"@modern-js/builder-plugin-swc": "2.41.0",
|
103
|
+
"@scripts/jest-config": "2.41.0",
|
104
|
+
"@scripts/build": "2.41.0"
|
105
105
|
},
|
106
106
|
"peerDependencies": {
|
107
|
-
"@modern-js/builder-rspack-provider": "^2.
|
107
|
+
"@modern-js/builder-rspack-provider": "^2.41.0"
|
108
108
|
},
|
109
109
|
"peerDependenciesMeta": {
|
110
110
|
"@modern-js/builder-rspack-provider": {
|