@modern-js/app-tools 3.1.5 → 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/builder/generator/createBuilderProviderConfig.js +4 -0
- package/dist/cjs/builder/generator/createCopyPattern.js +2 -2
- package/dist/cjs/builder/index.js +1 -1
- package/dist/cjs/commands/build.js +2 -1
- package/dist/cjs/commands/dev.js +2 -1
- package/dist/cjs/commands/index.js +2 -2
- package/dist/cjs/compat/utils.js +2 -2
- package/dist/cjs/config/default.js +1 -0
- package/dist/cjs/esm/ts-node-loader.js +1 -1
- package/dist/cjs/plugins/analyze/getFileSystemEntry.js +2 -2
- package/dist/cjs/plugins/analyze/utils.js +4 -4
- package/dist/cjs/plugins/deploy/utils/generator.js +3 -3
- package/dist/cjs/plugins/deploy/utils/index.js +1 -1
- package/dist/cjs/plugins/serverBuild.js +1 -2
- package/dist/cjs/utils/loadPlugins.js +2 -2
- package/dist/cjs/utils/register.js +3 -4
- package/dist/esm/builder/generator/createBuilderProviderConfig.mjs +4 -0
- package/dist/esm/commands/build.mjs +2 -1
- package/dist/esm/commands/dev.mjs +2 -1
- package/dist/esm/config/default.mjs +1 -0
- package/dist/esm/plugins/serverBuild.mjs +2 -3
- package/dist/esm/utils/register.mjs +2 -3
- package/dist/esm-node/builder/generator/createBuilderProviderConfig.mjs +4 -0
- package/dist/esm-node/commands/build.mjs +2 -1
- package/dist/esm-node/commands/dev.mjs +2 -1
- package/dist/esm-node/config/default.mjs +1 -0
- package/dist/esm-node/plugins/serverBuild.mjs +2 -3
- package/dist/esm-node/utils/register.mjs +2 -3
- package/dist/types/types/config/source.d.ts +14 -0
- package/dist/types/utils/register.d.ts +6 -0
- package/lib/types.d.ts +1 -0
- package/package.json +14 -14
|
@@ -56,6 +56,9 @@ function createBuilderProviderConfig(resolveConfig, appContext) {
|
|
|
56
56
|
resolve: {
|
|
57
57
|
...resolveConfig.resolve
|
|
58
58
|
},
|
|
59
|
+
source: {
|
|
60
|
+
...resolveConfig.source
|
|
61
|
+
},
|
|
59
62
|
dev: {
|
|
60
63
|
...resolveConfig.dev,
|
|
61
64
|
port: appContext.port
|
|
@@ -81,6 +84,7 @@ function createBuilderProviderConfig(resolveConfig, appContext) {
|
|
|
81
84
|
}
|
|
82
85
|
}
|
|
83
86
|
};
|
|
87
|
+
if (config.source?.enableAsyncEntry && config.source?.enableAsyncPreEntry) delete config.source.preEntry;
|
|
84
88
|
modifyOutputConfig(config, appContext);
|
|
85
89
|
return config;
|
|
86
90
|
}
|
|
@@ -24,8 +24,8 @@ var __webpack_require__ = {};
|
|
|
24
24
|
var __webpack_exports__ = {};
|
|
25
25
|
__webpack_require__.r(__webpack_exports__);
|
|
26
26
|
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
createPublicPattern: ()=>createPublicPattern,
|
|
28
|
+
createUploadPattern: ()=>createUploadPattern
|
|
29
29
|
});
|
|
30
30
|
const utils_namespaceObject = require("@modern-js/utils");
|
|
31
31
|
const index_js_namespaceObject = require("../shared/index.js");
|
|
@@ -24,9 +24,9 @@ var __webpack_require__ = {};
|
|
|
24
24
|
var __webpack_exports__ = {};
|
|
25
25
|
__webpack_require__.r(__webpack_exports__);
|
|
26
26
|
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
-
createBuilderGenerator: ()=>createBuilderGenerator,
|
|
28
27
|
builderPluginAdapterBasic: ()=>index_js_namespaceObject.builderPluginAdapterBasic,
|
|
29
28
|
builderPluginAdapterHooks: ()=>index_js_namespaceObject.builderPluginAdapterHooks,
|
|
29
|
+
createBuilderGenerator: ()=>createBuilderGenerator,
|
|
30
30
|
parseRspackConfig: ()=>builder_namespaceObject.parseRspackConfig
|
|
31
31
|
});
|
|
32
32
|
const builder_namespaceObject = require("@modern-js/builder");
|
|
@@ -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);
|
|
@@ -24,12 +24,12 @@ var __webpack_require__ = {};
|
|
|
24
24
|
var __webpack_exports__ = {};
|
|
25
25
|
__webpack_require__.r(__webpack_exports__);
|
|
26
26
|
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
+
buildCommand: ()=>buildCommand,
|
|
27
28
|
deployCommand: ()=>deployCommand,
|
|
28
29
|
devCommand: ()=>devCommand,
|
|
29
30
|
infoCommand: ()=>infoCommand,
|
|
30
31
|
inspectCommand: ()=>inspectCommand,
|
|
31
|
-
serverCommand: ()=>serverCommand
|
|
32
|
-
buildCommand: ()=>buildCommand
|
|
32
|
+
serverCommand: ()=>serverCommand
|
|
33
33
|
});
|
|
34
34
|
const index_js_namespaceObject = require("../locale/index.js");
|
|
35
35
|
const devCommand = async (program, api)=>{
|
package/dist/cjs/compat/utils.js
CHANGED
|
@@ -24,9 +24,9 @@ var __webpack_require__ = {};
|
|
|
24
24
|
var __webpack_exports__ = {};
|
|
25
25
|
__webpack_require__.r(__webpack_exports__);
|
|
26
26
|
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
+
transformHookParams: ()=>transformHookParams,
|
|
27
28
|
transformHookResult: ()=>transformHookResult,
|
|
28
|
-
transformHookRunner: ()=>transformHookRunner
|
|
29
|
-
transformHookParams: ()=>transformHookParams
|
|
29
|
+
transformHookRunner: ()=>transformHookRunner
|
|
30
30
|
});
|
|
31
31
|
const getHtmlTemplate_js_namespaceObject = require("../plugins/analyze/getHtmlTemplate.js");
|
|
32
32
|
function transformHookRunner(hookRunnerName) {
|
|
@@ -52,6 +52,7 @@ function createDefaultConfig(appContext) {
|
|
|
52
52
|
entries: void 0,
|
|
53
53
|
mainEntryName: utils_namespaceObject.DEFAULT_ENTRY_NAME,
|
|
54
54
|
enableAsyncEntry: false,
|
|
55
|
+
enableAsyncPreEntry: false,
|
|
55
56
|
disableDefaultEntries: false,
|
|
56
57
|
entriesDir: './src',
|
|
57
58
|
configDir: './config',
|
|
@@ -24,8 +24,8 @@ var __webpack_require__ = {};
|
|
|
24
24
|
var __webpack_exports__ = {};
|
|
25
25
|
__webpack_require__.r(__webpack_exports__);
|
|
26
26
|
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
-
load: ()=>load,
|
|
28
27
|
initialize: ()=>initialize,
|
|
28
|
+
load: ()=>load,
|
|
29
29
|
resolve: ()=>resolve
|
|
30
30
|
});
|
|
31
31
|
const external_url_namespaceObject = require("url");
|
|
@@ -34,8 +34,8 @@ var __webpack_exports__ = {};
|
|
|
34
34
|
__webpack_require__.r(__webpack_exports__);
|
|
35
35
|
__webpack_require__.d(__webpack_exports__, {
|
|
36
36
|
getFileSystemEntry: ()=>getFileSystemEntry,
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
hasEntry: ()=>hasEntry,
|
|
38
|
+
hasServerEntry: ()=>hasServerEntry
|
|
39
39
|
});
|
|
40
40
|
const external_fs_namespaceObject = require("fs");
|
|
41
41
|
var external_fs_default = /*#__PURE__*/ __webpack_require__.n(external_fs_namespaceObject);
|
|
@@ -33,13 +33,13 @@ var __webpack_require__ = {};
|
|
|
33
33
|
var __webpack_exports__ = {};
|
|
34
34
|
__webpack_require__.r(__webpack_exports__);
|
|
35
35
|
__webpack_require__.d(__webpack_exports__, {
|
|
36
|
-
|
|
36
|
+
checkIsBuildCommands: ()=>checkIsBuildCommands,
|
|
37
37
|
checkIsServeCommand: ()=>checkIsServeCommand,
|
|
38
|
-
replaceWithAlias: ()=>replaceWithAlias,
|
|
39
38
|
getServerCombinedModuleFile: ()=>getServerCombinedModuleFile,
|
|
40
|
-
walkDirectory: ()=>walkDirectory,
|
|
41
39
|
isSubDirOrEqual: ()=>isSubDirOrEqual,
|
|
42
|
-
|
|
40
|
+
parseModule: ()=>parseModule,
|
|
41
|
+
replaceWithAlias: ()=>replaceWithAlias,
|
|
42
|
+
walkDirectory: ()=>walkDirectory
|
|
43
43
|
});
|
|
44
44
|
const external_fs_namespaceObject = require("fs");
|
|
45
45
|
var external_fs_default = /*#__PURE__*/ __webpack_require__.n(external_fs_namespaceObject);
|
|
@@ -33,11 +33,11 @@ var __webpack_require__ = {};
|
|
|
33
33
|
var __webpack_exports__ = {};
|
|
34
34
|
__webpack_require__.r(__webpack_exports__);
|
|
35
35
|
__webpack_require__.d(__webpack_exports__, {
|
|
36
|
-
serverAppContextTemplate: ()=>serverAppContextTemplate,
|
|
37
|
-
getPluginsCode: ()=>getPluginsCode,
|
|
38
36
|
genPluginImportsCode: ()=>genPluginImportsCode,
|
|
39
37
|
generateHandler: ()=>generateHandler,
|
|
40
|
-
|
|
38
|
+
getPluginsCode: ()=>getPluginsCode,
|
|
39
|
+
getServerConfigPath: ()=>getServerConfigPath,
|
|
40
|
+
serverAppContextTemplate: ()=>serverAppContextTemplate
|
|
41
41
|
});
|
|
42
42
|
const external_node_path_namespaceObject = require("node:path");
|
|
43
43
|
var external_node_path_default = /*#__PURE__*/ __webpack_require__.n(external_node_path_namespaceObject);
|
|
@@ -33,8 +33,8 @@ var __webpack_require__ = {};
|
|
|
33
33
|
var __webpack_exports__ = {};
|
|
34
34
|
__webpack_require__.r(__webpack_exports__);
|
|
35
35
|
__webpack_require__.d(__webpack_exports__, {
|
|
36
|
-
getTemplatePath: ()=>getTemplatePath,
|
|
37
36
|
getProjectUsage: ()=>getProjectUsage,
|
|
37
|
+
getTemplatePath: ()=>getTemplatePath,
|
|
38
38
|
normalizePath: ()=>normalizePath,
|
|
39
39
|
readTemplate: ()=>readTemplate,
|
|
40
40
|
resolveESMDependency: ()=>resolveESMDependency
|
|
@@ -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);
|
|
@@ -24,9 +24,9 @@ var __webpack_require__ = {};
|
|
|
24
24
|
var __webpack_exports__ = {};
|
|
25
25
|
__webpack_require__.r(__webpack_exports__);
|
|
26
26
|
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
-
loadServerPlugins: ()=>loadServerPlugins,
|
|
28
27
|
getServerPlugins: ()=>getServerPlugins,
|
|
29
|
-
loadInternalPlugins: ()=>loadInternalPlugins
|
|
28
|
+
loadInternalPlugins: ()=>loadInternalPlugins,
|
|
29
|
+
loadServerPlugins: ()=>loadServerPlugins
|
|
30
30
|
});
|
|
31
31
|
const prod_server_namespaceObject = require("@modern-js/prod-server");
|
|
32
32
|
const utils_namespaceObject = require("@modern-js/utils");
|
|
@@ -33,8 +33,8 @@ var __webpack_require__ = {};
|
|
|
33
33
|
var __webpack_exports__ = {};
|
|
34
34
|
__webpack_require__.r(__webpack_exports__);
|
|
35
35
|
__webpack_require__.d(__webpack_exports__, {
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
resolveTsRuntimeRegisterMode: ()=>resolveTsRuntimeRegisterMode,
|
|
37
|
+
setupTsRuntime: ()=>setupTsRuntime
|
|
38
38
|
});
|
|
39
39
|
const external_node_path_namespaceObject = require("node:path");
|
|
40
40
|
var external_node_path_default = /*#__PURE__*/ __webpack_require__.n(external_node_path_namespaceObject);
|
|
@@ -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;
|
|
@@ -28,6 +28,9 @@ function createBuilderProviderConfig(resolveConfig, appContext) {
|
|
|
28
28
|
resolve: {
|
|
29
29
|
...resolveConfig.resolve
|
|
30
30
|
},
|
|
31
|
+
source: {
|
|
32
|
+
...resolveConfig.source
|
|
33
|
+
},
|
|
31
34
|
dev: {
|
|
32
35
|
...resolveConfig.dev,
|
|
33
36
|
port: appContext.port
|
|
@@ -53,6 +56,7 @@ function createBuilderProviderConfig(resolveConfig, appContext) {
|
|
|
53
56
|
}
|
|
54
57
|
}
|
|
55
58
|
};
|
|
59
|
+
if (config.source?.enableAsyncEntry && config.source?.enableAsyncPreEntry) delete config.source.preEntry;
|
|
56
60
|
modifyOutputConfig(config, appContext);
|
|
57
61
|
return config;
|
|
58
62
|
}
|
|
@@ -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;
|
|
@@ -29,6 +29,9 @@ function createBuilderProviderConfig(resolveConfig, appContext) {
|
|
|
29
29
|
resolve: {
|
|
30
30
|
...resolveConfig.resolve
|
|
31
31
|
},
|
|
32
|
+
source: {
|
|
33
|
+
...resolveConfig.source
|
|
34
|
+
},
|
|
32
35
|
dev: {
|
|
33
36
|
...resolveConfig.dev,
|
|
34
37
|
port: appContext.port
|
|
@@ -54,6 +57,7 @@ function createBuilderProviderConfig(resolveConfig, appContext) {
|
|
|
54
57
|
}
|
|
55
58
|
}
|
|
56
59
|
};
|
|
60
|
+
if (config.source?.enableAsyncEntry && config.source?.enableAsyncPreEntry) delete config.source.preEntry;
|
|
57
61
|
modifyOutputConfig(config, appContext);
|
|
58
62
|
return config;
|
|
59
63
|
}
|
|
@@ -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;
|
|
@@ -15,6 +15,11 @@ export type Entry = string | {
|
|
|
15
15
|
};
|
|
16
16
|
export type Entries = Record<string, Entry>;
|
|
17
17
|
export interface SourceUserConfig extends NonNullable<BuilderConfig['source']> {
|
|
18
|
+
/**
|
|
19
|
+
* Add code before each page entry. It will be executed before the page code.
|
|
20
|
+
* @default []
|
|
21
|
+
*/
|
|
22
|
+
preEntry?: string | string[];
|
|
18
23
|
/**
|
|
19
24
|
* Used to configure custom page entries.
|
|
20
25
|
*/
|
|
@@ -30,6 +35,15 @@ export interface SourceUserConfig extends NonNullable<BuilderConfig['source']> {
|
|
|
30
35
|
* @default false
|
|
31
36
|
*/
|
|
32
37
|
enableAsyncEntry?: boolean;
|
|
38
|
+
/**
|
|
39
|
+
* When enabled, framework will inject `source.preEntry` into the top of the
|
|
40
|
+
* auto-generated entry file (`index.jsx`) and will not pass `source.preEntry`
|
|
41
|
+
* to builder config.
|
|
42
|
+
* This is useful when `source.enableAsyncEntry` is enabled and you still want
|
|
43
|
+
* preEntry to run before the real entry code.
|
|
44
|
+
* @default false
|
|
45
|
+
*/
|
|
46
|
+
enableAsyncPreEntry?: boolean;
|
|
33
47
|
/**
|
|
34
48
|
* Used to disable the functionality of automatically identifying page entry points based on directory structure.
|
|
35
49
|
* @default false
|
|
@@ -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.1
|
|
18
|
+
"version": "3.2.1",
|
|
19
19
|
"types": "./dist/types/index.d.ts",
|
|
20
20
|
"main": "./dist/cjs/index.js",
|
|
21
21
|
"exports": {
|
|
@@ -80,11 +80,11 @@
|
|
|
80
80
|
"modern-app": "./bin/modern.js"
|
|
81
81
|
},
|
|
82
82
|
"dependencies": {
|
|
83
|
-
"@babel/parser": "^7.29.
|
|
83
|
+
"@babel/parser": "^7.29.3",
|
|
84
84
|
"@babel/traverse": "^7.29.0",
|
|
85
85
|
"@babel/types": "^7.29.0",
|
|
86
86
|
"@rsbuild/core": "2.0.0",
|
|
87
|
-
"@swc/core": "1.15.
|
|
87
|
+
"@swc/core": "1.15.33",
|
|
88
88
|
"@swc/helpers": "^0.5.17",
|
|
89
89
|
"es-module-lexer": "^1.7.0",
|
|
90
90
|
"import-meta-resolve": "^4.2.0",
|
|
@@ -93,19 +93,19 @@
|
|
|
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.1
|
|
97
|
-
"@modern-js/
|
|
98
|
-
"@modern-js/
|
|
99
|
-
"@modern-js/plugin-data-loader": "3.1
|
|
100
|
-
"@modern-js/
|
|
101
|
-
"@modern-js/server": "3.1
|
|
102
|
-
"@modern-js/server-core": "3.1
|
|
103
|
-
"@modern-js/
|
|
104
|
-
"@modern-js/
|
|
105
|
-
"@modern-js/utils": "3.1
|
|
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",
|