@modern-js/app-tools 2.3.0 → 2.3.1-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.
@@ -23,7 +23,9 @@ const NESTED_ROUTE = {
23
23
  PAGE_LOADER_FILE: "page.loader",
24
24
  LOADING_FILE: "loading",
25
25
  ERROR_FILE: "error",
26
- LOADER_FILE: "loader"
26
+ LOADER_FILE: "loader",
27
+ SPLATE_FILE: "$",
28
+ SPLATE_LOADER_FILE: "$.loader"
27
29
  };
28
30
  const APP_CONFIG_NAME = "config";
29
31
  const APP_INIT_EXPORTED = "init";
@@ -64,7 +64,7 @@ const createRoute = (routeInfo, rootDir, filename, entryName) => {
64
64
  });
65
65
  };
66
66
  const walk = (dirname, rootDir, alias, entryName) => __async(void 0, null, function* () {
67
- var _a, _b, _c;
67
+ var _a, _b, _c, _d;
68
68
  if (!(yield fs.pathExists(dirname))) {
69
69
  return null;
70
70
  }
@@ -90,6 +90,8 @@ const walk = (dirname, rootDir, alias, entryName) => __async(void 0, null, funct
90
90
  };
91
91
  let pageLoaderFile = "";
92
92
  let pageRoute = null;
93
+ let splatLoaderFile = "";
94
+ let splatRoute = null;
93
95
  const items = yield fs.readdir(dirname);
94
96
  for (const item of items) {
95
97
  const itemPath = path.join(dirname, item);
@@ -130,6 +132,24 @@ const walk = (dirname, rootDir, alias, entryName) => __async(void 0, null, funct
130
132
  }
131
133
  (_b = route.children) == null ? void 0 : _b.push(pageRoute);
132
134
  }
135
+ if (itemWithoutExt === NESTED_ROUTE.SPLATE_LOADER_FILE) {
136
+ splatLoaderFile = itemPath;
137
+ }
138
+ if (itemWithoutExt === NESTED_ROUTE.SPLATE_FILE) {
139
+ splatRoute = createRoute(
140
+ {
141
+ _component: replaceWithAlias(alias.basename, itemPath, alias.name),
142
+ path: "*"
143
+ },
144
+ rootDir,
145
+ itemPath,
146
+ entryName
147
+ );
148
+ if (splatLoaderFile) {
149
+ splatRoute.loader = splatLoaderFile;
150
+ }
151
+ (_c = route.children) == null ? void 0 : _c.push(splatRoute);
152
+ }
133
153
  if (itemWithoutExt === NESTED_ROUTE.LOADING_FILE) {
134
154
  route.loading = replaceWithAlias(alias.basename, itemPath, alias.name);
135
155
  }
@@ -146,7 +166,7 @@ const walk = (dirname, rootDir, alias, entryName) => __async(void 0, null, funct
146
166
  if (isPathlessLayout) {
147
167
  delete finalRoute.path;
148
168
  }
149
- route.children = (_c = route.children) == null ? void 0 : _c.filter((childRoute) => childRoute);
169
+ route.children = (_d = route.children) == null ? void 0 : _d.filter((childRoute) => childRoute);
150
170
  if (route.children && route.children.length === 0 && !route.index) {
151
171
  return null;
152
172
  }
@@ -66,7 +66,9 @@ const NESTED_ROUTE = {
66
66
  PAGE_LOADER_FILE: "page.loader",
67
67
  LOADING_FILE: "loading",
68
68
  ERROR_FILE: "error",
69
- LOADER_FILE: "loader"
69
+ LOADER_FILE: "loader",
70
+ SPLATE_FILE: "$",
71
+ SPLATE_LOADER_FILE: "$.loader"
70
72
  };
71
73
  const APP_CONFIG_NAME = "config";
72
74
  const APP_INIT_EXPORTED = "init";
@@ -90,7 +90,7 @@ const createRoute = (routeInfo, rootDir, filename, entryName) => {
90
90
  });
91
91
  };
92
92
  const walk = (dirname, rootDir, alias, entryName) => __async(void 0, null, function* () {
93
- var _a, _b, _c;
93
+ var _a, _b, _c, _d;
94
94
  if (!(yield import_utils.fs.pathExists(dirname))) {
95
95
  return null;
96
96
  }
@@ -116,6 +116,8 @@ const walk = (dirname, rootDir, alias, entryName) => __async(void 0, null, funct
116
116
  };
117
117
  let pageLoaderFile = "";
118
118
  let pageRoute = null;
119
+ let splatLoaderFile = "";
120
+ let splatRoute = null;
119
121
  const items = yield import_utils.fs.readdir(dirname);
120
122
  for (const item of items) {
121
123
  const itemPath = path.join(dirname, item);
@@ -156,6 +158,24 @@ const walk = (dirname, rootDir, alias, entryName) => __async(void 0, null, funct
156
158
  }
157
159
  (_b = route.children) == null ? void 0 : _b.push(pageRoute);
158
160
  }
161
+ if (itemWithoutExt === import_constants.NESTED_ROUTE.SPLATE_LOADER_FILE) {
162
+ splatLoaderFile = itemPath;
163
+ }
164
+ if (itemWithoutExt === import_constants.NESTED_ROUTE.SPLATE_FILE) {
165
+ splatRoute = createRoute(
166
+ {
167
+ _component: (0, import_utils2.replaceWithAlias)(alias.basename, itemPath, alias.name),
168
+ path: "*"
169
+ },
170
+ rootDir,
171
+ itemPath,
172
+ entryName
173
+ );
174
+ if (splatLoaderFile) {
175
+ splatRoute.loader = splatLoaderFile;
176
+ }
177
+ (_c = route.children) == null ? void 0 : _c.push(splatRoute);
178
+ }
159
179
  if (itemWithoutExt === import_constants.NESTED_ROUTE.LOADING_FILE) {
160
180
  route.loading = (0, import_utils2.replaceWithAlias)(alias.basename, itemPath, alias.name);
161
181
  }
@@ -172,7 +192,7 @@ const walk = (dirname, rootDir, alias, entryName) => __async(void 0, null, funct
172
192
  if (isPathlessLayout) {
173
193
  delete finalRoute.path;
174
194
  }
175
- route.children = (_c = route.children) == null ? void 0 : _c.filter((childRoute) => childRoute);
195
+ route.children = (_d = route.children) == null ? void 0 : _d.filter((childRoute) => childRoute);
176
196
  if (route.children && route.children.length === 0 && !route.index) {
177
197
  return null;
178
198
  }
@@ -32,7 +32,9 @@ var NESTED_ROUTE = {
32
32
  PAGE_LOADER_FILE: "page.loader",
33
33
  LOADING_FILE: "loading",
34
34
  ERROR_FILE: "error",
35
- LOADER_FILE: "loader"
35
+ LOADER_FILE: "loader",
36
+ SPLATE_FILE: "$",
37
+ SPLATE_LOADER_FILE: "$.loader"
36
38
  };
37
39
  var APP_CONFIG_NAME = "config";
38
40
  var APP_INIT_EXPORTED = "init";
@@ -197,7 +197,7 @@ var createRoute = function(routeInfo, rootDir, filename, entryName) {
197
197
  };
198
198
  var walk = function() {
199
199
  var _ref = _asyncToGenerator(function(dirname, rootDir, alias, entryName) {
200
- var ref, isDirectory, relativeDir, pathSegments, lastSegment, isRoot, isPathlessLayout, isWithoutLayoutPath, routePath, route, pageLoaderFile, pageRoute, items, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, item, itemPath, extname, itemWithoutExt, isDirectory2, childRoute, ref1, ref2, err, finalRoute;
200
+ var ref, isDirectory, relativeDir, pathSegments, lastSegment, isRoot, isPathlessLayout, isWithoutLayoutPath, routePath, route, pageLoaderFile, pageRoute, splatLoaderFile, splatRoute, items, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, item, itemPath, extname, itemWithoutExt, isDirectory2, childRoute, ref1, ref2, ref3, err, finalRoute;
201
201
  return __generator(this, function(_state) {
202
202
  switch(_state.label){
203
203
  case 0:
@@ -242,6 +242,8 @@ var walk = function() {
242
242
  };
243
243
  pageLoaderFile = "";
244
244
  pageRoute = null;
245
+ splatLoaderFile = "";
246
+ splatRoute = null;
245
247
  return [
246
248
  4,
247
249
  fs.readdir(dirname)
@@ -317,6 +319,20 @@ var walk = function() {
317
319
  }
318
320
  (ref2 = route.children) === null || ref2 === void 0 ? void 0 : ref2.push(pageRoute);
319
321
  }
322
+ if (itemWithoutExt === NESTED_ROUTE.SPLATE_LOADER_FILE) {
323
+ splatLoaderFile = itemPath;
324
+ }
325
+ if (itemWithoutExt === NESTED_ROUTE.SPLATE_FILE) {
326
+ ;
327
+ splatRoute = createRoute({
328
+ _component: replaceWithAlias(alias.basename, itemPath, alias.name),
329
+ path: "*"
330
+ }, rootDir, itemPath, entryName);
331
+ if (splatLoaderFile) {
332
+ splatRoute.loader = splatLoaderFile;
333
+ }
334
+ (ref3 = route.children) === null || ref3 === void 0 ? void 0 : ref3.push(splatRoute);
335
+ }
320
336
  if (itemWithoutExt === NESTED_ROUTE.LOADING_FILE) {
321
337
  route.loading = replaceWithAlias(alias.basename, itemPath, alias.name);
322
338
  }
@@ -24,6 +24,8 @@ export declare const NESTED_ROUTE: {
24
24
  LOADING_FILE: string;
25
25
  ERROR_FILE: string;
26
26
  LOADER_FILE: string;
27
+ SPLATE_FILE: string;
28
+ SPLATE_LOADER_FILE: string;
27
29
  };
28
30
  export declare const APP_CONFIG_NAME = "config";
29
31
  export declare const APP_INIT_EXPORTED = "init";
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "modern",
12
12
  "modern.js"
13
13
  ],
14
- "version": "2.3.0",
14
+ "version": "2.3.1-alpha.1",
15
15
  "jsnext:source": "./src/index.ts",
16
16
  "types": "./dist/types/index.d.ts",
17
17
  "main": "./dist/js/node/index.js",
@@ -63,8 +63,6 @@
63
63
  "@babel/runtime": "^7.18.0",
64
64
  "@babel/traverse": "^7.18.0",
65
65
  "@babel/types": "^7.18.0",
66
- "es-module-lexer": "^1.1.0",
67
- "esbuild": "0.15.7",
68
66
  "@modern-js/builder": "2.3.0",
69
67
  "@modern-js/builder-plugin-esbuild": "2.3.0",
70
68
  "@modern-js/builder-plugin-node-polyfill": "2.3.0",
@@ -81,19 +79,21 @@
81
79
  "@modern-js/server": "2.3.0",
82
80
  "@modern-js/types": "2.3.0",
83
81
  "@modern-js/upgrade": "2.3.0",
84
- "@modern-js/utils": "2.3.0"
82
+ "@modern-js/utils": "2.3.0",
83
+ "es-module-lexer": "^1.1.0",
84
+ "esbuild": "0.15.7"
85
85
  },
86
86
  "devDependencies": {
87
+ "@modern-js/builder-plugin-swc": "2.3.0",
88
+ "@modern-js/server-core": "2.3.0",
89
+ "@scripts/build": "2.3.0",
90
+ "@scripts/jest-config": "2.3.0",
87
91
  "@types/babel__traverse": "^7.14.2",
88
92
  "@types/jest": "^27",
89
93
  "@types/node": "^14",
90
94
  "jest": "^27",
91
95
  "typescript": "^4",
92
- "webpack": "^5.75.0",
93
- "@modern-js/builder-plugin-swc": "2.3.0",
94
- "@modern-js/server-core": "2.3.0",
95
- "@scripts/jest-config": "2.3.0",
96
- "@scripts/build": "2.3.0"
96
+ "webpack": "^5.75.0"
97
97
  },
98
98
  "sideEffects": false,
99
99
  "publishConfig": {