@modern-js/app-tools 2.46.0 → 2.47.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.
@@ -216,7 +216,7 @@ var analyze_default = ({ bundler }) => ({
216
216
  filename: rootLayoutFile
217
217
  });
218
218
  const hasAppConfig = moduleExports.some((e) => e.n === import_constants.APP_CONFIG_NAME);
219
- const generateLayoutPath = (0, import_utils2.replaceWithAlias)(srcDirectory, rootLayoutFile, internalSrcAlias);
219
+ const generateLayoutPath = (0, import_routes.getPathWithoutExt)((0, import_utils2.replaceWithAlias)(srcDirectory, rootLayoutFile, internalSrcAlias));
220
220
  if (hasAppConfig) {
221
221
  imports.push({
222
222
  value: generateLayoutPath,
@@ -35,19 +35,16 @@ __export(nestedRoutes_exports, {
35
35
  module.exports = __toCommonJS(nestedRoutes_exports);
36
36
  var path = __toESM(require("path"));
37
37
  var import_utils = require("@modern-js/utils");
38
+ var import_routes = require("../utils/routes");
38
39
  var import_constants = require("./constants");
39
40
  var import_utils2 = require("./utils");
40
41
  const conventionNames = Object.values(import_constants.NESTED_ROUTE);
41
42
  const replaceDynamicPath = (routePath) => {
42
43
  return routePath.replace(/\[(.*?)\]/g, ":$1");
43
44
  };
44
- const getPathWithoutExt = (filename) => {
45
- const extname = path.extname(filename);
46
- return filename.slice(0, -extname.length);
47
- };
48
45
  const getRouteId = (componentPath, routesDir, entryName, isMainEntry) => {
49
46
  const relativePath = (0, import_utils.normalizeToPosixPath)(path.relative(routesDir, componentPath));
50
- const pathWithoutExt = getPathWithoutExt(relativePath);
47
+ const pathWithoutExt = (0, import_routes.getPathWithoutExt)(relativePath);
51
48
  let id = ``;
52
49
  if (isMainEntry) {
53
50
  id = pathWithoutExt;
@@ -143,7 +140,7 @@ const walk = async (dirname, rootDir, alias, entryName, isMainEntry, oldVersion)
143
140
  const items = await import_utils.fs.readdir(dirname);
144
141
  for (const item of items) {
145
142
  const itemPath = path.join(dirname, item);
146
- const itemPathWithAlias = (0, import_utils2.replaceWithAlias)(alias.basename, itemPath, alias.name);
143
+ const itemPathWithAlias = (0, import_routes.getPathWithoutExt)((0, import_utils2.replaceWithAlias)(alias.basename, itemPath, alias.name));
147
144
  const extname = path.extname(item);
148
145
  const itemWithoutExt = item.slice(0, -extname.length);
149
146
  const isDirectory2 = (await import_utils.fs.stat(itemPath)).isDirectory();
@@ -50,7 +50,7 @@ const builderPluginAdapterSSR = (options) => ({
50
50
  }
51
51
  return config;
52
52
  });
53
- api.modifyBundlerChain(async (chain, { target, CHAIN_ID, isProd, HtmlPlugin: HtmlBundlerPlugin, isServer }) => {
53
+ api.modifyBundlerChain(async (chain, { target, isProd, HtmlPlugin: HtmlBundlerPlugin, isServer }) => {
54
54
  const builderConfig = api.getNormalizedConfig();
55
55
  const { normalizedConfig: normalizedConfig2 } = options;
56
56
  applyRouterPlugin(chain, "route-plugin", options, HtmlBundlerPlugin);
@@ -72,7 +72,6 @@ const builderPluginAdapterSSR = (options) => ({
72
72
  applyAsyncChunkHtmlPlugin({
73
73
  chain,
74
74
  modernConfig: options.normalizedConfig,
75
- CHAIN_ID,
76
75
  HtmlBundlerPlugin
77
76
  });
78
77
  }
@@ -94,9 +93,9 @@ const isStreamingSSR = (userConfig) => {
94
93
  }
95
94
  return false;
96
95
  };
97
- function applyAsyncChunkHtmlPlugin({ chain, modernConfig, CHAIN_ID, HtmlBundlerPlugin }) {
96
+ function applyAsyncChunkHtmlPlugin({ chain, modernConfig, HtmlBundlerPlugin }) {
98
97
  if (isStreamingSSR(modernConfig)) {
99
- chain.plugin(CHAIN_ID.PLUGIN.HTML_ASYNC_CHUNK).use(import_bundlerPlugins.HtmlAsyncChunkPlugin, [
98
+ chain.plugin("html-async-chunk").use(import_bundlerPlugins.HtmlAsyncChunkPlugin, [
100
99
  HtmlBundlerPlugin
101
100
  ]);
102
101
  }
@@ -86,24 +86,13 @@ function createDefaultConfig(appContext) {
86
86
  baseUrl: "/",
87
87
  port: 8080
88
88
  };
89
- const tools = {
90
- tsChecker: {
91
- issue: {
92
- include: [
93
- {
94
- file: "**/src/**/*"
95
- }
96
- ]
97
- }
98
- }
99
- };
100
89
  return {
101
90
  source,
102
91
  output,
103
92
  server,
104
93
  dev,
105
94
  html,
106
- tools,
95
+ tools: {},
107
96
  plugins: [],
108
97
  builderPlugins: [],
109
98
  runtime: {},
@@ -28,7 +28,8 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
28
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
29
  var routes_exports = {};
30
30
  __export(routes_exports, {
31
- generateRoutes: () => generateRoutes
31
+ generateRoutes: () => generateRoutes,
32
+ getPathWithoutExt: () => getPathWithoutExt
32
33
  });
33
34
  module.exports = __toCommonJS(routes_exports);
34
35
  var import_path = __toESM(require("path"));
@@ -40,7 +41,12 @@ const generateRoutes = async (appContext) => {
40
41
  }, null, 2);
41
42
  await import_utils.fs.outputFile(import_path.default.join(distDirectory, import_utils.ROUTE_SPEC_FILE), output);
42
43
  };
44
+ const getPathWithoutExt = (filename) => {
45
+ const extname = import_path.default.extname(filename);
46
+ return filename.slice(0, -extname.length);
47
+ };
43
48
  // Annotate the CommonJS export names for ESM import in node:
44
49
  0 && (module.exports = {
45
- generateRoutes
50
+ generateRoutes,
51
+ getPathWithoutExt
46
52
  });
@@ -7,7 +7,7 @@ import * as path from "path";
7
7
  import { createDebugger, findExists, fs, isApiOnly, minimist, isDevCommand, getArgv } from "@modern-js/utils";
8
8
  import { cloneDeep } from "@modern-js/utils/lodash";
9
9
  import { printInstructions } from "../utils/printInstructions";
10
- import { generateRoutes } from "../utils/routes";
10
+ import { generateRoutes, getPathWithoutExt } from "../utils/routes";
11
11
  import { emitResolvedConfig } from "../utils/config";
12
12
  import { getSelectedEntries } from "../utils/getSelectedEntries";
13
13
  import { initialNormalizedConfig } from "../config";
@@ -418,7 +418,7 @@ function analyze_default(param) {
418
418
  hasAppConfig = moduleExports.some(function(e) {
419
419
  return e.n === APP_CONFIG_NAME;
420
420
  });
421
- generateLayoutPath = replaceWithAlias(srcDirectory, rootLayoutFile, internalSrcAlias);
421
+ generateLayoutPath = getPathWithoutExt(replaceWithAlias(srcDirectory, rootLayoutFile, internalSrcAlias));
422
422
  if (hasAppConfig) {
423
423
  imports.push({
424
424
  value: generateLayoutPath,
@@ -4,16 +4,13 @@ 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 * as path from "path";
6
6
  import { fs, normalizeToPosixPath } from "@modern-js/utils";
7
+ import { getPathWithoutExt } from "../utils/routes";
7
8
  import { JS_EXTENSIONS, NESTED_ROUTE } from "./constants";
8
9
  import { hasAction, replaceWithAlias } from "./utils";
9
10
  var conventionNames = Object.values(NESTED_ROUTE);
10
11
  var replaceDynamicPath = function(routePath) {
11
12
  return routePath.replace(/\[(.*?)\]/g, ":$1");
12
13
  };
13
- var getPathWithoutExt = function(filename) {
14
- var extname = path.extname(filename);
15
- return filename.slice(0, -extname.length);
16
- };
17
14
  var getRouteId = function(componentPath, routesDir, entryName, isMainEntry) {
18
15
  var relativePath = normalizeToPosixPath(path.relative(routesDir, componentPath));
19
16
  var pathWithoutExt = getPathWithoutExt(relativePath);
@@ -150,7 +147,7 @@ var walk = function() {
150
147
  ];
151
148
  item = _step.value;
152
149
  itemPath = path.join(dirname, item);
153
- itemPathWithAlias = replaceWithAlias(alias.basename, itemPath, alias.name);
150
+ itemPathWithAlias = getPathWithoutExt(replaceWithAlias(alias.basename, itemPath, alias.name));
154
151
  extname = path.extname(item);
155
152
  itemWithoutExt = item.slice(0, -extname.length);
156
153
  return [
@@ -22,11 +22,11 @@ var builderPluginAdapterSSR = function(options) {
22
22
  });
23
23
  api.modifyBundlerChain(function() {
24
24
  var _ref = _async_to_generator(function(chain, param) {
25
- var target, CHAIN_ID, isProd, HtmlBundlerPlugin, isServer, builderConfig, normalizedConfig2;
25
+ var target, isProd, HtmlBundlerPlugin, isServer, builderConfig, normalizedConfig2;
26
26
  return _ts_generator(this, function(_state) {
27
27
  switch (_state.label) {
28
28
  case 0:
29
- target = param.target, CHAIN_ID = param.CHAIN_ID, isProd = param.isProd, HtmlBundlerPlugin = param.HtmlPlugin, isServer = param.isServer;
29
+ target = param.target, isProd = param.isProd, HtmlBundlerPlugin = param.HtmlPlugin, isServer = param.isServer;
30
30
  builderConfig = api.getNormalizedConfig();
31
31
  normalizedConfig2 = options.normalizedConfig;
32
32
  applyRouterPlugin(chain, "route-plugin", options, HtmlBundlerPlugin);
@@ -58,7 +58,6 @@ var builderPluginAdapterSSR = function(options) {
58
58
  applyAsyncChunkHtmlPlugin({
59
59
  chain,
60
60
  modernConfig: options.normalizedConfig,
61
- CHAIN_ID,
62
61
  HtmlBundlerPlugin
63
62
  });
64
63
  }
@@ -110,9 +109,9 @@ var isStreamingSSR = function(userConfig) {
110
109
  return false;
111
110
  };
112
111
  function applyAsyncChunkHtmlPlugin(param) {
113
- var chain = param.chain, modernConfig = param.modernConfig, CHAIN_ID = param.CHAIN_ID, HtmlBundlerPlugin = param.HtmlBundlerPlugin;
112
+ var chain = param.chain, modernConfig = param.modernConfig, HtmlBundlerPlugin = param.HtmlBundlerPlugin;
114
113
  if (isStreamingSSR(modernConfig)) {
115
- chain.plugin(CHAIN_ID.PLUGIN.HTML_ASYNC_CHUNK).use(HtmlAsyncChunkPlugin, [
114
+ chain.plugin("html-async-chunk").use(HtmlAsyncChunkPlugin, [
116
115
  HtmlBundlerPlugin
117
116
  ]);
118
117
  }
@@ -59,24 +59,13 @@ function createDefaultConfig(appContext) {
59
59
  baseUrl: "/",
60
60
  port: 8080
61
61
  };
62
- var tools = {
63
- tsChecker: {
64
- issue: {
65
- include: [
66
- {
67
- file: "**/src/**/*"
68
- }
69
- ]
70
- }
71
- }
72
- };
73
62
  return {
74
63
  source,
75
64
  output,
76
65
  server,
77
66
  dev,
78
67
  html,
79
- tools,
68
+ tools: {},
80
69
  plugins: [],
81
70
  builderPlugins: [],
82
71
  runtime: {},
@@ -28,6 +28,11 @@ var generateRoutes = function() {
28
28
  return _ref.apply(this, arguments);
29
29
  };
30
30
  }();
31
+ var getPathWithoutExt = function(filename) {
32
+ var extname = path.extname(filename);
33
+ return filename.slice(0, -extname.length);
34
+ };
31
35
  export {
32
- generateRoutes
36
+ generateRoutes,
37
+ getPathWithoutExt
33
38
  };
@@ -2,7 +2,7 @@ import * as path from "path";
2
2
  import { createDebugger, findExists, fs, isApiOnly, minimist, isDevCommand, getArgv } from "@modern-js/utils";
3
3
  import { cloneDeep } from "@modern-js/utils/lodash";
4
4
  import { printInstructions } from "../utils/printInstructions";
5
- import { generateRoutes } from "../utils/routes";
5
+ import { generateRoutes, getPathWithoutExt } from "../utils/routes";
6
6
  import { emitResolvedConfig } from "../utils/config";
7
7
  import { getSelectedEntries } from "../utils/getSelectedEntries";
8
8
  import { initialNormalizedConfig } from "../config";
@@ -183,7 +183,7 @@ var analyze_default = ({ bundler }) => ({
183
183
  filename: rootLayoutFile
184
184
  });
185
185
  const hasAppConfig = moduleExports.some((e) => e.n === APP_CONFIG_NAME);
186
- const generateLayoutPath = replaceWithAlias(srcDirectory, rootLayoutFile, internalSrcAlias);
186
+ const generateLayoutPath = getPathWithoutExt(replaceWithAlias(srcDirectory, rootLayoutFile, internalSrcAlias));
187
187
  if (hasAppConfig) {
188
188
  imports.push({
189
189
  value: generateLayoutPath,
@@ -1,15 +1,12 @@
1
1
  import * as path from "path";
2
2
  import { fs, normalizeToPosixPath } from "@modern-js/utils";
3
+ import { getPathWithoutExt } from "../utils/routes";
3
4
  import { JS_EXTENSIONS, NESTED_ROUTE } from "./constants";
4
5
  import { hasAction, replaceWithAlias } from "./utils";
5
6
  const conventionNames = Object.values(NESTED_ROUTE);
6
7
  const replaceDynamicPath = (routePath) => {
7
8
  return routePath.replace(/\[(.*?)\]/g, ":$1");
8
9
  };
9
- const getPathWithoutExt = (filename) => {
10
- const extname = path.extname(filename);
11
- return filename.slice(0, -extname.length);
12
- };
13
10
  const getRouteId = (componentPath, routesDir, entryName, isMainEntry) => {
14
11
  const relativePath = normalizeToPosixPath(path.relative(routesDir, componentPath));
15
12
  const pathWithoutExt = getPathWithoutExt(relativePath);
@@ -108,7 +105,7 @@ const walk = async (dirname, rootDir, alias, entryName, isMainEntry, oldVersion)
108
105
  const items = await fs.readdir(dirname);
109
106
  for (const item of items) {
110
107
  const itemPath = path.join(dirname, item);
111
- const itemPathWithAlias = replaceWithAlias(alias.basename, itemPath, alias.name);
108
+ const itemPathWithAlias = getPathWithoutExt(replaceWithAlias(alias.basename, itemPath, alias.name));
112
109
  const extname = path.extname(item);
113
110
  const itemWithoutExt = item.slice(0, -extname.length);
114
111
  const isDirectory2 = (await fs.stat(itemPath)).isDirectory();
@@ -17,7 +17,7 @@ const builderPluginAdapterSSR = (options) => ({
17
17
  }
18
18
  return config;
19
19
  });
20
- api.modifyBundlerChain(async (chain, { target, CHAIN_ID, isProd, HtmlPlugin: HtmlBundlerPlugin, isServer }) => {
20
+ api.modifyBundlerChain(async (chain, { target, isProd, HtmlPlugin: HtmlBundlerPlugin, isServer }) => {
21
21
  const builderConfig = api.getNormalizedConfig();
22
22
  const { normalizedConfig: normalizedConfig2 } = options;
23
23
  applyRouterPlugin(chain, "route-plugin", options, HtmlBundlerPlugin);
@@ -39,7 +39,6 @@ const builderPluginAdapterSSR = (options) => ({
39
39
  applyAsyncChunkHtmlPlugin({
40
40
  chain,
41
41
  modernConfig: options.normalizedConfig,
42
- CHAIN_ID,
43
42
  HtmlBundlerPlugin
44
43
  });
45
44
  }
@@ -61,9 +60,9 @@ const isStreamingSSR = (userConfig) => {
61
60
  }
62
61
  return false;
63
62
  };
64
- function applyAsyncChunkHtmlPlugin({ chain, modernConfig, CHAIN_ID, HtmlBundlerPlugin }) {
63
+ function applyAsyncChunkHtmlPlugin({ chain, modernConfig, HtmlBundlerPlugin }) {
65
64
  if (isStreamingSSR(modernConfig)) {
66
- chain.plugin(CHAIN_ID.PLUGIN.HTML_ASYNC_CHUNK).use(HtmlAsyncChunkPlugin, [
65
+ chain.plugin("html-async-chunk").use(HtmlAsyncChunkPlugin, [
67
66
  HtmlBundlerPlugin
68
67
  ]);
69
68
  }
@@ -62,24 +62,13 @@ function createDefaultConfig(appContext) {
62
62
  baseUrl: "/",
63
63
  port: 8080
64
64
  };
65
- const tools = {
66
- tsChecker: {
67
- issue: {
68
- include: [
69
- {
70
- file: "**/src/**/*"
71
- }
72
- ]
73
- }
74
- }
75
- };
76
65
  return {
77
66
  source,
78
67
  output,
79
68
  server,
80
69
  dev,
81
70
  html,
82
- tools,
71
+ tools: {},
83
72
  plugins: [],
84
73
  builderPlugins: [],
85
74
  runtime: {},
@@ -7,6 +7,11 @@ const generateRoutes = async (appContext) => {
7
7
  }, null, 2);
8
8
  await fs.outputFile(path.join(distDirectory, ROUTE_SPEC_FILE), output);
9
9
  };
10
+ const getPathWithoutExt = (filename) => {
11
+ const extname = path.extname(filename);
12
+ return filename.slice(0, -extname.length);
13
+ };
10
14
  export {
11
- generateRoutes
15
+ generateRoutes,
16
+ getPathWithoutExt
12
17
  };
@@ -1,3 +1,4 @@
1
1
  import type { IAppContext } from '@modern-js/core';
2
2
  declare const generateRoutes: (appContext: IAppContext) => Promise<void>;
3
- export { generateRoutes };
3
+ declare const getPathWithoutExt: (filename: string) => string;
4
+ export { generateRoutes, getPathWithoutExt };
package/package.json CHANGED
@@ -15,7 +15,7 @@
15
15
  "modern",
16
16
  "modern.js"
17
17
  ],
18
- "version": "2.46.0",
18
+ "version": "2.47.0",
19
19
  "jsnext:source": "./src/index.ts",
20
20
  "types": "./dist/types/index.d.ts",
21
21
  "main": "./dist/cjs/index.js",
@@ -69,38 +69,39 @@
69
69
  "@babel/parser": "^7.22.15",
70
70
  "@babel/traverse": "^7.23.2",
71
71
  "@babel/types": "^7.23.0",
72
- "@rsbuild/plugin-esbuild": "0.3.3",
73
- "@rsbuild/plugin-node-polyfill": "0.3.3",
74
- "@rsbuild/shared": "0.3.3",
72
+ "@rsbuild/plugin-esbuild": "0.4.4",
73
+ "@rsbuild/plugin-node-polyfill": "0.4.4",
74
+ "@rsbuild/shared": "0.4.4",
75
+ "@rsbuild/core": "0.4.4",
75
76
  "es-module-lexer": "^1.1.0",
76
77
  "esbuild": "0.17.19",
77
78
  "@swc/helpers": "0.5.3",
78
- "@modern-js/uni-builder": "2.46.0",
79
- "@modern-js/core": "2.46.0",
80
- "@modern-js/new-action": "2.46.0",
81
- "@modern-js/node-bundle-require": "2.46.0",
82
- "@modern-js/plugin": "2.46.0",
83
- "@modern-js/plugin-data-loader": "2.46.0",
84
- "@modern-js/plugin-lint": "2.46.0",
85
- "@modern-js/plugin-i18n": "2.46.0",
86
- "@modern-js/server": "2.46.0",
87
- "@modern-js/prod-server": "2.46.0",
88
- "@modern-js/server-utils": "2.46.0",
89
- "@modern-js/types": "2.46.0",
90
- "@modern-js/upgrade": "2.46.0",
91
- "@modern-js/server-core": "2.46.0",
92
- "@modern-js/utils": "2.46.0"
79
+ "@modern-js/uni-builder": "2.47.0",
80
+ "@modern-js/new-action": "2.47.0",
81
+ "@modern-js/node-bundle-require": "2.47.0",
82
+ "@modern-js/core": "2.47.0",
83
+ "@modern-js/plugin": "2.47.0",
84
+ "@modern-js/plugin-data-loader": "2.47.0",
85
+ "@modern-js/plugin-lint": "2.47.0",
86
+ "@modern-js/plugin-i18n": "2.47.0",
87
+ "@modern-js/prod-server": "2.47.0",
88
+ "@modern-js/server-utils": "2.47.0",
89
+ "@modern-js/types": "2.47.0",
90
+ "@modern-js/upgrade": "2.47.0",
91
+ "@modern-js/server": "2.47.0",
92
+ "@modern-js/server-core": "2.47.0",
93
+ "@modern-js/utils": "2.47.0"
93
94
  },
94
95
  "devDependencies": {
95
- "@rsbuild/plugin-swc": "0.3.3",
96
+ "@rsbuild/plugin-swc": "0.4.4",
96
97
  "@types/babel__traverse": "7.18.5",
97
98
  "@types/jest": "^29",
98
99
  "@types/node": "^14",
99
100
  "jest": "^29",
100
101
  "typescript": "^5",
101
102
  "webpack": "^5.89.0",
102
- "@scripts/build": "2.46.0",
103
- "@scripts/jest-config": "2.46.0"
103
+ "@scripts/build": "2.47.0",
104
+ "@scripts/jest-config": "2.47.0"
104
105
  },
105
106
  "sideEffects": false,
106
107
  "publishConfig": {