@modern-js/app-tools 3.0.4 → 3.1.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/shared/builderPlugins/adapterSSR.js +1 -1
- package/dist/cjs/config/default.js +1 -1
- package/dist/cjs/index.js +14 -5
- package/dist/cjs/plugins/analyze/utils.js +6 -6
- package/dist/cjs/plugins/deploy/index.js +10 -5
- package/dist/cjs/plugins/deploy/platforms/gh-pages.js +1 -1
- package/dist/cjs/plugins/deploy/platforms/netlify.js +17 -33
- package/dist/cjs/plugins/deploy/platforms/node.js +17 -38
- package/dist/cjs/plugins/deploy/platforms/templates/netlify-entry.cjs +57 -0
- package/dist/cjs/plugins/deploy/platforms/templates/netlify-entry.mjs +59 -0
- package/dist/cjs/plugins/deploy/platforms/templates/node-entry.cjs +44 -0
- package/dist/{esm/plugins/deploy/platforms → cjs/plugins/deploy/platforms/templates}/node-entry.mjs +5 -27
- package/dist/cjs/plugins/deploy/platforms/templates/vercel-entry.cjs +56 -0
- package/dist/cjs/plugins/deploy/platforms/templates/vercel-entry.mjs +58 -0
- package/dist/cjs/plugins/deploy/platforms/vercel.js +15 -32
- package/dist/cjs/plugins/deploy/types.js +18 -0
- package/dist/cjs/plugins/deploy/utils/generator.js +103 -0
- package/dist/cjs/plugins/deploy/{utils.js → utils/index.js} +28 -24
- package/dist/cjs/rsbuild.js +74 -0
- package/dist/cjs/utils/getConfigFile.js +1 -1
- package/dist/cjs/utils/register.js +1 -9
- package/dist/esm/builder/shared/builderPlugins/adapterBasic.mjs +2 -2
- package/dist/esm/builder/shared/builderPlugins/adapterSSR.mjs +2 -2
- package/dist/esm/commands/build.mjs +3 -3
- package/dist/esm/commands/dev.mjs +5 -5
- package/dist/esm/commands/serve.mjs +2 -2
- package/dist/esm/config/default.mjs +1 -1
- package/dist/esm/esm/register-esm.mjs +3 -3
- package/dist/esm/index.mjs +2 -1
- package/dist/esm/plugins/analyze/utils.mjs +2 -2
- package/dist/esm/plugins/deploy/index.mjs +9 -4
- package/dist/esm/plugins/deploy/platforms/gh-pages.mjs +1 -1
- package/dist/esm/plugins/deploy/platforms/netlify.mjs +25 -41
- package/dist/esm/plugins/deploy/platforms/node.mjs +22 -43
- package/dist/esm/plugins/deploy/platforms/templates/netlify-entry.cjs +57 -0
- package/dist/esm/plugins/deploy/platforms/templates/netlify-entry.mjs +59 -0
- package/dist/esm/plugins/deploy/platforms/templates/node-entry.cjs +44 -0
- package/dist/esm/plugins/deploy/platforms/templates/node-entry.mjs +46 -0
- package/dist/esm/plugins/deploy/platforms/templates/vercel-entry.cjs +56 -0
- package/dist/esm/plugins/deploy/platforms/templates/vercel-entry.mjs +58 -0
- package/dist/esm/plugins/deploy/platforms/vercel.mjs +28 -45
- package/dist/esm/plugins/deploy/types.mjs +0 -0
- package/dist/esm/plugins/deploy/utils/generator.mjs +47 -0
- package/dist/esm/plugins/deploy/utils/index.mjs +40 -0
- package/dist/esm/rsbuild.mjs +40 -0
- package/dist/esm/utils/getConfigFile.mjs +1 -1
- package/dist/esm/utils/loadPlugins.mjs +4 -4
- package/dist/esm/utils/register.mjs +6 -14
- package/dist/esm-node/builder/shared/builderPlugins/adapterBasic.mjs +2 -2
- package/dist/esm-node/builder/shared/builderPlugins/adapterSSR.mjs +2 -2
- package/dist/esm-node/commands/build.mjs +3 -3
- package/dist/esm-node/commands/dev.mjs +5 -5
- package/dist/esm-node/commands/serve.mjs +2 -2
- package/dist/esm-node/config/default.mjs +1 -1
- package/dist/esm-node/esm/register-esm.mjs +3 -3
- package/dist/esm-node/index.mjs +2 -1
- package/dist/esm-node/plugins/analyze/utils.mjs +2 -2
- package/dist/esm-node/plugins/deploy/index.mjs +9 -4
- package/dist/esm-node/plugins/deploy/platforms/gh-pages.mjs +1 -1
- package/dist/esm-node/plugins/deploy/platforms/netlify.mjs +25 -44
- package/dist/esm-node/plugins/deploy/platforms/node.mjs +22 -46
- package/dist/esm-node/plugins/deploy/platforms/templates/netlify-entry.cjs +57 -0
- package/dist/esm-node/plugins/deploy/platforms/templates/netlify-entry.mjs +59 -0
- package/dist/esm-node/plugins/deploy/platforms/templates/node-entry.cjs +44 -0
- package/dist/esm-node/plugins/deploy/platforms/templates/node-entry.mjs +46 -0
- package/dist/esm-node/plugins/deploy/platforms/templates/vercel-entry.cjs +56 -0
- package/dist/esm-node/plugins/deploy/platforms/templates/vercel-entry.mjs +58 -0
- package/dist/esm-node/plugins/deploy/platforms/vercel.mjs +28 -48
- package/dist/esm-node/plugins/deploy/types.mjs +1 -0
- package/dist/esm-node/plugins/deploy/utils/generator.mjs +48 -0
- package/dist/esm-node/plugins/deploy/utils/index.mjs +44 -0
- package/dist/esm-node/rsbuild.mjs +41 -0
- package/dist/esm-node/utils/getConfigFile.mjs +1 -1
- package/dist/esm-node/utils/loadPlugins.mjs +4 -4
- package/dist/esm-node/utils/register.mjs +6 -14
- package/dist/types/index.d.ts +1 -0
- package/dist/types/plugins/analyze/utils.d.ts +1 -1
- package/dist/types/plugins/deploy/platforms/platform.d.ts +8 -1
- package/dist/types/plugins/deploy/platforms/templates/netlify-entry.d.mts +2 -0
- package/dist/types/plugins/deploy/platforms/templates/node-entry.d.mts +1 -0
- package/dist/types/plugins/deploy/platforms/templates/vercel-entry.d.cts +2 -0
- package/dist/types/plugins/deploy/platforms/templates/vercel-entry.d.mts +2 -0
- package/dist/types/plugins/deploy/types.d.ts +3 -0
- package/dist/types/plugins/deploy/utils/generator.d.ts +24 -0
- package/dist/types/plugins/deploy/utils/index.d.ts +16 -0
- package/dist/types/rsbuild.d.ts +12 -0
- package/dist/types/utils/getConfigFile.d.ts +1 -1
- package/package.json +16 -15
- package/rslib.config.mts +19 -0
- package/dist/cjs/plugins/deploy/platforms/netlify-entry.js +0 -36
- package/dist/cjs/plugins/deploy/platforms/netlify-handler.js +0 -89
- package/dist/cjs/plugins/deploy/platforms/node-entry.js +0 -75
- package/dist/cjs/plugins/deploy/platforms/vercel-entry.js +0 -37
- package/dist/cjs/plugins/deploy/platforms/vercel-handler.js +0 -89
- package/dist/esm/plugins/deploy/platforms/netlify-entry.mjs +0 -2
- package/dist/esm/plugins/deploy/platforms/netlify-handler.mjs +0 -85
- package/dist/esm/plugins/deploy/platforms/vercel-entry.mjs +0 -3
- package/dist/esm/plugins/deploy/platforms/vercel-handler.mjs +0 -85
- package/dist/esm/plugins/deploy/utils.mjs +0 -39
- package/dist/esm-node/plugins/deploy/platforms/netlify-entry.mjs +0 -3
- package/dist/esm-node/plugins/deploy/platforms/netlify-handler.mjs +0 -89
- package/dist/esm-node/plugins/deploy/platforms/node-entry.mjs +0 -72
- package/dist/esm-node/plugins/deploy/platforms/vercel-entry.mjs +0 -4
- package/dist/esm-node/plugins/deploy/platforms/vercel-handler.mjs +0 -89
- package/dist/esm-node/plugins/deploy/utils.mjs +0 -40
- package/dist/types/plugins/deploy/platforms/netlify-entry.d.cts +0 -2
- package/dist/types/plugins/deploy/platforms/netlify-entry.d.mts +0 -1
- package/dist/types/plugins/deploy/platforms/vercel-entry.d.mts +0 -2
- package/dist/types/plugins/deploy/platforms/vercel-entry.d.ts +0 -2
- package/dist/types/plugins/deploy/platforms/vercel-handler.d.cts +0 -1
- package/dist/types/plugins/deploy/utils.d.ts +0 -23
- /package/dist/types/plugins/deploy/platforms/{netlify-handler.d.cts → templates/netlify-entry.d.cts} +0 -0
- /package/dist/types/plugins/deploy/platforms/{node-entry.d.ts → templates/node-entry.d.cts} +0 -0
|
@@ -127,7 +127,7 @@ async function applySSRLoaderEntry(chain, optinos, isServer) {
|
|
|
127
127
|
const { entrypoints } = appContext;
|
|
128
128
|
await Promise.all(entrypoints.map(async (entrypoint)=>{
|
|
129
129
|
const { entryName } = entrypoint;
|
|
130
|
-
const serverLoadersFile = (0, utils_js_namespaceObject.
|
|
130
|
+
const serverLoadersFile = (0, utils_js_namespaceObject.getServerCombinedModuleFile)(internalDirectory, entryName);
|
|
131
131
|
if (isServer) try {
|
|
132
132
|
await utils_namespaceObject.fs.access(serverLoadersFile, utils_namespaceObject.fs.constants.F_OK);
|
|
133
133
|
chain.entry(`${entryName}-server-loaders`).add(serverLoadersFile);
|
|
@@ -32,7 +32,7 @@ function createDefaultConfig(appContext) {
|
|
|
32
32
|
const dev = {
|
|
33
33
|
cliShortcuts: {
|
|
34
34
|
help: false,
|
|
35
|
-
custom: (shortcuts = [])=>shortcuts.filter(({ key })=>'r' !== key && 'u' !== key)
|
|
35
|
+
custom: (shortcuts = [])=>shortcuts.filter(({ key })=>'r' !== key && 'u' !== key && 'o' !== key)
|
|
36
36
|
}
|
|
37
37
|
};
|
|
38
38
|
const output = {
|
package/dist/cjs/index.js
CHANGED
|
@@ -36,6 +36,9 @@ var __webpack_modules__ = {
|
|
|
36
36
|
"./plugins/serverRuntime" (module) {
|
|
37
37
|
module.exports = require("./plugins/serverRuntime.js");
|
|
38
38
|
},
|
|
39
|
+
"./rsbuild" (module) {
|
|
40
|
+
module.exports = require("./rsbuild.js");
|
|
41
|
+
},
|
|
39
42
|
"./types?6efa" (module) {
|
|
40
43
|
module.exports = require("./types/index.js");
|
|
41
44
|
},
|
|
@@ -117,7 +120,8 @@ var __webpack_exports__ = {};
|
|
|
117
120
|
dev: ()=>_commands_dev__rspack_import_18.dev,
|
|
118
121
|
generateWatchFiles: ()=>_utils_generateWatchFiles__rspack_import_14.generateWatchFiles,
|
|
119
122
|
initAppContext: ()=>_utils_initAppContext__rspack_import_15.initAppContext,
|
|
120
|
-
mergeConfig: ()=>
|
|
123
|
+
mergeConfig: ()=>_modern_js_plugin_cli__rspack_import_22.mergeConfig,
|
|
124
|
+
resolveModernRsbuildConfig: ()=>_rsbuild__rspack_import_20.resolveModernRsbuildConfig,
|
|
121
125
|
serve: ()=>_commands_serve__rspack_import_19.serve
|
|
122
126
|
});
|
|
123
127
|
var path__rspack_import_0 = __webpack_require__("path");
|
|
@@ -147,6 +151,7 @@ var __webpack_exports__ = {};
|
|
|
147
151
|
var __rspack_reexport = {};
|
|
148
152
|
for(const __rspack_import_key in _defineConfig__rspack_import_17)if ([
|
|
149
153
|
"dev",
|
|
154
|
+
"resolveModernRsbuildConfig",
|
|
150
155
|
"mergeConfig",
|
|
151
156
|
"appTools",
|
|
152
157
|
"default",
|
|
@@ -158,10 +163,12 @@ var __webpack_exports__ = {};
|
|
|
158
163
|
__webpack_require__.d(__webpack_exports__, __rspack_reexport);
|
|
159
164
|
var _commands_dev__rspack_import_18 = __webpack_require__("./commands/dev");
|
|
160
165
|
var _commands_serve__rspack_import_19 = __webpack_require__("./commands/serve");
|
|
161
|
-
var
|
|
166
|
+
var _rsbuild__rspack_import_20 = __webpack_require__("./rsbuild");
|
|
167
|
+
var _types__rspack_import_21 = __webpack_require__("./types?6efa");
|
|
162
168
|
var __rspack_reexport = {};
|
|
163
|
-
for(const __rspack_import_key in
|
|
169
|
+
for(const __rspack_import_key in _types__rspack_import_21)if ([
|
|
164
170
|
"dev",
|
|
171
|
+
"resolveModernRsbuildConfig",
|
|
165
172
|
"mergeConfig",
|
|
166
173
|
"appTools",
|
|
167
174
|
"default",
|
|
@@ -169,9 +176,9 @@ var __webpack_exports__ = {};
|
|
|
169
176
|
"generateWatchFiles",
|
|
170
177
|
"initAppContext",
|
|
171
178
|
"defineConfig"
|
|
172
|
-
].indexOf(__rspack_import_key) < 0) __rspack_reexport[__rspack_import_key] = ()=>
|
|
179
|
+
].indexOf(__rspack_import_key) < 0) __rspack_reexport[__rspack_import_key] = ()=>_types__rspack_import_21[__rspack_import_key];
|
|
173
180
|
__webpack_require__.d(__webpack_exports__, __rspack_reexport);
|
|
174
|
-
var
|
|
181
|
+
var _modern_js_plugin_cli__rspack_import_22 = __webpack_require__("@modern-js/plugin/cli");
|
|
175
182
|
const appTools = ()=>({
|
|
176
183
|
name: '@modern-js/app-tools',
|
|
177
184
|
usePlugins: [
|
|
@@ -278,6 +285,7 @@ exports.dev = __webpack_exports__.dev;
|
|
|
278
285
|
exports.generateWatchFiles = __webpack_exports__.generateWatchFiles;
|
|
279
286
|
exports.initAppContext = __webpack_exports__.initAppContext;
|
|
280
287
|
exports.mergeConfig = __webpack_exports__.mergeConfig;
|
|
288
|
+
exports.resolveModernRsbuildConfig = __webpack_exports__.resolveModernRsbuildConfig;
|
|
281
289
|
exports.serve = __webpack_exports__.serve;
|
|
282
290
|
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
283
291
|
"appTools",
|
|
@@ -287,6 +295,7 @@ for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
|
287
295
|
"generateWatchFiles",
|
|
288
296
|
"initAppContext",
|
|
289
297
|
"mergeConfig",
|
|
298
|
+
"resolveModernRsbuildConfig",
|
|
290
299
|
"serve"
|
|
291
300
|
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
292
301
|
Object.defineProperty(exports, '__esModule', {
|
|
@@ -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
|
-
checkIsBuildCommands: ()=>checkIsBuildCommands,
|
|
37
|
-
checkIsServeCommand: ()=>checkIsServeCommand,
|
|
38
36
|
parseModule: ()=>parseModule,
|
|
37
|
+
checkIsServeCommand: ()=>checkIsServeCommand,
|
|
39
38
|
replaceWithAlias: ()=>replaceWithAlias,
|
|
39
|
+
getServerCombinedModuleFile: ()=>getServerCombinedModuleFile,
|
|
40
40
|
walkDirectory: ()=>walkDirectory,
|
|
41
41
|
isSubDirOrEqual: ()=>isSubDirOrEqual,
|
|
42
|
-
|
|
42
|
+
checkIsBuildCommands: ()=>checkIsBuildCommands
|
|
43
43
|
});
|
|
44
44
|
const external_fs_namespaceObject = require("fs");
|
|
45
45
|
var external_fs_default = /*#__PURE__*/ __webpack_require__.n(external_fs_namespaceObject);
|
|
@@ -74,7 +74,7 @@ const parseModule = async ({ source, filename })=>{
|
|
|
74
74
|
}
|
|
75
75
|
return await (0, external_es_module_lexer_namespaceObject.parse)(content);
|
|
76
76
|
};
|
|
77
|
-
const
|
|
77
|
+
const getServerCombinedModuleFile = (internalDirectory, entryName)=>external_path_default().join(internalDirectory, entryName, 'server-loader-combined.js');
|
|
78
78
|
const checkIsBuildCommands = ()=>{
|
|
79
79
|
const buildCommands = [
|
|
80
80
|
'dev',
|
|
@@ -99,7 +99,7 @@ const isSubDirOrEqual = (parent, child)=>{
|
|
|
99
99
|
};
|
|
100
100
|
exports.checkIsBuildCommands = __webpack_exports__.checkIsBuildCommands;
|
|
101
101
|
exports.checkIsServeCommand = __webpack_exports__.checkIsServeCommand;
|
|
102
|
-
exports.
|
|
102
|
+
exports.getServerCombinedModuleFile = __webpack_exports__.getServerCombinedModuleFile;
|
|
103
103
|
exports.isSubDirOrEqual = __webpack_exports__.isSubDirOrEqual;
|
|
104
104
|
exports.parseModule = __webpack_exports__.parseModule;
|
|
105
105
|
exports.replaceWithAlias = __webpack_exports__.replaceWithAlias;
|
|
@@ -107,7 +107,7 @@ exports.walkDirectory = __webpack_exports__.walkDirectory;
|
|
|
107
107
|
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
108
108
|
"checkIsBuildCommands",
|
|
109
109
|
"checkIsServeCommand",
|
|
110
|
-
"
|
|
110
|
+
"getServerCombinedModuleFile",
|
|
111
111
|
"isSubDirOrEqual",
|
|
112
112
|
"parseModule",
|
|
113
113
|
"replaceWithAlias",
|
|
@@ -31,20 +31,25 @@ const gh_pages_js_namespaceObject = require("./platforms/gh-pages.js");
|
|
|
31
31
|
const netlify_js_namespaceObject = require("./platforms/netlify.js");
|
|
32
32
|
const node_js_namespaceObject = require("./platforms/node.js");
|
|
33
33
|
const vercel_js_namespaceObject = require("./platforms/vercel.js");
|
|
34
|
-
const
|
|
34
|
+
const index_js_namespaceObject = require("./utils/index.js");
|
|
35
35
|
const deployPresets = {
|
|
36
36
|
node: node_js_namespaceObject.createNodePreset,
|
|
37
37
|
vercel: vercel_js_namespaceObject.createVercelPreset,
|
|
38
38
|
netlify: netlify_js_namespaceObject.createNetlifyPreset,
|
|
39
39
|
ghPages: gh_pages_js_namespaceObject.createGhPagesPreset
|
|
40
40
|
};
|
|
41
|
-
async function getDeployPreset(appContext, modernConfig, deployTarget) {
|
|
41
|
+
async function getDeployPreset(appContext, modernConfig, deployTarget, api) {
|
|
42
42
|
const { appDirectory, distDirectory, metaName } = appContext;
|
|
43
|
-
const { useSSR, useAPI, useWebServer } = (0,
|
|
43
|
+
const { useSSR, useAPI, useWebServer } = (0, index_js_namespaceObject.getProjectUsage)(appDirectory, distDirectory, metaName);
|
|
44
44
|
const needModernServer = useSSR || useAPI || useWebServer;
|
|
45
45
|
const createPreset = deployPresets[deployTarget];
|
|
46
46
|
if (!createPreset) throw new Error(`Unknown deploy target: '${deployTarget}'. MODERNJS_DEPLOY should be 'node', 'vercel', or 'netlify'.`);
|
|
47
|
-
return createPreset(
|
|
47
|
+
return createPreset({
|
|
48
|
+
appContext,
|
|
49
|
+
modernConfig,
|
|
50
|
+
needModernServer,
|
|
51
|
+
api
|
|
52
|
+
});
|
|
48
53
|
}
|
|
49
54
|
const deploy = ()=>({
|
|
50
55
|
name: '@modern-js/plugin-deploy',
|
|
@@ -55,7 +60,7 @@ const deploy = ()=>({
|
|
|
55
60
|
const { metaName } = appContext;
|
|
56
61
|
if ('modern-js' !== metaName && !process.env.MODERNJS_DEPLOY) return;
|
|
57
62
|
const modernConfig = api.getNormalizedConfig();
|
|
58
|
-
const deployPreset = await getDeployPreset(appContext, modernConfig, deployTarget);
|
|
63
|
+
const deployPreset = await getDeployPreset(appContext, modernConfig, deployTarget, api);
|
|
59
64
|
deployPreset?.prepare && await deployPreset?.prepare();
|
|
60
65
|
deployPreset?.writeOutput && await deployPreset?.writeOutput();
|
|
61
66
|
deployPreset?.genEntry && await deployPreset?.genEntry();
|
|
@@ -61,7 +61,7 @@ async function reorganizeHtmlFiles(routes, baseDir, baseUrl = '/') {
|
|
|
61
61
|
});
|
|
62
62
|
await Promise.all(copyPromises);
|
|
63
63
|
}
|
|
64
|
-
const createGhPagesPreset = (appContext, modernConfig)=>{
|
|
64
|
+
const createGhPagesPreset = ({ appContext, modernConfig })=>{
|
|
65
65
|
const { serverRoutes, appDirectory, distDirectory } = appContext;
|
|
66
66
|
const { server: { baseUrl } } = modernConfig;
|
|
67
67
|
const outputDirectory = external_path_default().join(appDirectory, '.output');
|
|
@@ -40,7 +40,8 @@ var external_node_path_default = /*#__PURE__*/ __webpack_require__.n(external_no
|
|
|
40
40
|
const utils_namespaceObject = require("@modern-js/utils");
|
|
41
41
|
const external_ndepe_namespaceObject = require("ndepe");
|
|
42
42
|
const routes_js_namespaceObject = require("../../../utils/routes.js");
|
|
43
|
-
const
|
|
43
|
+
const index_js_namespaceObject = require("../utils/index.js");
|
|
44
|
+
const generator_js_namespaceObject = require("../utils/generator.js");
|
|
44
45
|
async function cleanDistDirectory(dir) {
|
|
45
46
|
try {
|
|
46
47
|
const items = await utils_namespaceObject.fs.readdir(dir);
|
|
@@ -52,17 +53,12 @@ async function cleanDistDirectory(dir) {
|
|
|
52
53
|
console.error('Error cleaning directory:', error);
|
|
53
54
|
}
|
|
54
55
|
}
|
|
55
|
-
const createNetlifyPreset = (appContext, modernConfig, needModernServer)=>{
|
|
56
|
-
const { appDirectory, distDirectory, entrypoints,
|
|
56
|
+
const createNetlifyPreset = ({ appContext, modernConfig, needModernServer })=>{
|
|
57
|
+
const { appDirectory, distDirectory, entrypoints, moduleType } = appContext;
|
|
57
58
|
const isEsmProject = 'module' === moduleType;
|
|
58
|
-
const plugins = serverPlugins.map((plugin)=>[
|
|
59
|
-
plugin.name,
|
|
60
|
-
plugin.options
|
|
61
|
-
]);
|
|
62
59
|
const netlifyOutput = external_node_path_default().join(appDirectory, '.netlify');
|
|
63
60
|
const funcsDirectory = external_node_path_default().join(netlifyOutput, 'functions');
|
|
64
61
|
const entryFilePath = external_node_path_default().join(funcsDirectory, 'index.js');
|
|
65
|
-
const handlerFilePath = external_node_path_default().join(funcsDirectory, 'netlify-handler.cjs');
|
|
66
62
|
return {
|
|
67
63
|
async prepare () {
|
|
68
64
|
await utils_namespaceObject.fs.remove(netlifyOutput);
|
|
@@ -99,39 +95,27 @@ const createNetlifyPreset = (appContext, modernConfig, needModernServer)=>{
|
|
|
99
95
|
},
|
|
100
96
|
async genEntry () {
|
|
101
97
|
if (!needModernServer) return;
|
|
102
|
-
const
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
}
|
|
111
|
-
};
|
|
112
|
-
const meta = (0, utils_namespaceObject.getMeta)(metaName);
|
|
113
|
-
const pluginImportCode = (0, external_utils_js_namespaceObject.genPluginImportsCode)(plugins || []);
|
|
114
|
-
const dynamicProdOptions = {
|
|
115
|
-
config: serverConfig
|
|
116
|
-
};
|
|
117
|
-
const serverConfigPath = `path.join(__dirname, "${utils_namespaceObject.SERVER_DIR}", "${meta}.server")`;
|
|
118
|
-
const pluginsCode = (0, external_utils_js_namespaceObject.getPluginsCode)(plugins);
|
|
119
|
-
let handlerCode = (await utils_namespaceObject.fs.readFile(external_node_path_default().join(__dirname, './netlify-handler.js'))).toString();
|
|
120
|
-
const serverAppContext = (0, external_utils_js_namespaceObject.serverAppContenxtTemplate)(appContext);
|
|
121
|
-
handlerCode = handlerCode.replace('p_genPluginImportsCode', pluginImportCode).replace('p_ROUTE_SPEC_FILE', `"${utils_namespaceObject.ROUTE_SPEC_FILE}"`).replace('p_dynamicProdOptions', JSON.stringify(dynamicProdOptions)).replace('p_plugins', pluginsCode).replace('p_bffRuntimeFramework', `"${serverAppContext.bffRuntimeFramework}"`).replace('p_serverDirectory', serverConfigPath).replace('p_sharedDirectory', serverAppContext.sharedDirectory).replace('p_apiDirectory', serverAppContext.apiDirectory).replace('p_lambdaDirectory', serverAppContext.lambdaDirectory);
|
|
122
|
-
await utils_namespaceObject.fs.writeFile(handlerFilePath, handlerCode);
|
|
123
|
-
if (isEsmProject) await utils_namespaceObject.fs.copy(external_node_path_default().join(__dirname, './netlify-entry.mjs'), entryFilePath);
|
|
124
|
-
else await utils_namespaceObject.fs.copy(external_node_path_default().join(__dirname, './netlify-entry.js'), entryFilePath);
|
|
98
|
+
const template = await (0, index_js_namespaceObject.readTemplate)(`netlify-entry.${isEsmProject ? 'mjs' : 'cjs'}`);
|
|
99
|
+
const code = await (0, generator_js_namespaceObject.generateHandler)({
|
|
100
|
+
template,
|
|
101
|
+
appContext,
|
|
102
|
+
config: modernConfig,
|
|
103
|
+
isESM: isEsmProject
|
|
104
|
+
});
|
|
105
|
+
await utils_namespaceObject.fs.writeFile(entryFilePath, code);
|
|
125
106
|
},
|
|
126
107
|
async end () {
|
|
127
108
|
if ('development' !== process.env.NODE_ENV) await cleanDistDirectory(distDirectory);
|
|
128
109
|
if (!needModernServer) return;
|
|
110
|
+
const entry = isEsmProject ? await (0, index_js_namespaceObject.resolveESMDependency)('@modern-js/prod-server') : require.resolve('@modern-js/prod-server');
|
|
111
|
+
const netlifyEntry = isEsmProject ? await (0, index_js_namespaceObject.resolveESMDependency)('@modern-js/prod-server/netlify') : require.resolve('@modern-js/prod-server/netlify');
|
|
112
|
+
if (!entry || !netlifyEntry) throw new Error('Cannot find @modern-js/prod-server');
|
|
129
113
|
await (0, external_ndepe_namespaceObject.nodeDepEmit)({
|
|
130
114
|
appDir: appDirectory,
|
|
131
115
|
sourceDir: funcsDirectory,
|
|
132
116
|
includeEntries: [
|
|
133
|
-
|
|
134
|
-
|
|
117
|
+
entry,
|
|
118
|
+
netlifyEntry
|
|
135
119
|
],
|
|
136
120
|
copyWholePackage (pkgName) {
|
|
137
121
|
return '@modern-js/utils' === pkgName;
|
|
@@ -39,14 +39,11 @@ const external_node_path_namespaceObject = require("node:path");
|
|
|
39
39
|
var external_node_path_default = /*#__PURE__*/ __webpack_require__.n(external_node_path_namespaceObject);
|
|
40
40
|
const utils_namespaceObject = require("@modern-js/utils");
|
|
41
41
|
const external_ndepe_namespaceObject = require("ndepe");
|
|
42
|
-
const
|
|
43
|
-
const
|
|
44
|
-
|
|
42
|
+
const index_js_namespaceObject = require("../utils/index.js");
|
|
43
|
+
const generator_js_namespaceObject = require("../utils/generator.js");
|
|
44
|
+
const createNodePreset = ({ appContext, modernConfig, api })=>{
|
|
45
|
+
const { appDirectory, distDirectory, moduleType } = appContext;
|
|
45
46
|
const isEsmProject = 'module' === moduleType;
|
|
46
|
-
const plugins = serverPlugins.map((plugin)=>[
|
|
47
|
-
plugin.name,
|
|
48
|
-
plugin.options
|
|
49
|
-
]);
|
|
50
47
|
const outputDirectory = external_node_path_default().join(appDirectory, '.output');
|
|
51
48
|
const staticDirectory = external_node_path_default().join(outputDirectory, 'static');
|
|
52
49
|
const entryFilePath = external_node_path_default().join(outputDirectory, 'index.js');
|
|
@@ -58,44 +55,24 @@ const createNodePreset = (appContext, config)=>{
|
|
|
58
55
|
await utils_namespaceObject.fs.copy(distDirectory, outputDirectory);
|
|
59
56
|
},
|
|
60
57
|
async genEntry () {
|
|
61
|
-
const
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
distPath: {
|
|
70
|
-
root: '.'
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
};
|
|
74
|
-
const pluginImportCode = (0, external_utils_js_namespaceObject.genPluginImportsCode)(plugins || []);
|
|
75
|
-
const dynamicProdOptions = {
|
|
76
|
-
config: serverConfig
|
|
77
|
-
};
|
|
78
|
-
const meta = (0, utils_namespaceObject.getMeta)(metaName);
|
|
79
|
-
const serverConfigPath = `path.join(__dirname, "${utils_namespaceObject.SERVER_DIR}", "${meta}.server")`;
|
|
80
|
-
const pluginsCode = (0, external_utils_js_namespaceObject.getPluginsCode)(plugins);
|
|
81
|
-
let entryCode = (await utils_namespaceObject.fs.readFile(external_node_path_default().join(__dirname, './node-entry.js'))).toString();
|
|
82
|
-
const serverAppContext = (0, external_utils_js_namespaceObject.serverAppContenxtTemplate)(appContext);
|
|
83
|
-
entryCode = entryCode.replace('p_genPluginImportsCode', pluginImportCode).replace('p_ROUTE_SPEC_FILE', `"${utils_namespaceObject.ROUTE_SPEC_FILE}"`).replace('p_dynamicProdOptions', JSON.stringify(dynamicProdOptions)).replace('p_plugins', pluginsCode).replace('p_serverDirectory', serverConfigPath).replace('p_sharedDirectory', serverAppContext.sharedDirectory).replace('p_apiDirectory', serverAppContext.apiDirectory).replace('p_bffRuntimeFramework', `"${serverAppContext.bffRuntimeFramework}"`).replace('p_lambdaDirectory', serverAppContext.lambdaDirectory);
|
|
84
|
-
if (isEsmProject) {
|
|
85
|
-
const cjsEntryFilePath = external_node_path_default().join(outputDirectory, 'index.cjs');
|
|
86
|
-
await utils_namespaceObject.fs.writeFile(cjsEntryFilePath, entryCode);
|
|
87
|
-
await utils_namespaceObject.fs.writeFile(entryFilePath, "import('./index.cjs');");
|
|
88
|
-
} else await utils_namespaceObject.fs.writeFile(entryFilePath, entryCode);
|
|
58
|
+
const template = await (0, index_js_namespaceObject.readTemplate)(`node-entry.${isEsmProject ? 'mjs' : 'cjs'}`);
|
|
59
|
+
const code = await (0, generator_js_namespaceObject.generateHandler)({
|
|
60
|
+
template,
|
|
61
|
+
appContext,
|
|
62
|
+
config: modernConfig,
|
|
63
|
+
isESM: isEsmProject
|
|
64
|
+
});
|
|
65
|
+
await utils_namespaceObject.fs.writeFile(entryFilePath, code);
|
|
89
66
|
},
|
|
90
67
|
async end () {
|
|
91
|
-
console.log('Static directory:', utils_namespaceObject.chalk.blue(external_node_path_default().relative(appDirectory, staticDirectory)));
|
|
92
|
-
console.log("You can preview this build by", utils_namespaceObject.chalk.blue("node .output/index"));
|
|
93
68
|
const filter = (filePath)=>!filePath.startsWith(staticDirectory) && !filePath.endsWith('.map');
|
|
69
|
+
const entry = isEsmProject ? await (0, index_js_namespaceObject.resolveESMDependency)('@modern-js/prod-server') : require.resolve('@modern-js/prod-server');
|
|
70
|
+
if (!entry) throw new Error('Cannot find @modern-js/prod-server');
|
|
94
71
|
await (0, external_ndepe_namespaceObject.nodeDepEmit)({
|
|
95
72
|
appDir: appDirectory,
|
|
96
73
|
sourceDir: outputDirectory,
|
|
97
74
|
includeEntries: [
|
|
98
|
-
|
|
75
|
+
entry
|
|
99
76
|
],
|
|
100
77
|
copyWholePackage (pkgName) {
|
|
101
78
|
return '@modern-js/utils' === pkgName;
|
|
@@ -109,6 +86,8 @@ const createNodePreset = (appContext, config)=>{
|
|
|
109
86
|
};
|
|
110
87
|
}
|
|
111
88
|
});
|
|
89
|
+
console.log('Static directory:', utils_namespaceObject.chalk.blue(external_node_path_default().relative(appDirectory, staticDirectory).replace(/\\/g, '/')));
|
|
90
|
+
console.log("You can preview this build by", utils_namespaceObject.chalk.blue('node .output/index'));
|
|
112
91
|
}
|
|
113
92
|
};
|
|
114
93
|
};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
const fs = require('node:fs/promises');
|
|
2
|
+
const path = require('node:path');
|
|
3
|
+
const { createNetlifyFunction } = require('@modern-js/prod-server/netlify');
|
|
4
|
+
p_genPluginImportsCode;
|
|
5
|
+
if (!process.env.NODE_ENV) process.env.NODE_ENV = 'production';
|
|
6
|
+
let requestHandler = null;
|
|
7
|
+
let handlerCreationPromise = null;
|
|
8
|
+
async function loadRoutes(routeFilepath) {
|
|
9
|
+
try {
|
|
10
|
+
await fs.access(routeFilepath);
|
|
11
|
+
const content = await fs.readFile(routeFilepath, 'utf-8');
|
|
12
|
+
const routeSpec = JSON.parse(content);
|
|
13
|
+
return routeSpec.routes || [];
|
|
14
|
+
} catch (error) {
|
|
15
|
+
console.warn('route.json not found or invalid, continuing with empty routes.');
|
|
16
|
+
return [];
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
async function initServer() {
|
|
20
|
+
const routeFilepath = path.join(__dirname, p_ROUTE_SPEC_FILE);
|
|
21
|
+
const routes = await loadRoutes(routeFilepath);
|
|
22
|
+
const dynamicProdOptions = p_dynamicProdOptions;
|
|
23
|
+
const prodServerOptions = {
|
|
24
|
+
pwd: __dirname,
|
|
25
|
+
routes,
|
|
26
|
+
disableCustomHook: true,
|
|
27
|
+
appContext: {
|
|
28
|
+
sharedDirectory: p_sharedDirectory,
|
|
29
|
+
apiDirectory: p_apiDirectory,
|
|
30
|
+
lambdaDirectory: p_lambdaDirectory,
|
|
31
|
+
bffRuntimeFramework: p_bffRuntimeFramework
|
|
32
|
+
},
|
|
33
|
+
plugins: p_plugins,
|
|
34
|
+
serverConfigPath: p_serverDirectory,
|
|
35
|
+
...dynamicProdOptions
|
|
36
|
+
};
|
|
37
|
+
const requestHandler = await createNetlifyFunction(prodServerOptions);
|
|
38
|
+
return requestHandler;
|
|
39
|
+
}
|
|
40
|
+
async function createHandler() {
|
|
41
|
+
if (!handlerCreationPromise) handlerCreationPromise = (async ()=>{
|
|
42
|
+
try {
|
|
43
|
+
requestHandler = await initServer();
|
|
44
|
+
} catch (error) {
|
|
45
|
+
console.error('Error creating server:', error);
|
|
46
|
+
process.exit(1);
|
|
47
|
+
}
|
|
48
|
+
})();
|
|
49
|
+
await handlerCreationPromise;
|
|
50
|
+
return requestHandler;
|
|
51
|
+
}
|
|
52
|
+
createHandler();
|
|
53
|
+
const handler = async (request, context)=>{
|
|
54
|
+
if (!requestHandler) await createHandler();
|
|
55
|
+
return requestHandler(request, context);
|
|
56
|
+
};
|
|
57
|
+
exports.handler = handler;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import fs from 'node:fs/promises';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { fileURLToPath } from 'node:url';
|
|
4
|
+
import { createNetlifyFunction } from '@modern-js/prod-server/netlify';
|
|
5
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
6
|
+
p_genPluginImportsCode;
|
|
7
|
+
if (!process.env.NODE_ENV) process.env.NODE_ENV = 'production';
|
|
8
|
+
let requestHandler = null;
|
|
9
|
+
let handlerCreationPromise = null;
|
|
10
|
+
async function loadRoutes(routeFilepath) {
|
|
11
|
+
try {
|
|
12
|
+
await fs.access(routeFilepath);
|
|
13
|
+
const content = await fs.readFile(routeFilepath, 'utf-8');
|
|
14
|
+
const routeSpec = JSON.parse(content);
|
|
15
|
+
return routeSpec.routes || [];
|
|
16
|
+
} catch (error) {
|
|
17
|
+
console.warn('route.json not found or invalid, continuing with empty routes.');
|
|
18
|
+
return [];
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
async function initServer() {
|
|
22
|
+
const routeFilepath = path.join(__dirname, p_ROUTE_SPEC_FILE);
|
|
23
|
+
const routes = await loadRoutes(routeFilepath);
|
|
24
|
+
const dynamicProdOptions = p_dynamicProdOptions;
|
|
25
|
+
const prodServerOptions = {
|
|
26
|
+
pwd: __dirname,
|
|
27
|
+
routes,
|
|
28
|
+
disableCustomHook: true,
|
|
29
|
+
appContext: {
|
|
30
|
+
sharedDirectory: p_sharedDirectory,
|
|
31
|
+
apiDirectory: p_apiDirectory,
|
|
32
|
+
lambdaDirectory: p_lambdaDirectory,
|
|
33
|
+
bffRuntimeFramework: p_bffRuntimeFramework
|
|
34
|
+
},
|
|
35
|
+
plugins: p_plugins,
|
|
36
|
+
serverConfigPath: p_serverDirectory,
|
|
37
|
+
...dynamicProdOptions
|
|
38
|
+
};
|
|
39
|
+
const requestHandler = await createNetlifyFunction(prodServerOptions);
|
|
40
|
+
return requestHandler;
|
|
41
|
+
}
|
|
42
|
+
async function createHandler() {
|
|
43
|
+
if (!handlerCreationPromise) handlerCreationPromise = (async ()=>{
|
|
44
|
+
try {
|
|
45
|
+
requestHandler = await initServer();
|
|
46
|
+
} catch (error) {
|
|
47
|
+
console.error('Error creating server:', error);
|
|
48
|
+
process.exit(1);
|
|
49
|
+
}
|
|
50
|
+
})();
|
|
51
|
+
await handlerCreationPromise;
|
|
52
|
+
return requestHandler;
|
|
53
|
+
}
|
|
54
|
+
createHandler();
|
|
55
|
+
const handler = async (request, context)=>{
|
|
56
|
+
if (!requestHandler) await createHandler();
|
|
57
|
+
return requestHandler(request, context);
|
|
58
|
+
};
|
|
59
|
+
export default handler;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
const fs = require('node:fs/promises');
|
|
2
|
+
const path = require('node:path');
|
|
3
|
+
const { createProdServer } = require('@modern-js/prod-server');
|
|
4
|
+
p_genPluginImportsCode;
|
|
5
|
+
if (!process.env.NODE_ENV) process.env.NODE_ENV = 'production';
|
|
6
|
+
async function loadRoutes(routeFilepath) {
|
|
7
|
+
try {
|
|
8
|
+
await fs.access(routeFilepath);
|
|
9
|
+
const content = await fs.readFile(routeFilepath, 'utf-8');
|
|
10
|
+
const routeSpec = JSON.parse(content);
|
|
11
|
+
return routeSpec.routes || [];
|
|
12
|
+
} catch (error) {
|
|
13
|
+
console.warn('route.json not found or invalid, continuing with empty routes.');
|
|
14
|
+
return [];
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
async function main() {
|
|
18
|
+
const routeFilepath = path.join(__dirname, p_ROUTE_SPEC_FILE);
|
|
19
|
+
const routes = await loadRoutes(routeFilepath);
|
|
20
|
+
const dynamicProdOptions = p_dynamicProdOptions;
|
|
21
|
+
const prodServerOptions = {
|
|
22
|
+
pwd: __dirname,
|
|
23
|
+
routes,
|
|
24
|
+
disableCustomHook: true,
|
|
25
|
+
appContext: {
|
|
26
|
+
sharedDirectory: p_sharedDirectory,
|
|
27
|
+
apiDirectory: p_apiDirectory,
|
|
28
|
+
lambdaDirectory: p_lambdaDirectory,
|
|
29
|
+
bffRuntimeFramework: p_bffRuntimeFramework
|
|
30
|
+
},
|
|
31
|
+
plugins: p_plugins,
|
|
32
|
+
serverConfigPath: p_serverDirectory,
|
|
33
|
+
...dynamicProdOptions
|
|
34
|
+
};
|
|
35
|
+
const app = await createProdServer(prodServerOptions);
|
|
36
|
+
const port = process.env.PORT || 8080;
|
|
37
|
+
app.listen({
|
|
38
|
+
host: '::',
|
|
39
|
+
port
|
|
40
|
+
}, ()=>{
|
|
41
|
+
console.log(`\x1b[32mServer is listening on http://[::]:${port}`, '\x1b[0m');
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
main();
|
package/dist/{esm/plugins/deploy/platforms → cjs/plugins/deploy/platforms/templates}/node-entry.mjs
RENAMED
|
@@ -1,30 +1,8 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
module.exports = __rspack_external__modern_js_prod_server_057184e2;
|
|
7
|
-
},
|
|
8
|
-
"node:fs/promises" (module) {
|
|
9
|
-
module.exports = __rspack_external_node_fs_promises_153e37e0;
|
|
10
|
-
},
|
|
11
|
-
"node:path" (module) {
|
|
12
|
-
module.exports = __rspack_external_node_path_c5b9b54f;
|
|
13
|
-
}
|
|
14
|
-
};
|
|
15
|
-
var __webpack_module_cache__ = {};
|
|
16
|
-
function __webpack_require__(moduleId) {
|
|
17
|
-
var cachedModule = __webpack_module_cache__[moduleId];
|
|
18
|
-
if (void 0 !== cachedModule) return cachedModule.exports;
|
|
19
|
-
var module = __webpack_module_cache__[moduleId] = {
|
|
20
|
-
exports: {}
|
|
21
|
-
};
|
|
22
|
-
__webpack_modules__[moduleId](module, module.exports, __webpack_require__);
|
|
23
|
-
return module.exports;
|
|
24
|
-
}
|
|
25
|
-
const fs = __webpack_require__("node:fs/promises");
|
|
26
|
-
const path = __webpack_require__("node:path");
|
|
27
|
-
const { createProdServer } = __webpack_require__("@modern-js/prod-server");
|
|
1
|
+
import fs from 'node:fs/promises';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { fileURLToPath } from 'node:url';
|
|
4
|
+
import { createProdServer } from '@modern-js/prod-server';
|
|
5
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
28
6
|
p_genPluginImportsCode;
|
|
29
7
|
if (!process.env.NODE_ENV) process.env.NODE_ENV = 'production';
|
|
30
8
|
async function loadRoutes(routeFilepath) {
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
const fs = require('node:fs/promises');
|
|
2
|
+
const path = require('node:path');
|
|
3
|
+
const { createProdServer } = require('@modern-js/prod-server');
|
|
4
|
+
p_genPluginImportsCode;
|
|
5
|
+
if (!process.env.NODE_ENV) process.env.NODE_ENV = 'production';
|
|
6
|
+
let requestHandler = null;
|
|
7
|
+
let handlerCreationPromise = null;
|
|
8
|
+
async function loadRoutes(routeFilepath) {
|
|
9
|
+
try {
|
|
10
|
+
await fs.access(routeFilepath);
|
|
11
|
+
const content = await fs.readFile(routeFilepath, 'utf-8');
|
|
12
|
+
const routeSpec = JSON.parse(content);
|
|
13
|
+
return routeSpec.routes || [];
|
|
14
|
+
} catch (error) {
|
|
15
|
+
console.warn('route.json not found or invalid, continuing with empty routes.');
|
|
16
|
+
return [];
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
async function initServer() {
|
|
20
|
+
const routeFilepath = path.join(__dirname, p_ROUTE_SPEC_FILE);
|
|
21
|
+
const routes = await loadRoutes(routeFilepath);
|
|
22
|
+
const dynamicProdOptions = p_dynamicProdOptions;
|
|
23
|
+
const prodServerOptions = {
|
|
24
|
+
pwd: __dirname,
|
|
25
|
+
routes,
|
|
26
|
+
disableCustomHook: true,
|
|
27
|
+
appContext: {
|
|
28
|
+
sharedDirectory: p_sharedDirectory,
|
|
29
|
+
apiDirectory: p_apiDirectory,
|
|
30
|
+
lambdaDirectory: p_lambdaDirectory
|
|
31
|
+
},
|
|
32
|
+
plugins: p_plugins,
|
|
33
|
+
serverConfigPath: p_serverDirectory,
|
|
34
|
+
...dynamicProdOptions
|
|
35
|
+
};
|
|
36
|
+
const app = await createProdServer(prodServerOptions);
|
|
37
|
+
return app.getRequestListener();
|
|
38
|
+
}
|
|
39
|
+
async function createHandler() {
|
|
40
|
+
if (!handlerCreationPromise) handlerCreationPromise = (async ()=>{
|
|
41
|
+
try {
|
|
42
|
+
requestHandler = await initServer();
|
|
43
|
+
} catch (error) {
|
|
44
|
+
console.error('Error creating server:', error);
|
|
45
|
+
process.exit(1);
|
|
46
|
+
}
|
|
47
|
+
})();
|
|
48
|
+
await handlerCreationPromise;
|
|
49
|
+
return requestHandler;
|
|
50
|
+
}
|
|
51
|
+
createHandler();
|
|
52
|
+
const handler = async (req, res)=>{
|
|
53
|
+
if (!requestHandler) await createHandler();
|
|
54
|
+
return requestHandler(req, res);
|
|
55
|
+
};
|
|
56
|
+
module.exports = handler;
|