@modern-js/app-tools 2.39.2-alpha.0 → 2.39.2-alpha.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.
@@ -42,12 +42,20 @@ const ensureExtensions = (file) => {
42
42
  return file;
43
43
  };
44
44
  const isDirectory = (file) => !import_path.default.extname(file);
45
+ const isSubDirOrEqual = (parent, child) => {
46
+ if (parent === child) {
47
+ return true;
48
+ }
49
+ const relative = import_path.default.relative(parent, child);
50
+ const isSubdir = relative && !relative.startsWith("..") && !import_path.default.isAbsolute(relative);
51
+ return Boolean(isSubdir);
52
+ };
45
53
  const ifAlreadyExists = (entrypoints, checked) => entrypoints.some((entrypoint) => {
46
54
  if (ensureExtensions(entrypoint.entry) === ensureExtensions(checked.entry)) {
47
55
  checked.entryName = entrypoint.entryName;
48
56
  return true;
49
57
  }
50
- if (entrypoint.entry.startsWith(checked.entry) || checked.entry.startsWith(entrypoint.entry)) {
58
+ if (isSubDirOrEqual(entrypoint.entry, checked.entry) || isSubDirOrEqual(checked.entry, entrypoint.entry)) {
51
59
  throw new Error(`Entry configuration conflicts
52
60
  Your configuration: ${checked.entry}.
53
61
  Default entrypoint: ${entrypoint.entry}
@@ -79,7 +79,7 @@ const optimizeRoute = (routeTree) => {
79
79
  }
80
80
  const { children } = routeTree;
81
81
  const hasPage = children.some((child) => child.index);
82
- if (!routeTree._component && !routeTree.error && !routeTree.loading && !routeTree.config && !routeTree.clientData) {
82
+ if (!routeTree._component && !routeTree.error && !routeTree.loading && !routeTree.config && !routeTree.clientData && !hasPage) {
83
83
  const newRoutes = children.map((child) => {
84
84
  const routePath = `${routeTree.path ? routeTree.path : ""}${child.path ? `/${child.path}` : ""}`;
85
85
  const newRoute = {
@@ -285,7 +285,6 @@ const walk = async (dirname, rootDir, alias, entryName, isMainEntry, oldVersion)
285
285
  throw new Error("The root layout component is required, make sure the routes/layout.tsx file exists.");
286
286
  }
287
287
  if (isRoot && !oldVersion) {
288
- console.log("oooooooooooo");
289
288
  const optimizedRoutes = optimizeRoute(finalRoute);
290
289
  return optimizedRoutes;
291
290
  }
@@ -13,13 +13,21 @@ var ensureExtensions = function(file) {
13
13
  var isDirectory = function(file) {
14
14
  return !path.extname(file);
15
15
  };
16
+ var isSubDirOrEqual = function(parent, child) {
17
+ if (parent === child) {
18
+ return true;
19
+ }
20
+ var relative = path.relative(parent, child);
21
+ var isSubdir = relative && !relative.startsWith("..") && !path.isAbsolute(relative);
22
+ return Boolean(isSubdir);
23
+ };
16
24
  var ifAlreadyExists = function(entrypoints, checked) {
17
25
  return entrypoints.some(function(entrypoint) {
18
26
  if (ensureExtensions(entrypoint.entry) === ensureExtensions(checked.entry)) {
19
27
  checked.entryName = entrypoint.entryName;
20
28
  return true;
21
29
  }
22
- if (entrypoint.entry.startsWith(checked.entry) || checked.entry.startsWith(entrypoint.entry)) {
30
+ if (isSubDirOrEqual(entrypoint.entry, checked.entry) || isSubDirOrEqual(checked.entry, entrypoint.entry)) {
23
31
  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
32
  }
25
33
  return false;
@@ -48,7 +48,7 @@ var optimizeRoute = function(routeTree) {
48
48
  var hasPage = children.some(function(child) {
49
49
  return child.index;
50
50
  });
51
- if (!routeTree._component && !routeTree.error && !routeTree.loading && !routeTree.config && !routeTree.clientData) {
51
+ if (!routeTree._component && !routeTree.error && !routeTree.loading && !routeTree.config && !routeTree.clientData && !hasPage) {
52
52
  var newRoutes = children.map(function(child) {
53
53
  var routePath = "".concat(routeTree.path ? routeTree.path : "").concat(child.path ? "/".concat(child.path) : "");
54
54
  var newRoute = _object_spread_props(_object_spread({}, child), {
@@ -379,7 +379,6 @@ var walk = function() {
379
379
  throw new Error("The root layout component is required, make sure the routes/layout.tsx file exists.");
380
380
  }
381
381
  if (isRoot && !oldVersion) {
382
- console.log("oooooooooooo");
383
382
  optimizedRoutes = optimizeRoute(finalRoute);
384
383
  return [
385
384
  2,
@@ -9,12 +9,20 @@ const ensureExtensions = (file) => {
9
9
  return file;
10
10
  };
11
11
  const isDirectory = (file) => !path.extname(file);
12
+ const isSubDirOrEqual = (parent, child) => {
13
+ if (parent === child) {
14
+ return true;
15
+ }
16
+ const relative = path.relative(parent, child);
17
+ const isSubdir = relative && !relative.startsWith("..") && !path.isAbsolute(relative);
18
+ return Boolean(isSubdir);
19
+ };
12
20
  const ifAlreadyExists = (entrypoints, checked) => entrypoints.some((entrypoint) => {
13
21
  if (ensureExtensions(entrypoint.entry) === ensureExtensions(checked.entry)) {
14
22
  checked.entryName = entrypoint.entryName;
15
23
  return true;
16
24
  }
17
- if (entrypoint.entry.startsWith(checked.entry) || checked.entry.startsWith(entrypoint.entry)) {
25
+ if (isSubDirOrEqual(entrypoint.entry, checked.entry) || isSubDirOrEqual(checked.entry, entrypoint.entry)) {
18
26
  throw new Error(`Entry configuration conflicts
19
27
  Your configuration: ${checked.entry}.
20
28
  Default entrypoint: ${entrypoint.entry}
@@ -44,7 +44,7 @@ const optimizeRoute = (routeTree) => {
44
44
  }
45
45
  const { children } = routeTree;
46
46
  const hasPage = children.some((child) => child.index);
47
- if (!routeTree._component && !routeTree.error && !routeTree.loading && !routeTree.config && !routeTree.clientData) {
47
+ if (!routeTree._component && !routeTree.error && !routeTree.loading && !routeTree.config && !routeTree.clientData && !hasPage) {
48
48
  const newRoutes = children.map((child) => {
49
49
  const routePath = `${routeTree.path ? routeTree.path : ""}${child.path ? `/${child.path}` : ""}`;
50
50
  const newRoute = {
@@ -250,7 +250,6 @@ const walk = async (dirname, rootDir, alias, entryName, isMainEntry, oldVersion)
250
250
  throw new Error("The root layout component is required, make sure the routes/layout.tsx file exists.");
251
251
  }
252
252
  if (isRoot && !oldVersion) {
253
- console.log("oooooooooooo");
254
253
  const optimizedRoutes = optimizeRoute(finalRoute);
255
254
  return optimizedRoutes;
256
255
  }
package/package.json CHANGED
@@ -15,7 +15,7 @@
15
15
  "modern",
16
16
  "modern.js"
17
17
  ],
18
- "version": "2.39.2-alpha.0",
18
+ "version": "2.39.2-alpha.1",
19
19
  "jsnext:source": "./src/index.ts",
20
20
  "types": "./dist/types/index.d.ts",
21
21
  "main": "./dist/cjs/index.js",
@@ -77,19 +77,19 @@
77
77
  "@modern-js/builder-plugin-node-polyfill": "2.39.1",
78
78
  "@modern-js/builder-shared": "2.39.1",
79
79
  "@modern-js/builder-webpack-provider": "2.39.1",
80
- "@modern-js/new-action": "2.39.1",
81
80
  "@modern-js/core": "2.39.1",
81
+ "@modern-js/new-action": "2.39.1",
82
82
  "@modern-js/node-bundle-require": "2.39.1",
83
83
  "@modern-js/plugin": "2.39.1",
84
- "@modern-js/plugin-data-loader": "2.39.1",
85
84
  "@modern-js/plugin-i18n": "2.39.1",
85
+ "@modern-js/plugin-data-loader": "2.39.1",
86
86
  "@modern-js/plugin-lint": "2.39.1",
87
- "@modern-js/server": "2.39.1",
88
87
  "@modern-js/prod-server": "2.39.1",
89
- "@modern-js/types": "2.39.1",
90
- "@modern-js/server-core": "2.39.1",
88
+ "@modern-js/server": "2.39.1",
91
89
  "@modern-js/upgrade": "2.39.1",
92
- "@modern-js/utils": "2.39.1"
90
+ "@modern-js/types": "2.39.1",
91
+ "@modern-js/utils": "2.39.1",
92
+ "@modern-js/server-core": "2.39.1"
93
93
  },
94
94
  "devDependencies": {
95
95
  "@types/babel__traverse": "^7.14.2",
@@ -98,10 +98,10 @@
98
98
  "jest": "^29",
99
99
  "typescript": "^5",
100
100
  "webpack": "^5.88.1",
101
- "@scripts/build": "2.39.1",
102
101
  "@modern-js/builder-plugin-swc": "2.39.1",
103
- "@modern-js/builder-rspack-provider": "2.39.1",
104
- "@scripts/jest-config": "2.39.1"
102
+ "@scripts/build": "2.39.1",
103
+ "@scripts/jest-config": "2.39.1",
104
+ "@modern-js/builder-rspack-provider": "2.39.1"
105
105
  },
106
106
  "peerDependencies": {
107
107
  "@modern-js/builder-rspack-provider": "^2.39.1"