@modern-js/app-tools 2.57.1-alpha.2 → 2.57.1-alpha.4
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/esm/ts-node-loader.mjs +1 -1
- package/dist/cjs/esm/utils.mjs +15 -0
- package/dist/cjs/plugins/deploy/platforms/netlify-entry.mjs +1 -0
- package/dist/cjs/plugins/deploy/platforms/netlify-handler.js +6 -30
- package/dist/cjs/plugins/deploy/platforms/netlify.js +2 -2
- package/dist/cjs/utils/register.js +11 -0
- package/dist/types/plugins/deploy/platforms/netlify-entry.d.cts +2 -0
- package/dist/types/plugins/deploy/platforms/netlify-entry.d.mts +1 -0
- package/dist/types/plugins/deploy/platforms/netlify-handler.d.ts +1 -1
- package/package.json +5 -5
- package/dist/cjs/plugins/deploy/platforms/netlify-entry-mjs.js +0 -28
- package/dist/types/plugins/deploy/platforms/netlify-entry-cjs.d.ts +0 -1
- package/dist/types/plugins/deploy/platforms/netlify-entry-mjs.d.ts +0 -1
- /package/dist/cjs/plugins/deploy/platforms/{netlify-entry-cjs.js → netlify-entry.js} +0 -0
|
@@ -12,7 +12,7 @@ export async function initialize({ appDir, alias, tsconfigPath }) {
|
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
export function resolve(specifier, context, defaultResolve) {
|
|
15
|
-
const match = matchPath(specifier
|
|
15
|
+
const match = matchPath(specifier);
|
|
16
16
|
return match
|
|
17
17
|
? tsNodeResolve(pathToFileURL(match).href, context, defaultResolve)
|
|
18
18
|
: tsNodeResolve(specifier, context, defaultResolve);
|
package/dist/cjs/esm/utils.mjs
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import path from 'path';
|
|
2
|
+
import { createRequire } from 'module';
|
|
2
3
|
import tsConfigPaths from '@modern-js/utils/tsconfig-paths';
|
|
3
4
|
import { getAliasConfig } from '@modern-js/utils';
|
|
4
5
|
|
|
6
|
+
const require = createRequire(import.meta.url);
|
|
5
7
|
export function createMatchPath({ alias, appDir, tsconfigPath }) {
|
|
6
8
|
const aliasConfig = getAliasConfig(alias, {
|
|
7
9
|
appDirectory: appDir,
|
|
@@ -12,6 +14,19 @@ export function createMatchPath({ alias, appDir, tsconfigPath }) {
|
|
|
12
14
|
|
|
13
15
|
const tsPaths = Object.keys(paths).reduce((o, key) => {
|
|
14
16
|
let tsPath = paths[key];
|
|
17
|
+
// Do some special handling for Modern.js's internal alias, we can drop it in the next version
|
|
18
|
+
if (
|
|
19
|
+
typeof tsPath === 'string' &&
|
|
20
|
+
key.startsWith('@') &&
|
|
21
|
+
tsPath.startsWith('@')
|
|
22
|
+
) {
|
|
23
|
+
try {
|
|
24
|
+
tsPath = require.resolve(tsPath, {
|
|
25
|
+
paths: [appDir],
|
|
26
|
+
});
|
|
27
|
+
} catch {}
|
|
28
|
+
}
|
|
29
|
+
|
|
15
30
|
if (typeof tsPath === 'string' && path.isAbsolute(tsPath)) {
|
|
16
31
|
tsPath = path.relative(absoluteBaseUrl, tsPath);
|
|
17
32
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { handler } from './netlify-handler';
|
|
@@ -1,26 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var netlify_handler_exports = {};
|
|
20
|
-
__export(netlify_handler_exports, {
|
|
21
|
-
createHandler: () => createHandler
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(netlify_handler_exports);
|
|
24
2
|
const fs = require("node:fs/promises");
|
|
25
3
|
const path = require("node:path");
|
|
26
4
|
const { createNetlifyFunction } = require("@modern-js/prod-server/netlify");
|
|
@@ -75,13 +53,11 @@ async function createHandler() {
|
|
|
75
53
|
return requestHandler;
|
|
76
54
|
}
|
|
77
55
|
createHandler();
|
|
78
|
-
exports
|
|
79
|
-
|
|
80
|
-
|
|
56
|
+
module.exports = {
|
|
57
|
+
handler: async (request, context) => {
|
|
58
|
+
if (!requestHandler) {
|
|
59
|
+
await createHandler();
|
|
60
|
+
}
|
|
61
|
+
return requestHandler(request, context);
|
|
81
62
|
}
|
|
82
|
-
return requestHandler(request, context);
|
|
83
63
|
};
|
|
84
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
85
|
-
0 && (module.exports = {
|
|
86
|
-
createHandler
|
|
87
|
-
});
|
|
@@ -121,9 +121,9 @@ const createNetlifyPreset = (appContext, modernConfig, needModernServer) => {
|
|
|
121
121
|
entryCode = entryCode.replace("p_genPluginImportsCode", pluginImportCode).replace("p_ROUTE_SPEC_FILE", `"${import_utils.ROUTE_SPEC_FILE}"`).replace("p_dynamicProdOptions", JSON.stringify(dynamicProdOptions)).replace("p_plugins", pluginsCode).replace("p_sharedDirectory", serverAppContext.sharedDirectory).replace("p_apiDirectory", serverAppContext.apiDirectory).replace("p_lambdaDirectory", serverAppContext.lambdaDirectory);
|
|
122
122
|
await import_utils.fs.writeFile(handlerFilePath, entryCode);
|
|
123
123
|
if (isEsmProject) {
|
|
124
|
-
await import_utils.fs.copy(import_node_path.default.join(__dirname, "./netlify-entry
|
|
124
|
+
await import_utils.fs.copy(import_node_path.default.join(__dirname, "./netlify-entry.mjs"), entryFilePath);
|
|
125
125
|
} else {
|
|
126
|
-
await import_utils.fs.copy(import_node_path.default.join(__dirname, "./netlify-entry
|
|
126
|
+
await import_utils.fs.copy(import_node_path.default.join(__dirname, "./netlify-entry.cjs"), entryFilePath);
|
|
127
127
|
}
|
|
128
128
|
},
|
|
129
129
|
async end() {
|
|
@@ -52,6 +52,17 @@ const registerCompiler = async (appDir = process.cwd(), distDir, alias) => {
|
|
|
52
52
|
const { paths = {}, absoluteBaseUrl = "./" } = aliasConfig;
|
|
53
53
|
const tsPaths = Object.keys(paths).reduce((o, key) => {
|
|
54
54
|
let tsPath = paths[key];
|
|
55
|
+
if (typeof tsPath === "string" && key.startsWith("@") && tsPath.startsWith("@")) {
|
|
56
|
+
try {
|
|
57
|
+
tsPath = require.resolve(tsPath, {
|
|
58
|
+
paths: [
|
|
59
|
+
process.cwd(),
|
|
60
|
+
...module.paths
|
|
61
|
+
]
|
|
62
|
+
});
|
|
63
|
+
} catch {
|
|
64
|
+
}
|
|
65
|
+
}
|
|
55
66
|
if (typeof tsPath === "string" && import_node_path.default.isAbsolute(tsPath)) {
|
|
56
67
|
tsPath = import_node_path.default.relative(absoluteBaseUrl, tsPath);
|
|
57
68
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { handler } from "./netlify-handler";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export function
|
|
1
|
+
export function handler(request: any, context: any): Promise<any>;
|
package/package.json
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"modern",
|
|
16
16
|
"modern.js"
|
|
17
17
|
],
|
|
18
|
-
"version": "2.57.1-alpha.
|
|
18
|
+
"version": "2.57.1-alpha.4",
|
|
19
19
|
"jsnext:source": "./src/index.ts",
|
|
20
20
|
"types": "./dist/types/index.d.ts",
|
|
21
21
|
"main": "./dist/cjs/index.js",
|
|
@@ -88,16 +88,16 @@
|
|
|
88
88
|
"pkg-types": "^1.1.0",
|
|
89
89
|
"std-env": "^3.7.0",
|
|
90
90
|
"@modern-js/core": "2.57.0",
|
|
91
|
+
"@modern-js/node-bundle-require": "2.57.0",
|
|
91
92
|
"@modern-js/plugin": "2.57.0",
|
|
92
93
|
"@modern-js/plugin-i18n": "2.57.0",
|
|
93
94
|
"@modern-js/plugin-lint": "2.57.0",
|
|
94
|
-
"@modern-js/node-bundle-require": "2.57.0",
|
|
95
|
-
"@modern-js/prod-server": "2.57.0",
|
|
96
|
-
"@modern-js/server-core": "2.57.0",
|
|
97
|
-
"@modern-js/server-utils": "2.57.0",
|
|
98
95
|
"@modern-js/rsbuild-plugin-esbuild": "2.57.0",
|
|
96
|
+
"@modern-js/prod-server": "2.57.0",
|
|
99
97
|
"@modern-js/server": "2.57.0",
|
|
98
|
+
"@modern-js/server-core": "2.57.0",
|
|
100
99
|
"@modern-js/plugin-data-loader": "2.57.0",
|
|
100
|
+
"@modern-js/server-utils": "2.57.0",
|
|
101
101
|
"@modern-js/types": "2.57.0",
|
|
102
102
|
"@modern-js/uni-builder": "2.57.0",
|
|
103
103
|
"@modern-js/utils": "2.57.0"
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var netlify_entry_mjs_exports = {};
|
|
20
|
-
__export(netlify_entry_mjs_exports, {
|
|
21
|
-
handler: () => import_netlify_handler.handler
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(netlify_entry_mjs_exports);
|
|
24
|
-
var import_netlify_handler = require("./netlify-handler");
|
|
25
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
26
|
-
0 && (module.exports = {
|
|
27
|
-
handler
|
|
28
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export default handler;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
File without changes
|