@modern-js/app-tools 3.4.0 → 3.6.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/generator/index.js +7 -0
- package/dist/cjs/index.js +1 -0
- package/dist/esm/builder/generator/index.mjs +7 -0
- package/dist/esm/index.mjs +1 -0
- package/dist/esm-node/builder/generator/index.mjs +7 -0
- package/dist/esm-node/builder/shared/builderPlugins/adapterBasic.mjs +2 -2
- package/dist/esm-node/index.mjs +1 -0
- package/dist/esm-node/plugins/deploy/utils/index.mjs +3 -3
- package/dist/types/types/plugin.d.ts +6 -0
- package/package.json +15 -15
|
@@ -48,6 +48,13 @@ async function generateBuilder(options, bundlerType) {
|
|
|
48
48
|
else mergedEnvironments[name] = builderConfig.environments[name];
|
|
49
49
|
builderConfig.environments = mergedEnvironments;
|
|
50
50
|
} else builderConfig.environments = environments;
|
|
51
|
+
const hooks = appContext._internalContext.pluginAPI?.getHooks();
|
|
52
|
+
if (hooks?.modifyBuilderEnvironments) {
|
|
53
|
+
const { environments: modifiedEnvironments } = await hooks.modifyBuilderEnvironments.call({
|
|
54
|
+
environments: builderConfig.environments
|
|
55
|
+
});
|
|
56
|
+
builderConfig.environments = modifiedEnvironments;
|
|
57
|
+
}
|
|
51
58
|
const builder = await (0, builder_namespaceObject.createBuilder)({
|
|
52
59
|
cwd: appContext.appDirectory,
|
|
53
60
|
rscClientRuntimePath: `@${appContext.metaName}/runtime/rsc/client`,
|
package/dist/cjs/index.js
CHANGED
|
@@ -195,6 +195,7 @@ var __webpack_exports__ = {};
|
|
|
195
195
|
deploy: (0, _modern_js_plugin__rspack_import_3.createAsyncHook)(),
|
|
196
196
|
checkEntryPoint: (0, _modern_js_plugin__rspack_import_3.createAsyncHook)(),
|
|
197
197
|
modifyEntrypoints: (0, _modern_js_plugin__rspack_import_3.createAsyncHook)(),
|
|
198
|
+
modifyBuilderEnvironments: (0, _modern_js_plugin__rspack_import_3.createAsyncHook)(),
|
|
198
199
|
modifyFileSystemRoutes: (0, _modern_js_plugin__rspack_import_3.createAsyncHook)(),
|
|
199
200
|
generateEntryCode: (0, _modern_js_plugin__rspack_import_3.createAsyncHook)(),
|
|
200
201
|
onBeforeGenerateRoutes: (0, _modern_js_plugin__rspack_import_3.createAsyncHook)(),
|
|
@@ -16,6 +16,13 @@ async function generateBuilder(options, bundlerType) {
|
|
|
16
16
|
else mergedEnvironments[name] = builderConfig.environments[name];
|
|
17
17
|
builderConfig.environments = mergedEnvironments;
|
|
18
18
|
} else builderConfig.environments = environments;
|
|
19
|
+
const hooks = appContext._internalContext.pluginAPI?.getHooks();
|
|
20
|
+
if (hooks?.modifyBuilderEnvironments) {
|
|
21
|
+
const { environments: modifiedEnvironments } = await hooks.modifyBuilderEnvironments.call({
|
|
22
|
+
environments: builderConfig.environments
|
|
23
|
+
});
|
|
24
|
+
builderConfig.environments = modifiedEnvironments;
|
|
25
|
+
}
|
|
19
26
|
const builder = await createBuilder({
|
|
20
27
|
cwd: appContext.appDirectory,
|
|
21
28
|
rscClientRuntimePath: `@${appContext.metaName}/runtime/rsc/client`,
|
package/dist/esm/index.mjs
CHANGED
|
@@ -40,6 +40,7 @@ const appTools = ()=>({
|
|
|
40
40
|
deploy: createAsyncHook(),
|
|
41
41
|
checkEntryPoint: createAsyncHook(),
|
|
42
42
|
modifyEntrypoints: createAsyncHook(),
|
|
43
|
+
modifyBuilderEnvironments: createAsyncHook(),
|
|
43
44
|
modifyFileSystemRoutes: createAsyncHook(),
|
|
44
45
|
generateEntryCode: createAsyncHook(),
|
|
45
46
|
onBeforeGenerateRoutes: createAsyncHook(),
|
|
@@ -17,6 +17,13 @@ async function generateBuilder(options, bundlerType) {
|
|
|
17
17
|
else mergedEnvironments[name] = builderConfig.environments[name];
|
|
18
18
|
builderConfig.environments = mergedEnvironments;
|
|
19
19
|
} else builderConfig.environments = environments;
|
|
20
|
+
const hooks = appContext._internalContext.pluginAPI?.getHooks();
|
|
21
|
+
if (hooks?.modifyBuilderEnvironments) {
|
|
22
|
+
const { environments: modifiedEnvironments } = await hooks.modifyBuilderEnvironments.call({
|
|
23
|
+
environments: builderConfig.environments
|
|
24
|
+
});
|
|
25
|
+
builderConfig.environments = modifiedEnvironments;
|
|
26
|
+
}
|
|
20
27
|
const builder = await createBuilder({
|
|
21
28
|
cwd: appContext.appDirectory,
|
|
22
29
|
rscClientRuntimePath: `@${appContext.metaName}/runtime/rsc/client`,
|
|
@@ -3,7 +3,7 @@ import node_path from "node:path";
|
|
|
3
3
|
import { SERVICE_WORKER_ENVIRONMENT_NAME } from "@modern-js/builder";
|
|
4
4
|
import { fileURLToPath as __rspack_fileURLToPath } from "node:url";
|
|
5
5
|
import { dirname as __rspack_dirname } from "node:path";
|
|
6
|
-
var
|
|
6
|
+
var __rspack_import_meta_dirname__ = __rspack_dirname(__rspack_fileURLToPath(import.meta.url));
|
|
7
7
|
const builderPluginAdapterBasic = (options)=>({
|
|
8
8
|
name: 'builder-plugin-adapter-modern-basic',
|
|
9
9
|
setup (api) {
|
|
@@ -14,7 +14,7 @@ const builderPluginAdapterBasic = (options)=>({
|
|
|
14
14
|
const bareServerModuleReg = /\.(server|node)\.[tj]sx?$/;
|
|
15
15
|
const depExt = 'mjs';
|
|
16
16
|
chain.module.rule(CHAIN_ID.RULE.JS).exclude.add(bareServerModuleReg);
|
|
17
|
-
chain.module.rule('bare-server-module').test(bareServerModuleReg).use('server-module-loader').loader(node_path.join(
|
|
17
|
+
chain.module.rule('bare-server-module').test(bareServerModuleReg).use('server-module-loader').loader(node_path.join(__rspack_import_meta_dirname__, `../loaders/serverModuleLoader.${depExt}`));
|
|
18
18
|
}
|
|
19
19
|
const { appContext } = options;
|
|
20
20
|
const { metaName } = appContext;
|
package/dist/esm-node/index.mjs
CHANGED
|
@@ -42,6 +42,7 @@ const appTools = ()=>({
|
|
|
42
42
|
deploy: createAsyncHook(),
|
|
43
43
|
checkEntryPoint: createAsyncHook(),
|
|
44
44
|
modifyEntrypoints: createAsyncHook(),
|
|
45
|
+
modifyBuilderEnvironments: createAsyncHook(),
|
|
45
46
|
modifyFileSystemRoutes: createAsyncHook(),
|
|
46
47
|
generateEntryCode: createAsyncHook(),
|
|
47
48
|
onBeforeGenerateRoutes: createAsyncHook(),
|
|
@@ -4,7 +4,7 @@ import path from "path";
|
|
|
4
4
|
import { ROUTE_SPEC_FILE, SERVER_DIR, fs, getMeta } from "@modern-js/utils";
|
|
5
5
|
import { fileURLToPath as __rspack_fileURLToPath } from "node:url";
|
|
6
6
|
import { dirname as __rspack_dirname } from "node:path";
|
|
7
|
-
var
|
|
7
|
+
var __rspack_import_meta_dirname__ = __rspack_dirname(__rspack_fileURLToPath(import.meta.url));
|
|
8
8
|
const normalizePath = (filePath)=>filePath.replace(/\\/g, '/');
|
|
9
9
|
const getProjectUsage = (appDirectory, distDirectory, metaName)=>{
|
|
10
10
|
const routeJSON = path.join(distDirectory, ROUTE_SPEC_FILE);
|
|
@@ -27,7 +27,7 @@ const getProjectUsage = (appDirectory, distDirectory, metaName)=>{
|
|
|
27
27
|
useWebServer: isServerConfigExists
|
|
28
28
|
};
|
|
29
29
|
};
|
|
30
|
-
const getTemplatePath = (file)=>path.join(
|
|
30
|
+
const getTemplatePath = (file)=>path.join(__rspack_import_meta_dirname__, '../platforms/templates', file);
|
|
31
31
|
const readTemplate = async (file)=>(await fs.readFile(getTemplatePath(file))).toString();
|
|
32
32
|
const resolveESMDependency = async (entry)=>{
|
|
33
33
|
const conditions = new Set([
|
|
@@ -38,7 +38,7 @@ const resolveESMDependency = async (entry)=>{
|
|
|
38
38
|
]);
|
|
39
39
|
try {
|
|
40
40
|
const { moduleResolve } = await import("import-meta-resolve");
|
|
41
|
-
return normalizePath(moduleResolve(entry, pathToFileURL(`${
|
|
41
|
+
return normalizePath(moduleResolve(entry, pathToFileURL(`${__rspack_import_meta_dirname__}/`), conditions, false).pathname.replace(/^\/(\w)\:/, '$1:'));
|
|
42
42
|
} catch (err) {}
|
|
43
43
|
};
|
|
44
44
|
export { getProjectUsage, getTemplatePath, normalizePath, readTemplate, resolveESMDependency };
|
|
@@ -2,6 +2,7 @@ import type { AppContext, AsyncHook, InternalContext, PluginHook, PluginHookTap,
|
|
|
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
4
|
import type { EagerRouteComponentFilesByEntry } from '@modern-js/utils';
|
|
5
|
+
import type { EnvironmentConfig } from '@rsbuild/core';
|
|
5
6
|
import type { AppTools } from '.';
|
|
6
7
|
import type { getHookRunners } from '../compat/hooks';
|
|
7
8
|
import type { AppToolsNormalizedConfig, AppToolsUserConfig } from './config';
|
|
@@ -13,6 +14,9 @@ export type CheckEntryPointFn = TransformFunction<{
|
|
|
13
14
|
export type ModifyEntrypointsFn = TransformFunction<{
|
|
14
15
|
entrypoints: Entrypoint[];
|
|
15
16
|
}>;
|
|
17
|
+
export type ModifyBuilderEnvironmentsFn = TransformFunction<{
|
|
18
|
+
environments: Record<string, EnvironmentConfig>;
|
|
19
|
+
}>;
|
|
16
20
|
export type ModifyFileSystemRoutesFn = TransformFunction<{
|
|
17
21
|
entrypoint: Entrypoint;
|
|
18
22
|
routes: RouteLegacy[] | (NestedRouteForCli | PageRoute)[];
|
|
@@ -34,6 +38,7 @@ export interface AppToolsExtendAPI {
|
|
|
34
38
|
deploy: PluginHookTap<DeplpoyFn>;
|
|
35
39
|
checkEntryPoint: PluginHookTap<CheckEntryPointFn>;
|
|
36
40
|
modifyEntrypoints: PluginHookTap<ModifyEntrypointsFn>;
|
|
41
|
+
modifyBuilderEnvironments: PluginHookTap<ModifyBuilderEnvironmentsFn>;
|
|
37
42
|
modifyFileSystemRoutes: PluginHookTap<ModifyFileSystemRoutesFn>;
|
|
38
43
|
generateEntryCode: PluginHookTap<GenerateEntryCodeFn>;
|
|
39
44
|
onBeforeGenerateRoutes: PluginHookTap<BeforeGenerateRoutesFn>;
|
|
@@ -63,6 +68,7 @@ export interface AppToolsExtendHooks extends Record<string, PluginHook<(...args:
|
|
|
63
68
|
deploy: AsyncHook<DeplpoyFn>;
|
|
64
69
|
checkEntryPoint: AsyncHook<CheckEntryPointFn>;
|
|
65
70
|
modifyEntrypoints: AsyncHook<ModifyEntrypointsFn>;
|
|
71
|
+
modifyBuilderEnvironments: AsyncHook<ModifyBuilderEnvironmentsFn>;
|
|
66
72
|
modifyFileSystemRoutes: AsyncHook<ModifyFileSystemRoutesFn>;
|
|
67
73
|
generateEntryCode: AsyncHook<GenerateEntryCodeFn>;
|
|
68
74
|
onBeforeGenerateRoutes: AsyncHook<BeforeGenerateRoutesFn>;
|
package/package.json
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"modern",
|
|
16
16
|
"modern.js"
|
|
17
17
|
],
|
|
18
|
-
"version": "3.
|
|
18
|
+
"version": "3.6.0",
|
|
19
19
|
"types": "./dist/types/index.d.ts",
|
|
20
20
|
"main": "./dist/cjs/index.js",
|
|
21
21
|
"exports": {
|
|
@@ -83,7 +83,7 @@
|
|
|
83
83
|
"@babel/parser": "^7.29.7",
|
|
84
84
|
"@babel/traverse": "^7.29.7",
|
|
85
85
|
"@babel/types": "^7.29.7",
|
|
86
|
-
"@rsbuild/core": "2.0
|
|
86
|
+
"@rsbuild/core": "2.1.0",
|
|
87
87
|
"@swc/core": "1.15.41",
|
|
88
88
|
"@swc/helpers": "^0.5.17",
|
|
89
89
|
"es-module-lexer": "^1.7.0",
|
|
@@ -93,26 +93,26 @@
|
|
|
93
93
|
"ndepe": "^0.1.13",
|
|
94
94
|
"pkg-types": "^1.3.1",
|
|
95
95
|
"std-env": "^3.10.0",
|
|
96
|
-
"@modern-js/builder": "3.
|
|
97
|
-
"@modern-js/
|
|
98
|
-
"@modern-js/plugin": "3.
|
|
99
|
-
"@modern-js/
|
|
100
|
-
"@modern-js/prod-server": "3.
|
|
101
|
-
"@modern-js/server
|
|
102
|
-
"@modern-js/server": "3.
|
|
103
|
-
"@modern-js/server-utils": "3.
|
|
104
|
-
"@modern-js/types": "3.
|
|
105
|
-
"@modern-js/utils": "3.
|
|
96
|
+
"@modern-js/builder": "3.6.0",
|
|
97
|
+
"@modern-js/i18n-utils": "3.6.0",
|
|
98
|
+
"@modern-js/plugin-data-loader": "3.6.0",
|
|
99
|
+
"@modern-js/plugin": "3.6.0",
|
|
100
|
+
"@modern-js/prod-server": "3.6.0",
|
|
101
|
+
"@modern-js/server": "3.6.0",
|
|
102
|
+
"@modern-js/server-core": "3.6.0",
|
|
103
|
+
"@modern-js/server-utils": "3.6.0",
|
|
104
|
+
"@modern-js/types": "3.6.0",
|
|
105
|
+
"@modern-js/utils": "3.6.0"
|
|
106
106
|
},
|
|
107
107
|
"devDependencies": {
|
|
108
|
-
"@rslib/core": "0.
|
|
108
|
+
"@rslib/core": "0.23.2",
|
|
109
109
|
"@types/babel__traverse": "7.28.0",
|
|
110
110
|
"@types/node": "^20",
|
|
111
111
|
"ts-node": "^10.9.2",
|
|
112
112
|
"tsconfig-paths": "^4.2.0",
|
|
113
113
|
"typescript": "^5",
|
|
114
|
-
"@
|
|
115
|
-
"@
|
|
114
|
+
"@scripts/rstest-config": "2.66.0",
|
|
115
|
+
"@modern-js/rslib": "2.68.10"
|
|
116
116
|
},
|
|
117
117
|
"peerDependencies": {
|
|
118
118
|
"ts-node": "^10.9.2",
|