@modern-js/app-tools 2.27.1-alpha.0 → 2.28.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.
Files changed (48) hide show
  1. package/CHANGELOG.md +44 -0
  2. package/dist/cjs/analyze/generateCode.js +2 -2
  3. package/dist/cjs/analyze/getFileSystemEntry.js +2 -1
  4. package/dist/cjs/analyze/getServerRoutes.js +5 -4
  5. package/dist/cjs/analyze/index.js +209 -211
  6. package/dist/cjs/analyze/nestedRoutes.js +2 -2
  7. package/dist/cjs/analyze/templates.js +4 -4
  8. package/dist/cjs/builder/builder-rspack/adapterCopy.js +41 -43
  9. package/dist/cjs/builder/builder-webpack/adapterModern.js +23 -25
  10. package/dist/cjs/builder/generator/createBuilderProviderConfig.js +2 -1
  11. package/dist/cjs/builder/shared/builderPlugins/adapterSSR.js +12 -15
  12. package/dist/cjs/builder/shared/bundlerPlugins/RouterPlugin.js +33 -75
  13. package/dist/cjs/commands/build.js +2 -1
  14. package/dist/cjs/commands/inspect.js +2 -1
  15. package/dist/cjs/commands/serve.js +2 -2
  16. package/dist/cjs/index.js +3 -2
  17. package/dist/cjs/initialize/index.js +70 -72
  18. package/dist/esm/analyze/generateCode.js +2 -2
  19. package/dist/esm/analyze/getFileSystemEntry.js +2 -1
  20. package/dist/esm/analyze/getServerRoutes.js +5 -4
  21. package/dist/esm/analyze/nestedRoutes.js +2 -2
  22. package/dist/esm/analyze/templates.js +4 -4
  23. package/dist/esm/builder/builder-rspack/adapterCopy.js +1 -1
  24. package/dist/esm/builder/generator/createBuilderProviderConfig.js +2 -1
  25. package/dist/esm/builder/shared/builderPlugins/adapterSSR.js +13 -16
  26. package/dist/esm/builder/shared/bundlerPlugins/RouterPlugin.js +41 -101
  27. package/dist/esm/commands/build.js +2 -2
  28. package/dist/esm/commands/inspect.js +2 -2
  29. package/dist/esm/commands/serve.js +2 -2
  30. package/dist/esm/index.js +3 -2
  31. package/dist/esm-node/analyze/generateCode.js +2 -2
  32. package/dist/esm-node/analyze/getFileSystemEntry.js +2 -1
  33. package/dist/esm-node/analyze/getServerRoutes.js +5 -4
  34. package/dist/esm-node/analyze/index.js +209 -211
  35. package/dist/esm-node/analyze/nestedRoutes.js +2 -2
  36. package/dist/esm-node/analyze/templates.js +4 -4
  37. package/dist/esm-node/builder/builder-rspack/adapterCopy.js +41 -43
  38. package/dist/esm-node/builder/builder-webpack/adapterModern.js +23 -25
  39. package/dist/esm-node/builder/generator/createBuilderProviderConfig.js +2 -1
  40. package/dist/esm-node/builder/shared/builderPlugins/adapterSSR.js +12 -15
  41. package/dist/esm-node/builder/shared/bundlerPlugins/RouterPlugin.js +33 -75
  42. package/dist/esm-node/commands/build.js +2 -1
  43. package/dist/esm-node/commands/inspect.js +2 -1
  44. package/dist/esm-node/commands/serve.js +2 -2
  45. package/dist/esm-node/index.js +3 -2
  46. package/dist/esm-node/initialize/index.js +70 -72
  47. package/dist/types/builder/shared/bundlerPlugins/RouterPlugin.d.ts +0 -8
  48. package/package.json +24 -24
@@ -47,12 +47,13 @@ export const builderPluginAdapterSSR = (options) => ({
47
47
  }
48
48
  });
49
49
  const isStreamingSSR = (userConfig) => {
50
+ var _server;
50
51
  const isStreaming = (ssr) => ssr && typeof ssr === "object" && ssr.mode === "stream";
51
52
  const { server } = userConfig;
52
53
  if (isStreaming(server.ssr)) {
53
54
  return true;
54
55
  }
55
- if ((server === null || server === void 0 ? void 0 : server.ssrByEntries) && typeof server.ssrByEntries === "object") {
56
+ if (((_server = server) === null || _server === void 0 ? void 0 : _server.ssrByEntries) && typeof server.ssrByEntries === "object") {
56
57
  for (const name of Object.keys(server.ssrByEntries)) {
57
58
  if (isStreaming(server.ssrByEntries[name])) {
58
59
  return true;
@@ -69,38 +70,33 @@ function applyAsyncChunkHtmlPlugin({ chain, modernConfig, CHAIN_ID, HtmlBundlerP
69
70
  }
70
71
  }
71
72
  function applyRouterPlugin(chain, options) {
72
- var _normalizedConfig_runtime, _normalizedConfig_deploy_worker;
73
+ var _normalizedConfig_runtime, _normalizedConfig, _routerConfig, _normalizedConfig_deploy_worker;
73
74
  const { appContext, normalizedConfig } = options;
74
75
  const { entrypoints } = appContext;
75
76
  const existNestedRoutes = entrypoints.some((entrypoint) => entrypoint.nestedRoutesEntry);
76
- const routerConfig = normalizedConfig === null || normalizedConfig === void 0 ? void 0 : (_normalizedConfig_runtime = normalizedConfig.runtime) === null || _normalizedConfig_runtime === void 0 ? void 0 : _normalizedConfig_runtime.router;
77
- const routerManifest = Boolean(routerConfig === null || routerConfig === void 0 ? void 0 : routerConfig.manifest);
77
+ const routerConfig = (_normalizedConfig = normalizedConfig) === null || _normalizedConfig === void 0 ? void 0 : (_normalizedConfig_runtime = _normalizedConfig.runtime) === null || _normalizedConfig_runtime === void 0 ? void 0 : _normalizedConfig_runtime.router;
78
+ const routerManifest = Boolean((_routerConfig = routerConfig) === null || _routerConfig === void 0 ? void 0 : _routerConfig.manifest);
78
79
  const workerSSR = Boolean((_normalizedConfig_deploy_worker = normalizedConfig.deploy.worker) === null || _normalizedConfig_deploy_worker === void 0 ? void 0 : _normalizedConfig_deploy_worker.ssr);
79
- const minimize = !normalizedConfig.output.disableMinimize && process.env.NODE_ENV === "production";
80
80
  if (existNestedRoutes || routerManifest || workerSSR) {
81
- chain.plugin("route-plugin").use(RouterPlugin, [
82
- {
83
- minimize
84
- }
85
- ]);
81
+ chain.plugin("route-plugin").use(RouterPlugin);
86
82
  }
87
83
  }
88
84
  function applyFilterEntriesBySSRConfig({ isProd, chain, appNormalizedConfig }) {
89
- var _ref;
85
+ var _outputConfig, _this, _outputConfig1, _outputConfig2, _outputConfig3;
90
86
  const { server: serverConfig, output: outputConfig } = appNormalizedConfig;
91
87
  const entries = chain.entryPoints.entries();
92
- if (isProd && ((outputConfig === null || outputConfig === void 0 ? void 0 : outputConfig.ssg) === true || typeof ((_ref = outputConfig === null || outputConfig === void 0 ? void 0 : outputConfig.ssg) === null || _ref === void 0 ? void 0 : _ref[0]) === "function")) {
88
+ if (isProd && (((_outputConfig = outputConfig) === null || _outputConfig === void 0 ? void 0 : _outputConfig.ssg) === true || typeof ((_this = (_outputConfig1 = outputConfig) === null || _outputConfig1 === void 0 ? void 0 : _outputConfig1.ssg) === null || _this === void 0 ? void 0 : _this[0]) === "function")) {
93
89
  return;
94
90
  }
95
91
  if (typeof entries === "undefined") {
96
92
  throw new Error("No entry found, one of src/routes/layout.tsx, src/App.tsx, src/index.tsx is required");
97
93
  }
98
94
  const entryNames = Object.keys(entries);
99
- if (isProd && entryNames.length === 1 && (outputConfig === null || outputConfig === void 0 ? void 0 : outputConfig.ssg)) {
95
+ if (isProd && entryNames.length === 1 && ((_outputConfig2 = outputConfig) === null || _outputConfig2 === void 0 ? void 0 : _outputConfig2.ssg)) {
100
96
  return;
101
97
  }
102
98
  const ssgEntries = [];
103
- if (isProd && (outputConfig === null || outputConfig === void 0 ? void 0 : outputConfig.ssg)) {
99
+ if (isProd && ((_outputConfig3 = outputConfig) === null || _outputConfig3 === void 0 ? void 0 : _outputConfig3.ssg)) {
104
100
  const { ssg } = outputConfig;
105
101
  entryNames.forEach((name) => {
106
102
  if (ssg[name]) {
@@ -110,7 +106,8 @@ function applyFilterEntriesBySSRConfig({ isProd, chain, appNormalizedConfig }) {
110
106
  }
111
107
  const { ssr, ssrByEntries } = serverConfig || {};
112
108
  entryNames.forEach((name) => {
113
- if (!ssgEntries.includes(name) && (ssr && (ssrByEntries === null || ssrByEntries === void 0 ? void 0 : ssrByEntries[name]) === false || !ssr && !(ssrByEntries === null || ssrByEntries === void 0 ? void 0 : ssrByEntries[name]))) {
109
+ var _ssrByEntries, _ssrByEntries1;
110
+ if (!ssgEntries.includes(name) && (ssr && ((_ssrByEntries = ssrByEntries) === null || _ssrByEntries === void 0 ? void 0 : _ssrByEntries[name]) === false || !ssr && !((_ssrByEntries1 = ssrByEntries) === null || _ssrByEntries1 === void 0 ? void 0 : _ssrByEntries1[name]))) {
114
111
  chain.entryPoints.delete(name);
115
112
  }
116
113
  });
@@ -1,4 +1,3 @@
1
- import { _ as _define_property } from "@swc/helpers/_/_define_property";
2
1
  import path from "path";
3
2
  import { mergeWith } from "@modern-js/utils/lodash";
4
3
  import { ROUTE_MANIFEST_FILE } from "@modern-js/utils";
@@ -15,22 +14,6 @@ export class RouterPlugin {
15
14
  }
16
15
  return false;
17
16
  }
18
- getEntryChunks(compilation, chunks) {
19
- const entrypointsArray = Array.from(compilation.entrypoints.entries());
20
- const entryChunkIds = entrypointsArray.map((entrypoint) => entrypoint[0]);
21
- const entryChunks = [
22
- ...chunks
23
- ].filter((chunk) => {
24
- var _chunk_names;
25
- return (_chunk_names = chunk.names) === null || _chunk_names === void 0 ? void 0 : _chunk_names.some((name) => entryChunkIds.includes(name));
26
- });
27
- return entryChunks;
28
- }
29
- getEntryChunkFiles(entryChunks) {
30
- return entryChunks.map((chunk) => [
31
- ...chunk.files || []
32
- ].find((fname) => fname.includes(".js")));
33
- }
34
17
  apply(compiler) {
35
18
  const { target } = compiler.options;
36
19
  if (this.isTargetNodeOrWebWorker(target)) {
@@ -45,8 +28,7 @@ export class RouterPlugin {
45
28
  }
46
29
  return path2;
47
30
  };
48
- const chunkToSource = /* @__PURE__ */ new Map();
49
- const chunkToMap = /* @__PURE__ */ new Map();
31
+ const chunkToSourceAndMap = /* @__PURE__ */ new Map();
50
32
  compiler.hooks.thisCompilation.tap(PLUGIN_NAME, (compilation) => {
51
33
  compilation.hooks.processAssets.tapPromise({
52
34
  name: PLUGIN_NAME,
@@ -62,37 +44,14 @@ export class RouterPlugin {
62
44
  if (!namedChunkGroups) {
63
45
  return;
64
46
  }
65
- const entryChunks = this.getEntryChunks(compilation, chunks);
66
- const entryChunkFiles = entryChunks.map((chunk) => [
67
- ...chunk.files || []
68
- ].find((fname) => fname.includes(".js")));
69
- const entryChunkFileIds = entryChunks.map((chunk) => chunk.id);
70
- for (let i = 0; i <= entryChunkFiles.length - 1; i++) {
71
- const file = entryChunkFiles[i];
72
- const chunkId = entryChunkFileIds[i];
73
- const asset = compilation.assets[file];
74
- if (!asset) {
75
- continue;
76
- }
77
- const { map } = asset.sourceAndMap();
78
- chunkToMap.set(chunkId, map);
79
- }
80
- });
81
- compilation.hooks.processAssets.tapPromise({
82
- name: PLUGIN_NAME,
83
- stage: Compilation.PROCESS_ASSETS_STAGE_OPTIMIZE_TRANSFER
84
- }, async () => {
85
- const stats = compilation.getStats().toJson({
86
- all: false,
87
- chunkGroups: true,
88
- chunks: true,
89
- ids: true
47
+ const entrypointsArray = Array.from(compilation.entrypoints.entries());
48
+ const entryChunkIds = entrypointsArray.map((entrypoint) => entrypoint[0]);
49
+ const entryChunks = [
50
+ ...chunks
51
+ ].filter((chunk) => {
52
+ var _chunk_names;
53
+ return (_chunk_names = chunk.names) === null || _chunk_names === void 0 ? void 0 : _chunk_names.some((name) => entryChunkIds.includes(name));
90
54
  });
91
- const { chunks = [], namedChunkGroups } = stats;
92
- if (!namedChunkGroups) {
93
- return;
94
- }
95
- const entryChunks = this.getEntryChunks(compilation, chunks);
96
55
  const entryChunkFiles = entryChunks.map((chunk) => [
97
56
  ...chunk.files || []
98
57
  ].find((fname) => fname.includes(".js")));
@@ -104,8 +63,11 @@ export class RouterPlugin {
104
63
  if (!asset) {
105
64
  continue;
106
65
  }
107
- const { source } = asset.sourceAndMap();
108
- chunkToSource.set(chunkId, source);
66
+ const { source, map } = asset.sourceAndMap();
67
+ chunkToSourceAndMap.set(chunkId, {
68
+ source,
69
+ map
70
+ });
109
71
  }
110
72
  });
111
73
  compilation.hooks.processAssets.tapPromise({
@@ -138,7 +100,6 @@ export class RouterPlugin {
138
100
  const referenceCssAssets = assets.filter((asset) => /\.css$/.test(asset));
139
101
  routeAssets[name] = {
140
102
  chunkIds: chunkGroup.chunks,
141
- chunkName: chunkGroup.name,
142
103
  assets,
143
104
  referenceCssAssets
144
105
  };
@@ -154,29 +115,31 @@ export class RouterPlugin {
154
115
  const manifest = {
155
116
  routeAssets
156
117
  };
157
- const entryChunks = this.getEntryChunks(compilation, chunks);
158
- const entryChunkFiles = this.getEntryChunkFiles(entryChunks);
118
+ const entrypointsArray = Array.from(compilation.entrypoints.entries());
119
+ const entryChunkIds = entrypointsArray.map((entrypoint) => entrypoint[0]);
120
+ const entryChunks = [
121
+ ...chunks
122
+ ].filter((chunk) => {
123
+ var _chunk_names;
124
+ return (_chunk_names = chunk.names) === null || _chunk_names === void 0 ? void 0 : _chunk_names.some((name) => entryChunkIds.includes(name));
125
+ });
126
+ const entryChunkFiles = entryChunks.map((chunk) => [
127
+ ...chunk.files || []
128
+ ].find((fname) => fname.includes(".js")));
159
129
  const entryChunkFileIds = entryChunks.map((chunk) => chunk.id);
160
- for (let i = 0; i < entryChunkFiles.length; i++) {
130
+ for (let i = 0; i <= entryChunkFiles.length - 1; i++) {
161
131
  const file = entryChunkFiles[i];
162
- const chunkNames = entryChunks[i].names;
163
132
  const chunkId = entryChunkFileIds[i];
164
133
  const asset = compilation.assets[file];
165
134
  if (!asset || !chunkId) {
166
135
  continue;
167
136
  }
168
- let relatedAssets = {};
169
- if (entryChunkFiles.length > 1) {
170
- Object.keys(routeAssets).forEach((routeId) => {
171
- const segments = routeId.split("_");
172
- const chunkName = segments[0];
173
- if (chunkNames === null || chunkNames === void 0 ? void 0 : chunkNames.includes(chunkName)) {
174
- relatedAssets[routeId] = routeAssets[routeId];
175
- }
176
- });
177
- } else {
178
- relatedAssets = routeAssets;
179
- }
137
+ const relatedAssets = {};
138
+ Object.keys(routeAssets).forEach((routeId) => {
139
+ if (routeId.startsWith(`${chunkId}`)) {
140
+ relatedAssets[routeId] = routeAssets[routeId];
141
+ }
142
+ });
180
143
  const manifest2 = {
181
144
  routeAssets: relatedAssets
182
145
  };
@@ -192,13 +155,12 @@ export class RouterPlugin {
192
155
  })};
193
156
  })();
194
157
  `;
195
- const source = chunkToSource.get(chunkId);
196
- const map = chunkToMap.get(chunkId);
158
+ const { source, map } = chunkToSourceAndMap.get(chunkId);
197
159
  const newContent = `${injectedContent}${source.toString()}`;
198
160
  const result = await transform(newContent, {
199
161
  loader: path.extname(file).slice(1),
200
162
  sourcemap: true,
201
- minify: this.minimize
163
+ minify: process.env.NODE_ENV === "production"
202
164
  });
203
165
  const newSource = new SourceMapSource(result.code, file, result.map, source.toString(), map);
204
166
  compilation.updateAsset(
@@ -221,8 +183,4 @@ export class RouterPlugin {
221
183
  });
222
184
  });
223
185
  }
224
- constructor(options) {
225
- _define_property(this, "minimize", false);
226
- this.minimize = options.minimize;
227
- }
228
186
  }
@@ -3,7 +3,8 @@ import { logger } from "@modern-js/utils";
3
3
  import { generateRoutes } from "../utils/routes";
4
4
  import { buildServerConfig } from "../utils/config";
5
5
  export const build = async (api, options) => {
6
- if (options === null || options === void 0 ? void 0 : options.analyze) {
6
+ var _options;
7
+ if ((_options = options) === null || _options === void 0 ? void 0 : _options.analyze) {
7
8
  process.env.BUNDLE_ANALYZE = "true";
8
9
  }
9
10
  let resolvedConfig = api.useResolvedConfigContext();
@@ -1,5 +1,6 @@
1
1
  import { join } from "path";
2
2
  export const inspect = async (api, options) => {
3
+ var _appContext;
3
4
  const appContext = api.useAppContext();
4
5
  if (!appContext.builder) {
5
6
  throw new Error("Expect the Builder to have been initialized, But the appContext.builder received `undefined`");
@@ -7,7 +8,7 @@ export const inspect = async (api, options) => {
7
8
  return appContext.builder.inspectConfig({
8
9
  env: options.env,
9
10
  verbose: options.verbose,
10
- outputPath: join(appContext === null || appContext === void 0 ? void 0 : appContext.builder.context.distPath, options.output),
11
+ outputPath: join((_appContext = appContext) === null || _appContext === void 0 ? void 0 : _appContext.builder.context.distPath, options.output),
11
12
  writeToDisk: true
12
13
  });
13
14
  };
@@ -4,13 +4,13 @@ import { printInstructions } from "../utils/printInstructions";
4
4
  import { injectDataLoaderPlugin } from "../utils/createServer";
5
5
  import { getServerInternalPlugins } from "../utils/getServerInternalPlugins";
6
6
  export const start = async (api) => {
7
- var _userConfig_source, _userConfig_output_distPath;
7
+ var _userConfig_source, _userConfig, _userConfig_output_distPath;
8
8
  const appContext = api.useAppContext();
9
9
  const userConfig = api.useResolvedConfigContext();
10
10
  const hookRunners = api.useHookRunners();
11
11
  const { appDirectory, port, serverConfigFile, metaName } = appContext;
12
12
  logger.log(chalk.cyan(`Starting the modern server...`));
13
- const apiOnly = await isApiOnly(appContext.appDirectory, userConfig === null || userConfig === void 0 ? void 0 : (_userConfig_source = userConfig.source) === null || _userConfig_source === void 0 ? void 0 : _userConfig_source.entriesDir, appContext.apiDirectory);
13
+ const apiOnly = await isApiOnly(appContext.appDirectory, (_userConfig = userConfig) === null || _userConfig === void 0 ? void 0 : (_userConfig_source = _userConfig.source) === null || _userConfig_source === void 0 ? void 0 : _userConfig_source.entriesDir, appContext.apiDirectory);
14
14
  const serverInternalPlugins = await getServerInternalPlugins(api);
15
15
  const app = await server({
16
16
  pwd: appDirectory,
@@ -60,6 +60,7 @@ export const buildCommand = async (program, api) => {
60
60
  export const appTools = (options = {
61
61
  bundler: "webpack"
62
62
  }) => {
63
+ var _options, _options1;
63
64
  return {
64
65
  name: "@modern-js/app-tools",
65
66
  post: [
@@ -75,10 +76,10 @@ export const appTools = (options = {
75
76
  registerHook: hooks,
76
77
  usePlugins: [
77
78
  initializePlugin({
78
- bundler: (options === null || options === void 0 ? void 0 : options.bundler) === "experimental-rspack" ? "rspack" : "webpack"
79
+ bundler: ((_options = options) === null || _options === void 0 ? void 0 : _options.bundler) === "experimental-rspack" ? "rspack" : "webpack"
79
80
  }),
80
81
  analyzePlugin({
81
- bundler: (options === null || options === void 0 ? void 0 : options.bundler) === "experimental-rspack" ? "rspack" : "webpack"
82
+ bundler: ((_options1 = options) === null || _options1 === void 0 ? void 0 : _options1.bundler) === "experimental-rspack" ? "rspack" : "webpack"
82
83
  }),
83
84
  lintPlugin()
84
85
  ],
@@ -1,81 +1,79 @@
1
1
  import { ensureAbsolutePath, getPort, isDev, isDevCommand } from "@modern-js/utils";
2
2
  import { legacySchema, schema } from "../schema";
3
3
  import { checkIsLegacyConfig, createDefaultConfig, createLegacyDefaultConfig, transformNormalizedConfig } from "../config";
4
- export default ({ bundler }) => {
5
- return {
6
- name: "@modern-js/plugin-initialize",
7
- post: [
8
- "@modern-js/plugin-ssr",
9
- "@modern-js/plugin-document",
10
- "@modern-js/plugin-state",
11
- "@modern-js/plugin-router",
12
- "@modern-js/plugin-router-v5",
13
- "@modern-js/plugin-polyfill"
14
- ],
15
- setup(api) {
16
- const config = () => {
17
- const appContext = api.useAppContext();
4
+ export default ({ bundler }) => ({
5
+ name: "@modern-js/plugin-initialize",
6
+ post: [
7
+ "@modern-js/plugin-ssr",
8
+ "@modern-js/plugin-document",
9
+ "@modern-js/plugin-state",
10
+ "@modern-js/plugin-router",
11
+ "@modern-js/plugin-router-v5",
12
+ "@modern-js/plugin-polyfill"
13
+ ],
14
+ setup(api) {
15
+ const config = () => {
16
+ const appContext = api.useAppContext();
17
+ const userConfig = api.useConfigContext();
18
+ api.setAppContext({
19
+ ...appContext,
20
+ bundlerType: bundler
21
+ });
22
+ return checkIsLegacyConfig(userConfig) ? createLegacyDefaultConfig(appContext) : createDefaultConfig(appContext, bundler);
23
+ };
24
+ const validateSchema = () => {
25
+ const userConfig = api.useConfigContext();
26
+ const schemas = checkIsLegacyConfig(userConfig) ? legacySchema : schema;
27
+ return schemas.generate();
28
+ };
29
+ return {
30
+ config,
31
+ validateSchema,
32
+ async resolvedConfig({ resolved }) {
33
+ var _resolved_output_distPath;
34
+ let appContext = api.useAppContext();
18
35
  const userConfig = api.useConfigContext();
19
- api.setAppContext({
36
+ const port = await getServerPort(resolved);
37
+ appContext = {
20
38
  ...appContext,
21
- bundlerType: bundler
22
- });
23
- return checkIsLegacyConfig(userConfig) ? createLegacyDefaultConfig(appContext) : createDefaultConfig(appContext, bundler);
24
- };
25
- const validateSchema = () => {
26
- const userConfig = api.useConfigContext();
27
- const schemas = checkIsLegacyConfig(userConfig) ? legacySchema : schema;
28
- return schemas.generate();
29
- };
30
- return {
31
- config,
32
- validateSchema,
33
- async resolvedConfig({ resolved }) {
34
- var _resolved_output_distPath;
35
- let appContext = api.useAppContext();
36
- const userConfig = api.useConfigContext();
37
- const port = await getServerPort(resolved);
38
- appContext = {
39
- ...appContext,
40
- port,
41
- distDirectory: ensureAbsolutePath(appContext.distDirectory, ((_resolved_output_distPath = resolved.output.distPath) === null || _resolved_output_distPath === void 0 ? void 0 : _resolved_output_distPath.root) || "dist")
42
- };
43
- api.setAppContext(appContext);
44
- const normalizedConfig = checkIsLegacyConfig(resolved) ? transformNormalizedConfig(resolved) : resolved;
45
- resolved._raw = userConfig;
46
- resolved.server = {
47
- ...normalizedConfig.server || {},
48
- port
49
- };
50
- var _normalizedConfig_autoLoadPlugins;
51
- resolved.autoLoadPlugins = (_normalizedConfig_autoLoadPlugins = normalizedConfig.autoLoadPlugins) !== null && _normalizedConfig_autoLoadPlugins !== void 0 ? _normalizedConfig_autoLoadPlugins : false;
52
- stabilizeConfig(resolved, normalizedConfig, [
53
- "source",
54
- "bff",
55
- "dev",
56
- "html",
57
- "output",
58
- "tools",
59
- "testing",
60
- "plugins",
61
- "builderPlugins",
62
- "runtime",
63
- "runtimeByEntries",
64
- "deploy",
65
- "performance"
66
- ]);
67
- if (bundler === "webpack") {
68
- resolved.security = normalizedConfig.security || {};
69
- resolved.experiments = normalizedConfig.experiments;
70
- }
71
- return {
72
- resolved
73
- };
39
+ port,
40
+ distDirectory: ensureAbsolutePath(appContext.distDirectory, ((_resolved_output_distPath = resolved.output.distPath) === null || _resolved_output_distPath === void 0 ? void 0 : _resolved_output_distPath.root) || "dist")
41
+ };
42
+ api.setAppContext(appContext);
43
+ const normalizedConfig = checkIsLegacyConfig(resolved) ? transformNormalizedConfig(resolved) : resolved;
44
+ resolved._raw = userConfig;
45
+ resolved.server = {
46
+ ...normalizedConfig.server || {},
47
+ port
48
+ };
49
+ var _normalizedConfig_autoLoadPlugins;
50
+ resolved.autoLoadPlugins = (_normalizedConfig_autoLoadPlugins = normalizedConfig.autoLoadPlugins) !== null && _normalizedConfig_autoLoadPlugins !== void 0 ? _normalizedConfig_autoLoadPlugins : false;
51
+ stabilizeConfig(resolved, normalizedConfig, [
52
+ "source",
53
+ "bff",
54
+ "dev",
55
+ "html",
56
+ "output",
57
+ "tools",
58
+ "testing",
59
+ "plugins",
60
+ "builderPlugins",
61
+ "runtime",
62
+ "runtimeByEntries",
63
+ "deploy",
64
+ "performance"
65
+ ]);
66
+ if (bundler === "webpack") {
67
+ resolved.security = normalizedConfig.security || {};
68
+ resolved.experiments = normalizedConfig.experiments;
74
69
  }
75
- };
76
- }
77
- };
78
- };
70
+ return {
71
+ resolved
72
+ };
73
+ }
74
+ };
75
+ }
76
+ });
79
77
  function stabilizeConfig(resolve, config, keys) {
80
78
  keys.forEach((key) => {
81
79
  resolve[key] = config[key] || {};
@@ -3,21 +3,13 @@ import type { Rspack } from '@modern-js/builder-rspack-provider';
3
3
  export interface RouteAssets {
4
4
  [routeId: string]: {
5
5
  chunkIds?: (string | number)[];
6
- chunkName: string;
7
6
  assets?: string[];
8
7
  referenceCssAssets?: string[];
9
8
  };
10
9
  }
11
10
  type Compiler = webpack.Compiler | Rspack.Compiler;
12
- type Options = {
13
- minimize: boolean;
14
- };
15
11
  export declare class RouterPlugin {
16
- private minimize;
17
- constructor(options: Options);
18
12
  private isTargetNodeOrWebWorker;
19
- private getEntryChunks;
20
- private getEntryChunkFiles;
21
13
  apply(compiler: Compiler): void;
22
14
  }
23
15
  export {};
package/package.json CHANGED
@@ -15,7 +15,7 @@
15
15
  "modern",
16
16
  "modern.js"
17
17
  ],
18
- "version": "2.27.1-alpha.0",
18
+ "version": "2.28.0",
19
19
  "jsnext:source": "./src/index.ts",
20
20
  "types": "./dist/types/index.d.ts",
21
21
  "main": "./dist/cjs/index.js",
@@ -73,24 +73,24 @@
73
73
  "esbuild": "0.17.19",
74
74
  "rspack-plugin-virtual-module": "0.1.0",
75
75
  "@swc/helpers": "0.5.1",
76
- "@modern-js/builder": "2.27.0",
77
- "@modern-js/builder-webpack-provider": "2.27.0",
78
- "@modern-js/builder-plugin-esbuild": "2.27.0",
79
- "@modern-js/new-action": "2.27.0",
80
- "@modern-js/core": "2.27.0",
81
- "@modern-js/builder-shared": "2.27.0",
82
- "@modern-js/node-bundle-require": "2.27.0",
83
- "@modern-js/builder-plugin-node-polyfill": "2.27.0",
84
- "@modern-js/plugin-i18n": "2.27.0",
85
- "@modern-js/prod-server": "2.27.0",
86
- "@modern-js/plugin-lint": "2.27.0",
87
- "@modern-js/plugin": "2.27.0",
88
- "@modern-js/server": "2.27.0",
89
- "@modern-js/types": "2.27.0",
90
- "@modern-js/upgrade": "2.27.0",
91
- "@modern-js/utils": "2.27.0",
92
- "@modern-js/server-core": "2.27.0",
93
- "@modern-js/plugin-data-loader": "2.27.0"
76
+ "@modern-js/builder": "2.28.0",
77
+ "@modern-js/builder-plugin-esbuild": "2.28.0",
78
+ "@modern-js/builder-plugin-node-polyfill": "2.28.0",
79
+ "@modern-js/builder-shared": "2.28.0",
80
+ "@modern-js/builder-webpack-provider": "2.28.0",
81
+ "@modern-js/core": "2.28.0",
82
+ "@modern-js/new-action": "2.28.0",
83
+ "@modern-js/node-bundle-require": "2.28.0",
84
+ "@modern-js/plugin": "2.28.0",
85
+ "@modern-js/plugin-data-loader": "2.28.0",
86
+ "@modern-js/plugin-i18n": "2.28.0",
87
+ "@modern-js/plugin-lint": "2.28.0",
88
+ "@modern-js/prod-server": "2.28.0",
89
+ "@modern-js/server": "2.28.0",
90
+ "@modern-js/types": "2.28.0",
91
+ "@modern-js/upgrade": "2.28.0",
92
+ "@modern-js/utils": "2.28.0",
93
+ "@modern-js/server-core": "2.28.0"
94
94
  },
95
95
  "devDependencies": {
96
96
  "@types/babel__traverse": "^7.14.2",
@@ -99,13 +99,13 @@
99
99
  "jest": "^29",
100
100
  "typescript": "^5",
101
101
  "webpack": "^5.88.1",
102
- "@modern-js/builder-rspack-provider": "2.27.0",
103
- "@modern-js/builder-plugin-swc": "2.27.0",
104
- "@scripts/jest-config": "2.27.0",
105
- "@scripts/build": "2.27.0"
102
+ "@modern-js/builder-plugin-swc": "2.28.0",
103
+ "@modern-js/builder-rspack-provider": "2.28.0",
104
+ "@scripts/build": "2.28.0",
105
+ "@scripts/jest-config": "2.28.0"
106
106
  },
107
107
  "peerDependencies": {
108
- "@modern-js/builder-rspack-provider": "^2.27.0"
108
+ "@modern-js/builder-rspack-provider": "^2.28.0"
109
109
  },
110
110
  "peerDependenciesMeta": {
111
111
  "@modern-js/builder-rspack-provider": {