@modern-js/app-tools 2.2.0 → 2.2.1-alpha.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.
@@ -23,7 +23,8 @@ 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: "$"
27
28
  };
28
29
  const APP_CONFIG_NAME = "config";
29
30
  const APP_INIT_EXPORTED = "init";
@@ -44,14 +44,15 @@ import {
44
44
  fs,
45
45
  getEntryOptions,
46
46
  isApiOnly,
47
- minimist
47
+ minimist,
48
+ getCommand,
49
+ isDevCommand
48
50
  } from "@modern-js/utils";
49
51
  import { cloneDeep } from "@modern-js/utils/lodash";
50
52
  import { createBuilderForModern } from "../builder";
51
53
  import { printInstructions } from "../utils/printInstructions";
52
54
  import { generateRoutes } from "../utils/routes";
53
55
  import { emitResolvedConfig } from "../utils/config";
54
- import { getCommand, isDevCommand } from "../utils/commands";
55
56
  import { getSelectedEntries } from "../utils/getSelectedEntries";
56
57
  import { initialNormalizedConfig } from "../config";
57
58
  import {
@@ -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
  }
@@ -130,6 +130,18 @@ const walk = (dirname, rootDir, alias, entryName) => __async(void 0, null, funct
130
130
  }
131
131
  (_b = route.children) == null ? void 0 : _b.push(pageRoute);
132
132
  }
133
+ if (itemWithoutExt === NESTED_ROUTE.SPLATE_FILE) {
134
+ const splatRoute = createRoute(
135
+ {
136
+ _component: replaceWithAlias(alias.basename, itemPath, alias.name),
137
+ path: "*"
138
+ },
139
+ rootDir,
140
+ itemPath,
141
+ entryName
142
+ );
143
+ (_c = route.children) == null ? void 0 : _c.push(splatRoute);
144
+ }
133
145
  if (itemWithoutExt === NESTED_ROUTE.LOADING_FILE) {
134
146
  route.loading = replaceWithAlias(alias.basename, itemPath, alias.name);
135
147
  }
@@ -146,7 +158,7 @@ const walk = (dirname, rootDir, alias, entryName) => __async(void 0, null, funct
146
158
  if (isPathlessLayout) {
147
159
  delete finalRoute.path;
148
160
  }
149
- route.children = (_c = route.children) == null ? void 0 : _c.filter((childRoute) => childRoute);
161
+ route.children = (_d = route.children) == null ? void 0 : _d.filter((childRoute) => childRoute);
150
162
  if (route.children && route.children.length === 0 && !route.index) {
151
163
  return null;
152
164
  }
@@ -39,14 +39,18 @@ var __async = (__this, __arguments, generator) => {
39
39
  };
40
40
  import path from "path";
41
41
  import lintPlugin from "@modern-js/plugin-lint";
42
- import { cleanRequireCache, emptyDir, Import } from "@modern-js/utils";
42
+ import {
43
+ cleanRequireCache,
44
+ emptyDir,
45
+ Import,
46
+ getCommand
47
+ } from "@modern-js/utils";
43
48
  import { castArray } from "@modern-js/utils/lodash";
44
49
  import analyzePlugin from "./analyze";
45
50
  import initializePlugin from "./initialize";
46
51
  import { hooks } from "./hooks";
47
52
  import { i18n, localeKeys } from "./locale";
48
53
  import { getLocaleLanguage } from "./utils/language";
49
- import { getCommand } from "./utils/commands";
50
54
  import { restart } from "./utils/restart";
51
55
  import { generateWatchFiles } from "./utils/generateWatchFiles";
52
56
  export * from "./defineConfig";
@@ -37,9 +37,13 @@ var __async = (__this, __arguments, generator) => {
37
37
  step((generator = generator.apply(__this, __arguments)).next());
38
38
  });
39
39
  };
40
- import { ensureAbsolutePath, getPort, isDev } from "@modern-js/utils";
40
+ import {
41
+ ensureAbsolutePath,
42
+ getPort,
43
+ isDev,
44
+ isDevCommand
45
+ } from "@modern-js/utils";
41
46
  import { legacySchema, schema } from "../schema";
42
- import { isDevCommand } from "../utils/commands";
43
47
  import { transformNormalizedConfig } from "../config/initial/transformNormalizedConfig";
44
48
  import {
45
49
  checkIsLegacyConfig,
@@ -66,7 +66,8 @@ 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: "$"
70
71
  };
71
72
  const APP_CONFIG_NAME = "config";
72
73
  const APP_INIT_EXPORTED = "init";
@@ -70,7 +70,6 @@ var import_builder = require("../builder");
70
70
  var import_printInstructions = require("../utils/printInstructions");
71
71
  var import_routes = require("../utils/routes");
72
72
  var import_config = require("../utils/config");
73
- var import_commands = require("../utils/commands");
74
73
  var import_getSelectedEntries = require("../utils/getSelectedEntries");
75
74
  var import_config2 = require("../config");
76
75
  var import_utils2 = require("./utils");
@@ -148,7 +147,7 @@ var analyze_default = () => ({
148
147
  yield hookRunners.addDefineTypes();
149
148
  debug(`add Define Types`);
150
149
  let checkedEntries = entrypoints.map((point) => point.entryName);
151
- if ((0, import_commands.isDevCommand)()) {
150
+ if ((0, import_utils.isDevCommand)()) {
152
151
  const { entry } = (0, import_utils.minimist)(process.argv.slice(2));
153
152
  checkedEntries = yield (0, import_getSelectedEntries.getSelectedEntries)(
154
153
  typeof entry === "string" ? entry.split(",") : entry,
@@ -163,7 +162,7 @@ var analyze_default = () => ({
163
162
  htmlTemplates
164
163
  });
165
164
  api.setAppContext(appContext);
166
- const command = (0, import_commands.getCommand)();
165
+ const command = (0, import_utils.getCommand)();
167
166
  const buildCommands = ["dev", "start", "build", "inspect", "deploy"];
168
167
  if (buildCommands.includes(command)) {
169
168
  let _b;
@@ -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
  }
@@ -156,6 +156,18 @@ const walk = (dirname, rootDir, alias, entryName) => __async(void 0, null, funct
156
156
  }
157
157
  (_b = route.children) == null ? void 0 : _b.push(pageRoute);
158
158
  }
159
+ if (itemWithoutExt === import_constants.NESTED_ROUTE.SPLATE_FILE) {
160
+ const splatRoute = createRoute(
161
+ {
162
+ _component: (0, import_utils2.replaceWithAlias)(alias.basename, itemPath, alias.name),
163
+ path: "*"
164
+ },
165
+ rootDir,
166
+ itemPath,
167
+ entryName
168
+ );
169
+ (_c = route.children) == null ? void 0 : _c.push(splatRoute);
170
+ }
159
171
  if (itemWithoutExt === import_constants.NESTED_ROUTE.LOADING_FILE) {
160
172
  route.loading = (0, import_utils2.replaceWithAlias)(alias.basename, itemPath, alias.name);
161
173
  }
@@ -172,7 +184,7 @@ const walk = (dirname, rootDir, alias, entryName) => __async(void 0, null, funct
172
184
  if (isPathlessLayout) {
173
185
  delete finalRoute.path;
174
186
  }
175
- route.children = (_c = route.children) == null ? void 0 : _c.filter((childRoute) => childRoute);
187
+ route.children = (_d = route.children) == null ? void 0 : _d.filter((childRoute) => childRoute);
176
188
  if (route.children && route.children.length === 0 && !route.index) {
177
189
  return null;
178
190
  }
@@ -75,7 +75,6 @@ var import_initialize = __toESM(require("./initialize"));
75
75
  var import_hooks = require("./hooks");
76
76
  var import_locale = require("./locale");
77
77
  var import_language = require("./utils/language");
78
- var import_commands = require("./utils/commands");
79
78
  var import_restart = require("./utils/restart");
80
79
  var import_generateWatchFiles = require("./utils/generateWatchFiles");
81
80
  __reExport(src_exports, require("./defineConfig"), module.exports);
@@ -194,7 +193,7 @@ var src_default = () => ({
194
193
  },
195
194
  prepare() {
196
195
  return __async(this, null, function* () {
197
- const command = (0, import_commands.getCommand)();
196
+ const command = (0, import_utils.getCommand)();
198
197
  if (command === "dev" || command === "start" || command === "build") {
199
198
  const appContext = api.useAppContext();
200
199
  yield (0, import_utils.emptyDir)(appContext.distDirectory);
@@ -59,7 +59,6 @@ __export(initialize_exports, {
59
59
  module.exports = __toCommonJS(initialize_exports);
60
60
  var import_utils = require("@modern-js/utils");
61
61
  var import_schema = require("../schema");
62
- var import_commands = require("../utils/commands");
63
62
  var import_transformNormalizedConfig = require("../config/initial/transformNormalizedConfig");
64
63
  var import_config = require("../config");
65
64
  var initialize_default = () => ({
@@ -125,7 +124,7 @@ var initialize_default = () => ({
125
124
  function getServerPort(config) {
126
125
  return __async(this, null, function* () {
127
126
  const prodPort = config.server.port || 8080;
128
- if ((0, import_utils.isDev)() && (0, import_commands.isDevCommand)()) {
127
+ if ((0, import_utils.isDev)() && (0, import_utils.isDevCommand)()) {
129
128
  return (0, import_utils.getPort)(config.dev.port || prodPort);
130
129
  }
131
130
  return prodPort;
@@ -32,7 +32,8 @@ 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: "$"
36
37
  };
37
38
  var APP_CONFIG_NAME = "config";
38
39
  var APP_INIT_EXPORTED = "init";
@@ -221,13 +221,12 @@ var __generator = this && this.__generator || function(thisArg, body) {
221
221
  }
222
222
  };
223
223
  import * as path from "path";
224
- import { createDebugger, findExists, fs, getEntryOptions, isApiOnly, minimist } from "@modern-js/utils";
224
+ import { createDebugger, findExists, fs, getEntryOptions, isApiOnly, minimist, getCommand, isDevCommand } from "@modern-js/utils";
225
225
  import { cloneDeep } from "@modern-js/utils/lodash";
226
226
  import { createBuilderForModern } from "../builder";
227
227
  import { printInstructions } from "../utils/printInstructions";
228
228
  import { generateRoutes } from "../utils/routes";
229
229
  import { emitResolvedConfig } from "../utils/config";
230
- import { getCommand, isDevCommand } from "../utils/commands";
231
230
  import { getSelectedEntries } from "../utils/getSelectedEntries";
232
231
  import { initialNormalizedConfig } from "../config";
233
232
  import { getServerLoadersFile, isPageComponentFile, parseModule, replaceWithAlias } from "./utils";
@@ -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, items, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, item, itemPath, extname, itemWithoutExt, isDirectory2, childRoute, ref1, ref2, ref3, splatRoute, err, finalRoute;
201
201
  return __generator(this, function(_state) {
202
202
  switch(_state.label){
203
203
  case 0:
@@ -317,6 +317,14 @@ var walk = function() {
317
317
  }
318
318
  (ref2 = route.children) === null || ref2 === void 0 ? void 0 : ref2.push(pageRoute);
319
319
  }
320
+ if (itemWithoutExt === NESTED_ROUTE.SPLATE_FILE) {
321
+ ;
322
+ splatRoute = createRoute({
323
+ _component: replaceWithAlias(alias.basename, itemPath, alias.name),
324
+ path: "*"
325
+ }, rootDir, itemPath, entryName);
326
+ (ref3 = route.children) === null || ref3 === void 0 ? void 0 : ref3.push(splatRoute);
327
+ }
320
328
  if (itemWithoutExt === NESTED_ROUTE.LOADING_FILE) {
321
329
  route.loading = replaceWithAlias(alias.basename, itemPath, alias.name);
322
330
  }
@@ -176,14 +176,13 @@ var __generator = this && this.__generator || function(thisArg, body) {
176
176
  };
177
177
  import path from "path";
178
178
  import lintPlugin from "@modern-js/plugin-lint";
179
- import { cleanRequireCache, emptyDir, Import } from "@modern-js/utils";
179
+ import { cleanRequireCache, emptyDir, Import, getCommand } from "@modern-js/utils";
180
180
  import { castArray } from "@modern-js/utils/lodash";
181
181
  import analyzePlugin from "./analyze";
182
182
  import initializePlugin from "./initialize";
183
183
  import { hooks } from "./hooks";
184
184
  import { i18n, localeKeys } from "./locale";
185
185
  import { getLocaleLanguage } from "./utils/language";
186
- import { getCommand } from "./utils/commands";
187
186
  import { restart } from "./utils/restart";
188
187
  import { generateWatchFiles } from "./utils/generateWatchFiles";
189
188
  export * from "./defineConfig";
@@ -174,9 +174,8 @@ var __generator = this && this.__generator || function(thisArg, body) {
174
174
  };
175
175
  }
176
176
  };
177
- import { ensureAbsolutePath, getPort, isDev } from "@modern-js/utils";
177
+ import { ensureAbsolutePath, getPort, isDev, isDevCommand } from "@modern-js/utils";
178
178
  import { legacySchema, schema } from "../schema";
179
- import { isDevCommand } from "../utils/commands";
180
179
  import { transformNormalizedConfig } from "../config/initial/transformNormalizedConfig";
181
180
  import { checkIsLegacyConfig, createDefaultConfig, createLegacyDefaultConfig } from "../config";
182
181
  var initialize_default = function() {
@@ -24,6 +24,7 @@ export declare const NESTED_ROUTE: {
24
24
  LOADING_FILE: string;
25
25
  ERROR_FILE: string;
26
26
  LOADER_FILE: string;
27
+ SPLATE_FILE: string;
27
28
  };
28
29
  export declare const APP_CONFIG_NAME = "config";
29
30
  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.2.0",
14
+ "version": "2.2.1-alpha.0",
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.2.0",
69
67
  "@modern-js/builder-plugin-esbuild": "2.2.0",
70
68
  "@modern-js/builder-plugin-node-polyfill": "2.2.0",
@@ -81,19 +79,21 @@
81
79
  "@modern-js/server": "2.2.0",
82
80
  "@modern-js/types": "2.2.0",
83
81
  "@modern-js/upgrade": "2.2.0",
84
- "@modern-js/utils": "2.2.0"
82
+ "@modern-js/utils": "2.2.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.2.0",
88
+ "@modern-js/server-core": "2.2.0",
89
+ "@scripts/build": "2.2.0",
90
+ "@scripts/jest-config": "2.2.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.2.0",
94
- "@modern-js/server-core": "2.2.0",
95
- "@scripts/jest-config": "2.2.0",
96
- "@scripts/build": "2.2.0"
96
+ "webpack": "^5.75.0"
97
97
  },
98
98
  "sideEffects": false,
99
99
  "publishConfig": {
@@ -1,13 +0,0 @@
1
- const getCommand = () => {
2
- const args = process.argv.slice(2);
3
- const command = args[0];
4
- return command;
5
- };
6
- const isDevCommand = () => {
7
- const command = getCommand();
8
- return command === "dev" || command === "start";
9
- };
10
- export {
11
- getCommand,
12
- isDevCommand
13
- };
@@ -1,37 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: true });
8
- };
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") {
11
- for (let key of __getOwnPropNames(from))
12
- if (!__hasOwnProp.call(to, key) && key !== except)
13
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
- }
15
- return to;
16
- };
17
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
- var commands_exports = {};
19
- __export(commands_exports, {
20
- getCommand: () => getCommand,
21
- isDevCommand: () => isDevCommand
22
- });
23
- module.exports = __toCommonJS(commands_exports);
24
- const getCommand = () => {
25
- const args = process.argv.slice(2);
26
- const command = args[0];
27
- return command;
28
- };
29
- const isDevCommand = () => {
30
- const command = getCommand();
31
- return command === "dev" || command === "start";
32
- };
33
- // Annotate the CommonJS export names for ESM import in node:
34
- 0 && (module.exports = {
35
- getCommand,
36
- isDevCommand
37
- });
@@ -1,10 +0,0 @@
1
- var getCommand = function() {
2
- var args = process.argv.slice(2);
3
- var command = args[0];
4
- return command;
5
- };
6
- var isDevCommand = function() {
7
- var command = getCommand();
8
- return command === "dev" || command === "start";
9
- };
10
- export { getCommand, isDevCommand };
@@ -1,2 +0,0 @@
1
- export declare const getCommand: () => string;
2
- export declare const isDevCommand: () => boolean;