@modern-js/app-tools 3.2.0 → 3.2.1
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/commands/build.js +2 -1
- package/dist/cjs/commands/dev.js +2 -1
- package/dist/cjs/plugins/serverBuild.js +1 -2
- package/dist/cjs/utils/register.js +1 -2
- package/dist/esm/commands/build.mjs +2 -1
- package/dist/esm/commands/dev.mjs +2 -1
- package/dist/esm/plugins/serverBuild.mjs +2 -3
- package/dist/esm/utils/register.mjs +2 -3
- package/dist/esm-node/commands/build.mjs +2 -1
- package/dist/esm-node/commands/dev.mjs +2 -1
- package/dist/esm-node/plugins/serverBuild.mjs +2 -3
- package/dist/esm-node/utils/register.mjs +2 -3
- package/dist/types/utils/register.d.ts +6 -0
- package/lib/types.d.ts +1 -0
- package/package.json +14 -14
|
@@ -71,7 +71,8 @@ const build = async (api, options)=>{
|
|
|
71
71
|
const combinedAlias = [].concat(resolvedConfig?.resolve?.alias ?? []).concat(resolvedConfig?.source?.alias ?? []);
|
|
72
72
|
await (0, loadPlugins_js_namespaceObject.loadServerPlugins)(api, appContext.appDirectory, appContext.metaName);
|
|
73
73
|
await (0, register_js_namespaceObject.setupTsRuntime)(appContext.appDirectory, appContext.distDirectory, combinedAlias, {
|
|
74
|
-
moduleType: appContext.moduleType
|
|
74
|
+
moduleType: appContext.moduleType,
|
|
75
|
+
tsconfigPath: resolvedConfig?.server?.tsconfigPath
|
|
75
76
|
});
|
|
76
77
|
const { apiOnly } = appContext;
|
|
77
78
|
if (apiOnly) {
|
package/dist/cjs/commands/dev.js
CHANGED
|
@@ -52,7 +52,8 @@ const dev = async (api, options, devServerOptions)=>{
|
|
|
52
52
|
const hooks = api.getHooks();
|
|
53
53
|
const combinedAlias = [].concat(normalizedConfig?.resolve?.alias ?? []).concat(normalizedConfig?.source?.alias ?? []);
|
|
54
54
|
await (0, register_js_namespaceObject.setupTsRuntime)(appContext.appDirectory, appContext.distDirectory, combinedAlias, {
|
|
55
|
-
moduleType: appContext.moduleType
|
|
55
|
+
moduleType: appContext.moduleType,
|
|
56
|
+
tsconfigPath: normalizedConfig?.server?.tsconfigPath
|
|
56
57
|
});
|
|
57
58
|
const { appDirectory, port, apiOnly, metaName, serverRoutes } = appContext;
|
|
58
59
|
const meta = (0, utils_namespaceObject.getMeta)(metaName);
|
|
@@ -41,7 +41,6 @@ const external_path_namespaceObject = require("path");
|
|
|
41
41
|
var external_path_default = /*#__PURE__*/ __webpack_require__.n(external_path_namespaceObject);
|
|
42
42
|
const server_utils_namespaceObject = require("@modern-js/server-utils");
|
|
43
43
|
const utils_namespaceObject = require("@modern-js/utils");
|
|
44
|
-
const TS_CONFIG_FILENAME = 'tsconfig.json';
|
|
45
44
|
function checkHasCache(appDir) {
|
|
46
45
|
const tsFilepath = external_path_default().resolve(appDir, utils_namespaceObject.SERVER_DIR, 'cache.ts');
|
|
47
46
|
const jsfilepath = external_path_default().resolve(appDir, utils_namespaceObject.SERVER_DIR, 'cache.js');
|
|
@@ -63,7 +62,7 @@ const serverBuild = ()=>({
|
|
|
63
62
|
const distDir = external_path_default().resolve(distDirectory);
|
|
64
63
|
const serverDir = external_path_default().resolve(appDirectory, utils_namespaceObject.SERVER_DIR);
|
|
65
64
|
const sharedDir = external_path_default().resolve(appDirectory, utils_namespaceObject.SHARED_DIR);
|
|
66
|
-
const tsconfigPath =
|
|
65
|
+
const tsconfigPath = (0, utils_namespaceObject.resolveServerTsconfig)(appDirectory, modernConfig?.server?.tsconfigPath);
|
|
67
66
|
const sourceDirs = [];
|
|
68
67
|
if (external_fs_default().existsSync(serverDir)) {
|
|
69
68
|
sourceDirs.push(serverDir);
|
|
@@ -94,8 +94,7 @@ const resolveTsRuntimeRegisterMode = (hasTsNode)=>{
|
|
|
94
94
|
return 'unsupported';
|
|
95
95
|
};
|
|
96
96
|
const setupTsRuntime = async (appDir, distDir, alias, options = {})=>{
|
|
97
|
-
const
|
|
98
|
-
const tsconfigPath = external_node_path_default().resolve(appDir, TS_CONFIG_FILENAME);
|
|
97
|
+
const tsconfigPath = (0, utils_namespaceObject.resolveServerTsconfig)(appDir, options.tsconfigPath);
|
|
99
98
|
const isTsProject = await utils_namespaceObject.fs.pathExists(tsconfigPath);
|
|
100
99
|
const hasTsNode = (0, utils_namespaceObject.isDepExists)(appDir, 'ts-node');
|
|
101
100
|
if (!isTsProject) return;
|
|
@@ -33,7 +33,8 @@ const build = async (api, options)=>{
|
|
|
33
33
|
const combinedAlias = [].concat(resolvedConfig?.resolve?.alias ?? []).concat(resolvedConfig?.source?.alias ?? []);
|
|
34
34
|
await loadServerPlugins(api, appContext.appDirectory, appContext.metaName);
|
|
35
35
|
await setupTsRuntime(appContext.appDirectory, appContext.distDirectory, combinedAlias, {
|
|
36
|
-
moduleType: appContext.moduleType
|
|
36
|
+
moduleType: appContext.moduleType,
|
|
37
|
+
tsconfigPath: resolvedConfig?.server?.tsconfigPath
|
|
37
38
|
});
|
|
38
39
|
const { apiOnly } = appContext;
|
|
39
40
|
if (apiOnly) {
|
|
@@ -14,7 +14,8 @@ const dev = async (api, options, devServerOptions)=>{
|
|
|
14
14
|
const hooks = api.getHooks();
|
|
15
15
|
const combinedAlias = [].concat(normalizedConfig?.resolve?.alias ?? []).concat(normalizedConfig?.source?.alias ?? []);
|
|
16
16
|
await setupTsRuntime(appContext.appDirectory, appContext.distDirectory, combinedAlias, {
|
|
17
|
-
moduleType: appContext.moduleType
|
|
17
|
+
moduleType: appContext.moduleType,
|
|
18
|
+
tsconfigPath: normalizedConfig?.server?.tsconfigPath
|
|
18
19
|
});
|
|
19
20
|
const { appDirectory, port, apiOnly, metaName, serverRoutes } = appContext;
|
|
20
21
|
const meta = getMeta(metaName);
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import fs from "fs";
|
|
2
2
|
import path from "path";
|
|
3
3
|
import { compile } from "@modern-js/server-utils";
|
|
4
|
-
import { SERVER_DIR, SHARED_DIR, getMeta } from "@modern-js/utils";
|
|
5
|
-
const TS_CONFIG_FILENAME = 'tsconfig.json';
|
|
4
|
+
import { SERVER_DIR, SHARED_DIR, getMeta, resolveServerTsconfig } from "@modern-js/utils";
|
|
6
5
|
function checkHasCache(appDir) {
|
|
7
6
|
const tsFilepath = path.resolve(appDir, SERVER_DIR, 'cache.ts');
|
|
8
7
|
const jsfilepath = path.resolve(appDir, SERVER_DIR, 'cache.js');
|
|
@@ -24,7 +23,7 @@ const serverBuild = ()=>({
|
|
|
24
23
|
const distDir = path.resolve(distDirectory);
|
|
25
24
|
const serverDir = path.resolve(appDirectory, SERVER_DIR);
|
|
26
25
|
const sharedDir = path.resolve(appDirectory, SHARED_DIR);
|
|
27
|
-
const tsconfigPath =
|
|
26
|
+
const tsconfigPath = resolveServerTsconfig(appDirectory, modernConfig?.server?.tsconfigPath);
|
|
28
27
|
const sourceDirs = [];
|
|
29
28
|
if (fs.existsSync(serverDir)) {
|
|
30
29
|
sourceDirs.push(serverDir);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import node_path from "node:path";
|
|
2
|
-
import { fs, getAliasConfig, isDepExists, loadFromProject, mergeAlias, readTsConfigByFile } from "@modern-js/utils";
|
|
2
|
+
import { fs, getAliasConfig, isDepExists, loadFromProject, mergeAlias, readTsConfigByFile, resolveServerTsconfig } from "@modern-js/utils";
|
|
3
3
|
const normalizePathValue = ({ key, value, absoluteBaseUrl })=>{
|
|
4
4
|
let normalizedValue = value;
|
|
5
5
|
if (key.startsWith('@') && normalizedValue.startsWith('@')) try {
|
|
@@ -55,8 +55,7 @@ const resolveTsRuntimeRegisterMode = (hasTsNode)=>{
|
|
|
55
55
|
return 'unsupported';
|
|
56
56
|
};
|
|
57
57
|
const setupTsRuntime = async (appDir, distDir, alias, options = {})=>{
|
|
58
|
-
const
|
|
59
|
-
const tsconfigPath = node_path.resolve(appDir, TS_CONFIG_FILENAME);
|
|
58
|
+
const tsconfigPath = resolveServerTsconfig(appDir, options.tsconfigPath);
|
|
60
59
|
const isTsProject = await fs.pathExists(tsconfigPath);
|
|
61
60
|
const hasTsNode = isDepExists(appDir, 'ts-node');
|
|
62
61
|
if (!isTsProject) return;
|
|
@@ -34,7 +34,8 @@ const build = async (api, options)=>{
|
|
|
34
34
|
const combinedAlias = [].concat(resolvedConfig?.resolve?.alias ?? []).concat(resolvedConfig?.source?.alias ?? []);
|
|
35
35
|
await loadServerPlugins(api, appContext.appDirectory, appContext.metaName);
|
|
36
36
|
await setupTsRuntime(appContext.appDirectory, appContext.distDirectory, combinedAlias, {
|
|
37
|
-
moduleType: appContext.moduleType
|
|
37
|
+
moduleType: appContext.moduleType,
|
|
38
|
+
tsconfigPath: resolvedConfig?.server?.tsconfigPath
|
|
38
39
|
});
|
|
39
40
|
const { apiOnly } = appContext;
|
|
40
41
|
if (apiOnly) {
|
|
@@ -15,7 +15,8 @@ const dev = async (api, options, devServerOptions)=>{
|
|
|
15
15
|
const hooks = api.getHooks();
|
|
16
16
|
const combinedAlias = [].concat(normalizedConfig?.resolve?.alias ?? []).concat(normalizedConfig?.source?.alias ?? []);
|
|
17
17
|
await setupTsRuntime(appContext.appDirectory, appContext.distDirectory, combinedAlias, {
|
|
18
|
-
moduleType: appContext.moduleType
|
|
18
|
+
moduleType: appContext.moduleType,
|
|
19
|
+
tsconfigPath: normalizedConfig?.server?.tsconfigPath
|
|
19
20
|
});
|
|
20
21
|
const { appDirectory, port, apiOnly, metaName, serverRoutes } = appContext;
|
|
21
22
|
const meta = getMeta(metaName);
|
|
@@ -2,8 +2,7 @@ import "node:module";
|
|
|
2
2
|
import fs from "fs";
|
|
3
3
|
import path from "path";
|
|
4
4
|
import { compile } from "@modern-js/server-utils";
|
|
5
|
-
import { SERVER_DIR, SHARED_DIR, getMeta } from "@modern-js/utils";
|
|
6
|
-
const TS_CONFIG_FILENAME = 'tsconfig.json';
|
|
5
|
+
import { SERVER_DIR, SHARED_DIR, getMeta, resolveServerTsconfig } from "@modern-js/utils";
|
|
7
6
|
function checkHasCache(appDir) {
|
|
8
7
|
const tsFilepath = path.resolve(appDir, SERVER_DIR, 'cache.ts');
|
|
9
8
|
const jsfilepath = path.resolve(appDir, SERVER_DIR, 'cache.js');
|
|
@@ -25,7 +24,7 @@ const serverBuild = ()=>({
|
|
|
25
24
|
const distDir = path.resolve(distDirectory);
|
|
26
25
|
const serverDir = path.resolve(appDirectory, SERVER_DIR);
|
|
27
26
|
const sharedDir = path.resolve(appDirectory, SHARED_DIR);
|
|
28
|
-
const tsconfigPath =
|
|
27
|
+
const tsconfigPath = resolveServerTsconfig(appDirectory, modernConfig?.server?.tsconfigPath);
|
|
29
28
|
const sourceDirs = [];
|
|
30
29
|
if (fs.existsSync(serverDir)) {
|
|
31
30
|
sourceDirs.push(serverDir);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import __rslib_shim_module__ from "node:module";
|
|
2
2
|
const require = /*#__PURE__*/ __rslib_shim_module__.createRequire(/*#__PURE__*/ (()=>import.meta.url)());
|
|
3
3
|
import node_path from "node:path";
|
|
4
|
-
import { fs, getAliasConfig, isDepExists, loadFromProject, mergeAlias, readTsConfigByFile } from "@modern-js/utils";
|
|
4
|
+
import { fs, getAliasConfig, isDepExists, loadFromProject, mergeAlias, readTsConfigByFile, resolveServerTsconfig } from "@modern-js/utils";
|
|
5
5
|
const normalizePathValue = ({ key, value, absoluteBaseUrl })=>{
|
|
6
6
|
let normalizedValue = value;
|
|
7
7
|
if (key.startsWith('@') && normalizedValue.startsWith('@')) try {
|
|
@@ -57,8 +57,7 @@ const resolveTsRuntimeRegisterMode = (hasTsNode)=>{
|
|
|
57
57
|
return 'unsupported';
|
|
58
58
|
};
|
|
59
59
|
const setupTsRuntime = async (appDir, distDir, alias, options = {})=>{
|
|
60
|
-
const
|
|
61
|
-
const tsconfigPath = node_path.resolve(appDir, TS_CONFIG_FILENAME);
|
|
60
|
+
const tsconfigPath = resolveServerTsconfig(appDir, options.tsconfigPath);
|
|
62
61
|
const isTsProject = await fs.pathExists(tsconfigPath);
|
|
63
62
|
const hasTsNode = isDepExists(appDir, 'ts-node');
|
|
64
63
|
if (!isTsProject) return;
|
|
@@ -3,6 +3,12 @@ import type { ConfigChain } from '@rsbuild/core';
|
|
|
3
3
|
type TsRuntimeRegisterMode = 'ts-node' | 'node-loader' | 'unsupported';
|
|
4
4
|
interface TsRuntimeSetupOptions {
|
|
5
5
|
moduleType?: string;
|
|
6
|
+
/**
|
|
7
|
+
* User-configured `server.tsconfigPath`. Forwarded into the shared
|
|
8
|
+
* resolveServerTsconfig helper. Resolved relative to appDir when not
|
|
9
|
+
* absolute. Falls back to `<appDir>/tsconfig.json` when unset.
|
|
10
|
+
*/
|
|
11
|
+
tsconfigPath?: string;
|
|
6
12
|
}
|
|
7
13
|
export declare const resolveTsRuntimeRegisterMode: (hasTsNode: boolean) => TsRuntimeRegisterMode;
|
|
8
14
|
/**
|
package/lib/types.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"modern",
|
|
16
16
|
"modern.js"
|
|
17
17
|
],
|
|
18
|
-
"version": "3.2.
|
|
18
|
+
"version": "3.2.1",
|
|
19
19
|
"types": "./dist/types/index.d.ts",
|
|
20
20
|
"main": "./dist/cjs/index.js",
|
|
21
21
|
"exports": {
|
|
@@ -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/
|
|
97
|
-
"@modern-js/
|
|
98
|
-
"@modern-js/
|
|
99
|
-
"@modern-js/plugin-data-loader": "3.2.
|
|
100
|
-
"@modern-js/server": "3.2.
|
|
101
|
-
"@modern-js/server
|
|
102
|
-
"@modern-js/
|
|
103
|
-
"@modern-js/
|
|
104
|
-
"@modern-js/
|
|
105
|
-
"@modern-js/utils": "3.2.
|
|
96
|
+
"@modern-js/builder": "3.2.1",
|
|
97
|
+
"@modern-js/plugin": "3.2.1",
|
|
98
|
+
"@modern-js/i18n-utils": "3.2.1",
|
|
99
|
+
"@modern-js/plugin-data-loader": "3.2.1",
|
|
100
|
+
"@modern-js/prod-server": "3.2.1",
|
|
101
|
+
"@modern-js/server": "3.2.1",
|
|
102
|
+
"@modern-js/server-core": "3.2.1",
|
|
103
|
+
"@modern-js/server-utils": "3.2.1",
|
|
104
|
+
"@modern-js/types": "3.2.1",
|
|
105
|
+
"@modern-js/utils": "3.2.1"
|
|
106
106
|
},
|
|
107
107
|
"devDependencies": {
|
|
108
|
-
"@rslib/core": "0.21.
|
|
108
|
+
"@rslib/core": "0.21.5",
|
|
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
|
+
"@modern-js/rslib": "2.68.10",
|
|
115
|
+
"@scripts/rstest-config": "2.66.0"
|
|
116
116
|
},
|
|
117
117
|
"peerDependencies": {
|
|
118
118
|
"ts-node": "^10.9.2",
|