@modern-js/app-tools 2.60.4-alpha.1 → 2.60.4
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/cjs/plugins/analyze/getServerRoutes.js +4 -1
- package/dist/cjs/utils/register.js +22 -28
- package/dist/esm/plugins/analyze/getServerRoutes.js +6 -1
- package/dist/esm/utils/register.js +29 -53
- package/dist/esm-node/plugins/analyze/getServerRoutes.js +4 -1
- package/dist/esm-node/utils/register.js +22 -28
- package/package.json +16 -16
@@ -145,7 +145,10 @@ const collectStaticRoutes = (appContext, config) => {
|
|
145
145
|
const { appDirectory } = appContext;
|
146
146
|
const { source: { configDir }, server: { publicRoutes = {} } } = config;
|
147
147
|
const publicFolder = import_path.default.resolve(appDirectory, configDir || "", "public");
|
148
|
-
|
148
|
+
const ignoreFiles = [
|
149
|
+
".gitkeep"
|
150
|
+
];
|
151
|
+
return import_fs.default.existsSync(publicFolder) ? (0, import_utils2.walkDirectory)(publicFolder).filter((filePath) => !ignoreFiles.includes(import_path.default.basename(filePath))).map((filePath) => {
|
149
152
|
const urlPath = `${(0, import_utils.urlJoin)(toPosix(filePath).slice(toPosix(publicFolder).length))}`;
|
150
153
|
return {
|
151
154
|
urlPath: publicRoutes[(0, import_utils.removeLeadingSlash)(urlPath)] || urlPath,
|
@@ -81,44 +81,38 @@ const registerCompiler = async (appDir, distDir, alias) => {
|
|
81
81
|
tsConfig = (0, import_utils.readTsConfigByFile)(tsconfigPath);
|
82
82
|
}
|
83
83
|
const { MODERN_NODE_LOADER } = process.env;
|
84
|
-
if (MODERN_NODE_LOADER
|
84
|
+
if (MODERN_NODE_LOADER === "esbuild" || !isTsProject) {
|
85
|
+
await registerEsbuild({
|
86
|
+
isTsProject,
|
87
|
+
tsConfig,
|
88
|
+
distDir
|
89
|
+
});
|
90
|
+
} else {
|
85
91
|
try {
|
86
92
|
const tsNode = await (0, import_utils.loadFromProject)("ts-node", appDir);
|
87
93
|
const tsNodeOptions = tsConfig["ts-node"];
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
});
|
101
|
-
} else {
|
102
|
-
await registerEsbuild({
|
103
|
-
isTsProject,
|
104
|
-
tsConfig,
|
105
|
-
distDir
|
106
|
-
});
|
107
|
-
}
|
94
|
+
tsNode.register({
|
95
|
+
project: tsconfigPath,
|
96
|
+
scope: true,
|
97
|
+
// for env.d.ts, https://www.npmjs.com/package/ts-node#missing-types
|
98
|
+
files: true,
|
99
|
+
transpileOnly: true,
|
100
|
+
ignore: [
|
101
|
+
"(?:^|/)node_modules/",
|
102
|
+
`(?:^|/)${import_node_path.default.relative(appDir, distDir)}/`
|
103
|
+
],
|
104
|
+
...tsNodeOptions
|
105
|
+
});
|
108
106
|
} catch (error) {
|
109
|
-
|
107
|
+
if (process.env.DEBUG) {
|
108
|
+
import_utils.logger.error(error);
|
109
|
+
}
|
110
110
|
await registerEsbuild({
|
111
111
|
isTsProject,
|
112
112
|
tsConfig,
|
113
113
|
distDir
|
114
114
|
});
|
115
115
|
}
|
116
|
-
} else {
|
117
|
-
await registerEsbuild({
|
118
|
-
isTsProject,
|
119
|
-
tsConfig,
|
120
|
-
distDir
|
121
|
-
});
|
122
116
|
}
|
123
117
|
const tsConfigPaths = (await import("@modern-js/utils/tsconfig-paths")).default;
|
124
118
|
if (await import_utils.fs.pathExists(appDir)) {
|
@@ -110,7 +110,12 @@ var collectStaticRoutes = function(appContext, config) {
|
|
110
110
|
var appDirectory = appContext.appDirectory;
|
111
111
|
var configDir = config.source.configDir, _config_server = config.server, _config_server_publicRoutes = _config_server.publicRoutes, publicRoutes = _config_server_publicRoutes === void 0 ? {} : _config_server_publicRoutes;
|
112
112
|
var publicFolder = path.resolve(appDirectory, configDir || "", "public");
|
113
|
-
|
113
|
+
var ignoreFiles = [
|
114
|
+
".gitkeep"
|
115
|
+
];
|
116
|
+
return fs.existsSync(publicFolder) ? walkDirectory(publicFolder).filter(function(filePath) {
|
117
|
+
return !ignoreFiles.includes(path.basename(filePath));
|
118
|
+
}).map(function(filePath) {
|
114
119
|
var urlPath = "".concat(urlJoin(toPosix(filePath).slice(toPosix(publicFolder).length)));
|
115
120
|
return {
|
116
121
|
urlPath: publicRoutes[removeLeadingSlash(urlPath)] || urlPath,
|
@@ -82,31 +82,39 @@ var registerCompiler = function() {
|
|
82
82
|
tsConfig = readTsConfigByFile(tsconfigPath);
|
83
83
|
}
|
84
84
|
MODERN_NODE_LOADER = process.env.MODERN_NODE_LOADER;
|
85
|
-
if (!(MODERN_NODE_LOADER
|
85
|
+
if (!(MODERN_NODE_LOADER === "esbuild" || !isTsProject))
|
86
86
|
return [
|
87
87
|
3,
|
88
|
-
|
88
|
+
3
|
89
89
|
];
|
90
|
-
|
90
|
+
return [
|
91
|
+
4,
|
92
|
+
registerEsbuild({
|
93
|
+
isTsProject,
|
94
|
+
tsConfig,
|
95
|
+
distDir
|
96
|
+
})
|
97
|
+
];
|
91
98
|
case 2:
|
99
|
+
_state.sent();
|
100
|
+
return [
|
101
|
+
3,
|
102
|
+
7
|
103
|
+
];
|
104
|
+
case 3:
|
92
105
|
_state.trys.push([
|
93
|
-
|
94
|
-
|
106
|
+
3,
|
107
|
+
5,
|
95
108
|
,
|
96
|
-
|
109
|
+
7
|
97
110
|
]);
|
98
111
|
return [
|
99
112
|
4,
|
100
113
|
loadFromProject("ts-node", appDir)
|
101
114
|
];
|
102
|
-
case
|
115
|
+
case 4:
|
103
116
|
tsNode = _state.sent();
|
104
117
|
tsNodeOptions = tsConfig["ts-node"];
|
105
|
-
if (!isTsProject)
|
106
|
-
return [
|
107
|
-
3,
|
108
|
-
4
|
109
|
-
];
|
110
118
|
tsNode.register(_object_spread({
|
111
119
|
project: tsconfigPath,
|
112
120
|
scope: true,
|
@@ -120,28 +128,13 @@ var registerCompiler = function() {
|
|
120
128
|
}, tsNodeOptions));
|
121
129
|
return [
|
122
130
|
3,
|
123
|
-
|
124
|
-
];
|
125
|
-
case 4:
|
126
|
-
return [
|
127
|
-
4,
|
128
|
-
registerEsbuild({
|
129
|
-
isTsProject,
|
130
|
-
tsConfig,
|
131
|
-
distDir
|
132
|
-
})
|
131
|
+
7
|
133
132
|
];
|
134
133
|
case 5:
|
135
|
-
_state.sent();
|
136
|
-
_state.label = 6;
|
137
|
-
case 6:
|
138
|
-
return [
|
139
|
-
3,
|
140
|
-
9
|
141
|
-
];
|
142
|
-
case 7:
|
143
134
|
error = _state.sent();
|
144
|
-
|
135
|
+
if (process.env.DEBUG) {
|
136
|
+
logger.error(error);
|
137
|
+
}
|
145
138
|
return [
|
146
139
|
4,
|
147
140
|
registerEsbuild({
|
@@ -150,41 +143,24 @@ var registerCompiler = function() {
|
|
150
143
|
distDir
|
151
144
|
})
|
152
145
|
];
|
153
|
-
case
|
146
|
+
case 6:
|
154
147
|
_state.sent();
|
155
148
|
return [
|
156
149
|
3,
|
157
|
-
|
158
|
-
];
|
159
|
-
case 9:
|
160
|
-
return [
|
161
|
-
3,
|
162
|
-
12
|
150
|
+
7
|
163
151
|
];
|
164
|
-
case
|
165
|
-
return [
|
166
|
-
4,
|
167
|
-
registerEsbuild({
|
168
|
-
isTsProject,
|
169
|
-
tsConfig,
|
170
|
-
distDir
|
171
|
-
})
|
172
|
-
];
|
173
|
-
case 11:
|
174
|
-
_state.sent();
|
175
|
-
_state.label = 12;
|
176
|
-
case 12:
|
152
|
+
case 7:
|
177
153
|
return [
|
178
154
|
4,
|
179
155
|
import("@modern-js/utils/tsconfig-paths")
|
180
156
|
];
|
181
|
-
case
|
157
|
+
case 8:
|
182
158
|
tsConfigPaths = _state.sent().default;
|
183
159
|
return [
|
184
160
|
4,
|
185
161
|
fs.pathExists(appDir)
|
186
162
|
];
|
187
|
-
case
|
163
|
+
case 9:
|
188
164
|
if (_state.sent()) {
|
189
165
|
tsConfigPaths.register({
|
190
166
|
baseUrl: absoluteBaseUrl || "./",
|
@@ -112,7 +112,10 @@ const collectStaticRoutes = (appContext, config) => {
|
|
112
112
|
const { appDirectory } = appContext;
|
113
113
|
const { source: { configDir }, server: { publicRoutes = {} } } = config;
|
114
114
|
const publicFolder = path.resolve(appDirectory, configDir || "", "public");
|
115
|
-
|
115
|
+
const ignoreFiles = [
|
116
|
+
".gitkeep"
|
117
|
+
];
|
118
|
+
return fs.existsSync(publicFolder) ? walkDirectory(publicFolder).filter((filePath) => !ignoreFiles.includes(path.basename(filePath))).map((filePath) => {
|
116
119
|
const urlPath = `${urlJoin(toPosix(filePath).slice(toPosix(publicFolder).length))}`;
|
117
120
|
return {
|
118
121
|
urlPath: publicRoutes[removeLeadingSlash(urlPath)] || urlPath,
|
@@ -48,44 +48,38 @@ const registerCompiler = async (appDir, distDir, alias) => {
|
|
48
48
|
tsConfig = readTsConfigByFile(tsconfigPath);
|
49
49
|
}
|
50
50
|
const { MODERN_NODE_LOADER } = process.env;
|
51
|
-
if (MODERN_NODE_LOADER
|
51
|
+
if (MODERN_NODE_LOADER === "esbuild" || !isTsProject) {
|
52
|
+
await registerEsbuild({
|
53
|
+
isTsProject,
|
54
|
+
tsConfig,
|
55
|
+
distDir
|
56
|
+
});
|
57
|
+
} else {
|
52
58
|
try {
|
53
59
|
const tsNode = await loadFromProject("ts-node", appDir);
|
54
60
|
const tsNodeOptions = tsConfig["ts-node"];
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
});
|
68
|
-
} else {
|
69
|
-
await registerEsbuild({
|
70
|
-
isTsProject,
|
71
|
-
tsConfig,
|
72
|
-
distDir
|
73
|
-
});
|
74
|
-
}
|
61
|
+
tsNode.register({
|
62
|
+
project: tsconfigPath,
|
63
|
+
scope: true,
|
64
|
+
// for env.d.ts, https://www.npmjs.com/package/ts-node#missing-types
|
65
|
+
files: true,
|
66
|
+
transpileOnly: true,
|
67
|
+
ignore: [
|
68
|
+
"(?:^|/)node_modules/",
|
69
|
+
`(?:^|/)${path.relative(appDir, distDir)}/`
|
70
|
+
],
|
71
|
+
...tsNodeOptions
|
72
|
+
});
|
75
73
|
} catch (error) {
|
76
|
-
|
74
|
+
if (process.env.DEBUG) {
|
75
|
+
logger.error(error);
|
76
|
+
}
|
77
77
|
await registerEsbuild({
|
78
78
|
isTsProject,
|
79
79
|
tsConfig,
|
80
80
|
distDir
|
81
81
|
});
|
82
82
|
}
|
83
|
-
} else {
|
84
|
-
await registerEsbuild({
|
85
|
-
isTsProject,
|
86
|
-
tsConfig,
|
87
|
-
distDir
|
88
|
-
});
|
89
83
|
}
|
90
84
|
const tsConfigPaths = (await import("@modern-js/utils/tsconfig-paths")).default;
|
91
85
|
if (await fs.pathExists(appDir)) {
|
package/package.json
CHANGED
@@ -15,7 +15,7 @@
|
|
15
15
|
"modern",
|
16
16
|
"modern.js"
|
17
17
|
],
|
18
|
-
"version": "2.60.4
|
18
|
+
"version": "2.60.4",
|
19
19
|
"jsnext:source": "./src/index.ts",
|
20
20
|
"types": "./dist/types/index.d.ts",
|
21
21
|
"main": "./dist/cjs/index.js",
|
@@ -88,19 +88,19 @@
|
|
88
88
|
"mlly": "^1.6.1",
|
89
89
|
"pkg-types": "^1.1.0",
|
90
90
|
"std-env": "^3.7.0",
|
91
|
-
"@modern-js/core": "2.60.
|
92
|
-
"@modern-js/
|
93
|
-
"@modern-js/plugin-
|
94
|
-
"@modern-js/
|
95
|
-
"@modern-js/prod-server": "2.60.
|
96
|
-
"@modern-js/
|
97
|
-
"@modern-js/
|
98
|
-
"@modern-js/server": "2.60.
|
99
|
-
"@modern-js/
|
100
|
-
"@modern-js/
|
101
|
-
"@modern-js/server-
|
102
|
-
"@modern-js/
|
103
|
-
"@modern-js/
|
91
|
+
"@modern-js/core": "2.60.4",
|
92
|
+
"@modern-js/plugin": "2.60.4",
|
93
|
+
"@modern-js/plugin-data-loader": "2.60.4",
|
94
|
+
"@modern-js/node-bundle-require": "2.60.4",
|
95
|
+
"@modern-js/prod-server": "2.60.4",
|
96
|
+
"@modern-js/rsbuild-plugin-esbuild": "2.60.4",
|
97
|
+
"@modern-js/plugin-i18n": "2.60.4",
|
98
|
+
"@modern-js/server": "2.60.4",
|
99
|
+
"@modern-js/server-utils": "2.60.4",
|
100
|
+
"@modern-js/types": "2.60.4",
|
101
|
+
"@modern-js/server-core": "2.60.4",
|
102
|
+
"@modern-js/uni-builder": "2.60.4",
|
103
|
+
"@modern-js/utils": "2.60.4"
|
104
104
|
},
|
105
105
|
"devDependencies": {
|
106
106
|
"@rsbuild/plugin-webpack-swc": "~1.0.3",
|
@@ -112,8 +112,8 @@
|
|
112
112
|
"tsconfig-paths": "^4.2.0",
|
113
113
|
"typescript": "^5",
|
114
114
|
"webpack": "^5.95.0",
|
115
|
-
"@scripts/build": "2.60.
|
116
|
-
"@scripts/jest-config": "2.60.
|
115
|
+
"@scripts/build": "2.60.4",
|
116
|
+
"@scripts/jest-config": "2.60.4"
|
117
117
|
},
|
118
118
|
"peerDependencies": {
|
119
119
|
"ts-node": "^10.7.0",
|