@modern-js/app-tools 3.2.1 → 3.3.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.
- package/dist/cjs/builder/builder-rspack/index.js +9 -5
- package/dist/cjs/builder/generator/adapterCopy.js +9 -5
- package/dist/cjs/builder/generator/createBuilderProviderConfig.js +9 -5
- package/dist/cjs/builder/generator/createCopyPattern.js +9 -5
- package/dist/cjs/builder/generator/getBuilderEnvironments.js +9 -5
- package/dist/cjs/builder/generator/index.js +9 -5
- package/dist/cjs/builder/index.js +9 -5
- package/dist/cjs/builder/shared/builderPlugins/adapterBasic.js +9 -5
- package/dist/cjs/builder/shared/builderPlugins/adapterHtml.js +10 -6
- package/dist/cjs/builder/shared/builderPlugins/adapterSSR.js +37 -8
- package/dist/cjs/builder/shared/builderPlugins/builderHooks.js +12 -8
- package/dist/cjs/builder/shared/builderPlugins/index.js +9 -5
- package/dist/cjs/builder/shared/bundlerPlugins/HtmlAsyncChunkPlugin.js +9 -5
- package/dist/cjs/builder/shared/bundlerPlugins/HtmlBottomTemplate.js +12 -8
- package/dist/cjs/builder/shared/bundlerPlugins/RouterPlugin.js +9 -5
- package/dist/cjs/builder/shared/bundlerPlugins/index.js +9 -5
- package/dist/cjs/builder/shared/createCopyInfo.js +9 -5
- package/dist/cjs/builder/shared/index.js +9 -5
- package/dist/cjs/builder/shared/lazyCompilation.js +94 -0
- package/dist/cjs/builder/shared/loaders/serverModuleLoader.js +12 -8
- package/dist/cjs/commands/build.js +9 -5
- package/dist/cjs/commands/deploy.js +9 -5
- package/dist/cjs/commands/dev.js +9 -5
- package/dist/cjs/commands/index.js +9 -5
- package/dist/cjs/commands/info.js +9 -5
- package/dist/cjs/commands/inspect.js +12 -8
- package/dist/cjs/commands/serve.js +9 -5
- package/dist/cjs/compat/hooks.js +9 -5
- package/dist/cjs/compat/index.js +9 -5
- package/dist/cjs/compat/utils.js +9 -5
- package/dist/cjs/config/default.js +27 -7
- package/dist/cjs/config/index.js +9 -5
- package/dist/cjs/config/initialize/index.js +9 -5
- package/dist/cjs/config/initialize/inits.js +9 -5
- package/dist/cjs/constants.js +13 -9
- package/dist/cjs/defineConfig.js +12 -8
- package/dist/cjs/esm/register-esm.js +9 -5
- package/dist/cjs/esm/ts-node-loader.js +9 -5
- package/dist/cjs/esm/ts-paths-loader.js +9 -5
- package/dist/cjs/index.js +21 -16
- package/dist/cjs/locale/en.js +12 -8
- package/dist/cjs/locale/index.js +9 -5
- package/dist/cjs/locale/zh.js +12 -8
- package/dist/cjs/plugins/analyze/constants.js +14 -10
- package/dist/cjs/plugins/analyze/getBundleEntry.js +9 -5
- package/dist/cjs/plugins/analyze/getFileSystemEntry.js +9 -5
- package/dist/cjs/plugins/analyze/getHtmlTemplate.js +9 -5
- package/dist/cjs/plugins/analyze/getServerRoutes.js +9 -5
- package/dist/cjs/plugins/analyze/index.js +12 -6
- package/dist/cjs/plugins/analyze/isDefaultExportFunction.js +9 -5
- package/dist/cjs/plugins/analyze/templates.js +12 -8
- package/dist/cjs/plugins/analyze/utils.js +9 -5
- package/dist/cjs/plugins/deploy/index.js +9 -5
- package/dist/cjs/plugins/deploy/platforms/gh-pages.js +9 -5
- package/dist/cjs/plugins/deploy/platforms/netlify.js +9 -5
- package/dist/cjs/plugins/deploy/platforms/node.js +9 -5
- package/dist/cjs/plugins/deploy/platforms/vercel.js +9 -5
- package/dist/cjs/plugins/deploy/utils/generator.js +9 -5
- package/dist/cjs/plugins/deploy/utils/index.js +9 -5
- package/dist/cjs/plugins/initialize/index.js +19 -6
- package/dist/cjs/plugins/serverBuild.js +9 -5
- package/dist/cjs/plugins/serverRuntime.js +12 -8
- package/dist/cjs/rsbuild.js +9 -5
- package/dist/cjs/run/index.js +9 -5
- package/dist/cjs/types/config/index.js +9 -5
- package/dist/cjs/types/index.js +9 -5
- package/dist/cjs/utils/config.js +9 -5
- package/dist/cjs/utils/createServer.js +14 -10
- package/dist/cjs/utils/env.js +9 -5
- package/dist/cjs/utils/generateWatchFiles.js +9 -5
- package/dist/cjs/utils/getConfigFile.js +9 -5
- package/dist/cjs/utils/getSelectedEntries.js +9 -5
- package/dist/cjs/utils/initAppContext.js +9 -5
- package/dist/cjs/utils/loadPlugins.js +9 -5
- package/dist/cjs/utils/printInstructions.js +9 -5
- package/dist/cjs/utils/register.js +9 -5
- package/dist/cjs/utils/restart.js +9 -5
- package/dist/cjs/utils/routes.js +9 -5
- package/dist/esm/builder/shared/builderPlugins/adapterHtml.mjs +1 -1
- package/dist/esm/builder/shared/builderPlugins/adapterSSR.mjs +29 -4
- package/dist/esm/builder/shared/lazyCompilation.mjs +44 -0
- package/dist/esm/config/default.mjs +14 -1
- package/dist/esm/plugins/analyze/index.mjs +3 -1
- package/dist/esm/plugins/initialize/index.mjs +11 -2
- package/dist/esm-node/builder/shared/builderPlugins/adapterHtml.mjs +1 -1
- package/dist/esm-node/builder/shared/builderPlugins/adapterSSR.mjs +29 -4
- package/dist/esm-node/builder/shared/lazyCompilation.mjs +45 -0
- package/dist/esm-node/config/default.mjs +14 -1
- package/dist/esm-node/plugins/analyze/index.mjs +3 -1
- package/dist/esm-node/plugins/initialize/index.mjs +11 -2
- package/dist/types/builder/shared/lazyCompilation.d.ts +43 -0
- package/dist/types/builder/shared/types.d.ts +10 -0
- package/dist/types/config/default.d.ts +6 -0
- package/dist/types/types/plugin.d.ts +14 -0
- package/package.json +18 -18
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { type EagerRouteComponentFilesByEntry } from '@modern-js/utils';
|
|
2
|
+
export { type EagerRouteComponentFilesByEntry, type RouteComponentFileCollection, collectRouteComponentFiles, normalizeModulePath, } from '@modern-js/utils';
|
|
3
|
+
type ModuleLike = {
|
|
4
|
+
resource?: string;
|
|
5
|
+
};
|
|
6
|
+
type LazyCompilationTestFn = (m: ModuleLike) => boolean;
|
|
7
|
+
/** Matches Rspack's `LazyCompilationOptions['test']`. */
|
|
8
|
+
type LazyCompilationTest = RegExp | LazyCompilationTestFn | undefined;
|
|
9
|
+
export type EagerRouteComponentInfo = {
|
|
10
|
+
files: Set<string>;
|
|
11
|
+
/** Specifiers that could not be resolved, keyed by entry name. */
|
|
12
|
+
unresolvedByEntry: Map<string, string[]>;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Aggregate the per-entry route component data (collected by the router plugin
|
|
16
|
+
* during route generation and threaded in as
|
|
17
|
+
* `BuilderOptions.eagerRouteComponentFilesByEntry`) into the flat shape
|
|
18
|
+
* {@link planSSRLazyCompilation} expects: one Set of all route files plus the
|
|
19
|
+
* unresolved specifiers keyed by entry.
|
|
20
|
+
*/
|
|
21
|
+
export declare function aggregateEagerRouteComponentFiles(byEntry: EagerRouteComponentFilesByEntry | undefined): EagerRouteComponentInfo;
|
|
22
|
+
/**
|
|
23
|
+
* Build a `lazyCompilation.test` that forces route component modules to compile
|
|
24
|
+
* eagerly (so SSR first-screen chunk/CSS injection has the assets it needs at
|
|
25
|
+
* render time), while delegating all other modules to the user's `test`
|
|
26
|
+
* (defaulting to lazy when the user did not provide one).
|
|
27
|
+
*/
|
|
28
|
+
export declare function buildSSRLazyCompilationTest(eagerRouteFiles: Set<string>, userTest?: LazyCompilationTest): LazyCompilationTestFn;
|
|
29
|
+
export type SSRLazyPlan = {
|
|
30
|
+
apply: false;
|
|
31
|
+
unresolvedByEntry?: Map<string, string[]>;
|
|
32
|
+
} | {
|
|
33
|
+
apply: true;
|
|
34
|
+
lazyCompilation: Record<string, unknown>;
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* Decide whether to apply the route-eager lazy compilation for an SSR project.
|
|
38
|
+
* Checks unresolved route components FIRST: if any exist we cannot guarantee
|
|
39
|
+
* they are eager, so we skip the optimization (and surface them so the caller
|
|
40
|
+
* can warn) rather than silently leaving a route lazy. `current` is the
|
|
41
|
+
* existing `dev.lazyCompilation` value (lazy must be enabled for this to apply).
|
|
42
|
+
*/
|
|
43
|
+
export declare function planSSRLazyCompilation(current: unknown, info: EagerRouteComponentInfo): SSRLazyPlan;
|
|
@@ -1,6 +1,16 @@
|
|
|
1
|
+
import type { EagerRouteComponentFilesByEntry } from '@modern-js/utils';
|
|
1
2
|
import type { AppNormalizedConfig } from '../../types';
|
|
2
3
|
import type { AppToolsContext } from '../../types/plugin';
|
|
3
4
|
export type BuilderOptions = {
|
|
4
5
|
normalizedConfig: AppNormalizedConfig;
|
|
5
6
|
appContext: AppToolsContext;
|
|
7
|
+
/**
|
|
8
|
+
* Route component files collected from the FINAL file-system routes (after
|
|
9
|
+
* all `modifyFileSystemRoutes` consumers ran), keyed by entry name. Populated
|
|
10
|
+
* by the router plugin during route generation and threaded in here (read
|
|
11
|
+
* FRESH from the app context AFTER `generateEntryCode` runs) so the SSR
|
|
12
|
+
* builder plugin can force route component chunks eager under lazy
|
|
13
|
+
* compilation. Explicit param instead of a direct `_internalContext` read.
|
|
14
|
+
*/
|
|
15
|
+
eagerRouteComponentFilesByEntry?: EagerRouteComponentFilesByEntry;
|
|
6
16
|
};
|
|
@@ -1,3 +1,9 @@
|
|
|
1
1
|
import type { AppUserConfig } from '../types';
|
|
2
2
|
import type { AppToolsContext } from '../types/plugin';
|
|
3
3
|
export declare function createDefaultConfig(appContext: AppToolsContext): AppUserConfig;
|
|
4
|
+
/**
|
|
5
|
+
* Default-enable lazy compilation for pure CSR and stream SSR. Stream SSR keeps
|
|
6
|
+
* first-screen route assets correct via the route-eager lazyCompilation.test
|
|
7
|
+
* injected by the SSR builder plugin. String SSR, RSC and SSG stay disabled.
|
|
8
|
+
*/
|
|
9
|
+
export declare function isLazyCompilationSafeByDefault(userConfig: Pick<AppUserConfig, 'server' | 'output'>): boolean;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { AppContext, AsyncHook, InternalContext, PluginHook, PluginHookTap, TransformFunction } from '@modern-js/plugin';
|
|
2
2
|
import type { Hooks } from '@modern-js/plugin/cli';
|
|
3
3
|
import type { Entrypoint, HtmlPartials, HtmlTemplates, NestedRouteForCli, PageRoute, RouteLegacy, ServerPlugin, ServerRoute } from '@modern-js/types';
|
|
4
|
+
import type { EagerRouteComponentFilesByEntry } from '@modern-js/utils';
|
|
4
5
|
import type { AppTools } from '.';
|
|
5
6
|
import type { getHookRunners } from '../compat/hooks';
|
|
6
7
|
import type { AppToolsNormalizedConfig, AppToolsUserConfig } from './config';
|
|
@@ -109,6 +110,19 @@ export interface AppToolsExtendContext {
|
|
|
109
110
|
* @private
|
|
110
111
|
*/
|
|
111
112
|
bffRuntimeFramework?: string;
|
|
113
|
+
/**
|
|
114
|
+
* Route component files collected from the FINAL file-system routes (after all
|
|
115
|
+
* `modifyFileSystemRoutes` consumers ran), keyed by entry name. Populated by
|
|
116
|
+
* the router plugin during route generation and consumed (currently by stream
|
|
117
|
+
* SSR lazy compilation) to force route component chunks eager.
|
|
118
|
+
*
|
|
119
|
+
* Published via the app context (`api.updateAppContext`) by the router plugin,
|
|
120
|
+
* then read fresh when assembling the builder options and threaded into
|
|
121
|
+
* `BuilderOptions.eagerRouteComponentFilesByEntry`; the SSR builder plugin
|
|
122
|
+
* reads it from those options (not from the context directly).
|
|
123
|
+
* @private
|
|
124
|
+
*/
|
|
125
|
+
eagerRouteComponentFilesByEntry?: EagerRouteComponentFilesByEntry;
|
|
112
126
|
}
|
|
113
127
|
export type AppToolsContext = AppContext<AppTools> & AppToolsExtendContext;
|
|
114
128
|
export type AppToolsHooks = Hooks<AppToolsUserConfig, AppToolsNormalizedConfig, {}, {}> & AppToolsExtendHooks;
|
package/package.json
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"modern",
|
|
16
16
|
"modern.js"
|
|
17
17
|
],
|
|
18
|
-
"version": "3.
|
|
18
|
+
"version": "3.3.0",
|
|
19
19
|
"types": "./dist/types/index.d.ts",
|
|
20
20
|
"main": "./dist/cjs/index.js",
|
|
21
21
|
"exports": {
|
|
@@ -80,32 +80,32 @@
|
|
|
80
80
|
"modern-app": "./bin/modern.js"
|
|
81
81
|
},
|
|
82
82
|
"dependencies": {
|
|
83
|
-
"@babel/parser": "^7.29.
|
|
84
|
-
"@babel/traverse": "^7.29.
|
|
85
|
-
"@babel/types": "^7.29.
|
|
86
|
-
"@rsbuild/core": "2.0.
|
|
87
|
-
"@swc/core": "1.15.
|
|
83
|
+
"@babel/parser": "^7.29.7",
|
|
84
|
+
"@babel/traverse": "^7.29.7",
|
|
85
|
+
"@babel/types": "^7.29.7",
|
|
86
|
+
"@rsbuild/core": "2.0.10",
|
|
87
|
+
"@swc/core": "1.15.40",
|
|
88
88
|
"@swc/helpers": "^0.5.17",
|
|
89
89
|
"es-module-lexer": "^1.7.0",
|
|
90
|
-
"import-meta-resolve": "^4.2.0",
|
|
91
90
|
"flatted": "^3.4.2",
|
|
91
|
+
"import-meta-resolve": "^4.2.0",
|
|
92
92
|
"mlly": "^1.8.2",
|
|
93
93
|
"ndepe": "^0.1.13",
|
|
94
94
|
"pkg-types": "^1.3.1",
|
|
95
95
|
"std-env": "^3.10.0",
|
|
96
|
-
"@modern-js/
|
|
97
|
-
"@modern-js/plugin": "3.
|
|
98
|
-
"@modern-js/
|
|
99
|
-
"@modern-js/plugin-data-loader": "3.
|
|
100
|
-
"@modern-js/prod-server": "3.
|
|
101
|
-
"@modern-js/server": "3.
|
|
102
|
-
"@modern-js/server-core": "3.
|
|
103
|
-
"@modern-js/server-utils": "3.
|
|
104
|
-
"@modern-js/types": "3.
|
|
105
|
-
"@modern-js/utils": "3.
|
|
96
|
+
"@modern-js/i18n-utils": "3.3.0",
|
|
97
|
+
"@modern-js/plugin": "3.3.0",
|
|
98
|
+
"@modern-js/builder": "3.3.0",
|
|
99
|
+
"@modern-js/plugin-data-loader": "3.3.0",
|
|
100
|
+
"@modern-js/prod-server": "3.3.0",
|
|
101
|
+
"@modern-js/server": "3.3.0",
|
|
102
|
+
"@modern-js/server-core": "3.3.0",
|
|
103
|
+
"@modern-js/server-utils": "3.3.0",
|
|
104
|
+
"@modern-js/types": "3.3.0",
|
|
105
|
+
"@modern-js/utils": "3.3.0"
|
|
106
106
|
},
|
|
107
107
|
"devDependencies": {
|
|
108
|
-
"@rslib/core": "0.
|
|
108
|
+
"@rslib/core": "0.22.0",
|
|
109
109
|
"@types/babel__traverse": "7.28.0",
|
|
110
110
|
"@types/node": "^20",
|
|
111
111
|
"ts-node": "^10.9.2",
|