nitropack-nightly 2.12.0-20250715-082121.fb010982 → 2.13.0-20250716-094945.42a23de2
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/core/index.mjs +17 -26
- package/dist/meta/index.mjs +1 -1
- package/dist/presets/_all.gen.d.ts +1 -1
- package/dist/presets/_types.gen.d.ts +2 -2
- package/dist/presets/cloudflare/preset.mjs +7 -7
- package/dist/presets/deno/preset-legacy.mjs +1 -1
- package/dist/presets/deno/preset.mjs +2 -2
- package/dist/presets/edgio/preset.mjs +2 -2
- package/dist/presets/netlify/legacy/preset.mjs +1 -1
- package/dist/presets/netlify/preset.d.ts +1 -1
- package/dist/presets/netlify/preset.mjs +2 -18
- package/dist/presets/netlify/types.d.ts +0 -2
- package/dist/presets/vercel/preset.mjs +6 -5
- package/package.json +3 -5
- package/dist/presets/netlify/dev.d.ts +0 -2
- package/dist/presets/netlify/dev.mjs +0 -86
package/dist/core/index.mjs
CHANGED
|
@@ -1619,8 +1619,8 @@ async function buildProduction(nitro, rollupConfig) {
|
|
|
1619
1619
|
nitro: version
|
|
1620
1620
|
},
|
|
1621
1621
|
commands: {
|
|
1622
|
-
preview: nitro.options.commands.preview,
|
|
1623
|
-
deploy: nitro.options.commands.deploy
|
|
1622
|
+
preview: resolveTmplPath(nitro.options.commands.preview, nitro),
|
|
1623
|
+
deploy: resolveTmplPath(nitro.options.commands.deploy, nitro)
|
|
1624
1624
|
},
|
|
1625
1625
|
config: {
|
|
1626
1626
|
...Object.fromEntries(
|
|
@@ -1642,26 +1642,14 @@ async function buildProduction(nitro, rollupConfig) {
|
|
|
1642
1642
|
}
|
|
1643
1643
|
}
|
|
1644
1644
|
await nitro.hooks.callHook("compiled", nitro);
|
|
1645
|
-
|
|
1646
|
-
const rewriteRelativePaths = (input) => {
|
|
1647
|
-
return input.replace(/([\s:])\.\/(\S*)/g, `$1${rOutput}/$2`);
|
|
1648
|
-
};
|
|
1649
|
-
if (buildInfo.commands.preview) {
|
|
1645
|
+
if (buildInfo.commands?.preview) {
|
|
1650
1646
|
nitro.logger.success(
|
|
1651
|
-
`You can preview this build using \`${
|
|
1652
|
-
rewriteRelativePaths(buildInfo.commands.preview),
|
|
1653
|
-
nitro.options,
|
|
1654
|
-
nitro.options.rootDir
|
|
1655
|
-
)}\``
|
|
1647
|
+
`You can preview this build using \`${buildInfo.commands?.preview}\``
|
|
1656
1648
|
);
|
|
1657
1649
|
}
|
|
1658
|
-
if (buildInfo.commands
|
|
1650
|
+
if (buildInfo.commands?.deploy) {
|
|
1659
1651
|
nitro.logger.success(
|
|
1660
|
-
`You can deploy this build using \`${
|
|
1661
|
-
rewriteRelativePaths(buildInfo.commands.deploy),
|
|
1662
|
-
nitro.options,
|
|
1663
|
-
nitro.options.rootDir
|
|
1664
|
-
)}\``
|
|
1652
|
+
`You can deploy this build using \`${buildInfo.commands?.deploy}\``
|
|
1665
1653
|
);
|
|
1666
1654
|
}
|
|
1667
1655
|
}
|
|
@@ -1686,17 +1674,20 @@ async function _snapshot(nitro) {
|
|
|
1686
1674
|
})
|
|
1687
1675
|
);
|
|
1688
1676
|
}
|
|
1689
|
-
function
|
|
1690
|
-
if (!
|
|
1691
|
-
return
|
|
1677
|
+
function resolveTmplPath(input, nitro) {
|
|
1678
|
+
if (!input || !input.includes("{{")) {
|
|
1679
|
+
return input;
|
|
1692
1680
|
}
|
|
1693
|
-
return
|
|
1694
|
-
let val = getProperty(
|
|
1681
|
+
return input.replace(/{{ ?([\w.]+) ?}}/g, (_, match) => {
|
|
1682
|
+
let val = getProperty(
|
|
1683
|
+
nitro.options,
|
|
1684
|
+
match
|
|
1685
|
+
);
|
|
1695
1686
|
if (val) {
|
|
1696
|
-
val = relative(
|
|
1687
|
+
val = relative(nitro.options.rootDir, val);
|
|
1697
1688
|
} else {
|
|
1698
|
-
|
|
1699
|
-
`cannot resolve template param '${match}' in ${
|
|
1689
|
+
nitro.logger.warn(
|
|
1690
|
+
`cannot resolve template param '${match}' in ${input.slice(0, 20)}`
|
|
1700
1691
|
);
|
|
1701
1692
|
}
|
|
1702
1693
|
return val || `${match}`;
|
package/dist/meta/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default: readonly [any, any, any, any, any, any, any, any, any, any, any, any, any, any, ...any[], any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any
|
|
1
|
+
declare const _default: readonly [any, any, any, any, any, any, any, any, any, any, any, any, any, any, ...any[], any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any];
|
|
2
2
|
export default _default;
|
|
@@ -15,5 +15,5 @@ export interface PresetOptions {
|
|
|
15
15
|
vercel: VercelOptions;
|
|
16
16
|
}
|
|
17
17
|
export declare const presetsWithConfig: readonly ["awsAmplify", "awsLambda", "azure", "cloudflare", "firebase", "netlify", "vercel"];
|
|
18
|
-
export type PresetName = "alwaysdata" | "aws-amplify" | "aws-lambda" | "azure" | "azure-functions" | "azure-swa" | "base-worker" | "bun" | "cleavr" | "cli" | "cloudflare" | "cloudflare-dev" | "cloudflare-durable" | "cloudflare-module" | "cloudflare-module-legacy" | "cloudflare-pages" | "cloudflare-pages-static" | "cloudflare-worker" | "deno" | "deno-deploy" | "deno-server" | "deno-server-legacy" | "digital-ocean" | "edgio" | "firebase" | "firebase-app-hosting" | "flight-control" | "genezio" | "github-pages" | "gitlab-pages" | "heroku" | "iis" | "iis-handler" | "iis-node" | "koyeb" | "layer0" | "netlify" | "netlify-builder" | "netlify-
|
|
19
|
-
export type PresetNameInput = "alwaysdata" | "aws-amplify" | "awsAmplify" | "aws_amplify" | "aws-lambda" | "awsLambda" | "aws_lambda" | "azure" | "azure-functions" | "azureFunctions" | "azure_functions" | "azure-swa" | "azureSwa" | "azure_swa" | "base-worker" | "baseWorker" | "base_worker" | "bun" | "cleavr" | "cli" | "cloudflare" | "cloudflare-dev" | "cloudflareDev" | "cloudflare_dev" | "cloudflare-durable" | "cloudflareDurable" | "cloudflare_durable" | "cloudflare-module" | "cloudflareModule" | "cloudflare_module" | "cloudflare-module-legacy" | "cloudflareModuleLegacy" | "cloudflare_module_legacy" | "cloudflare-pages" | "cloudflarePages" | "cloudflare_pages" | "cloudflare-pages-static" | "cloudflarePagesStatic" | "cloudflare_pages_static" | "cloudflare-worker" | "cloudflareWorker" | "cloudflare_worker" | "deno" | "deno-deploy" | "denoDeploy" | "deno_deploy" | "deno-server" | "denoServer" | "deno_server" | "deno-server-legacy" | "denoServerLegacy" | "deno_server_legacy" | "digital-ocean" | "digitalOcean" | "digital_ocean" | "edgio" | "firebase" | "firebase-app-hosting" | "firebaseAppHosting" | "firebase_app_hosting" | "flight-control" | "flightControl" | "flight_control" | "genezio" | "github-pages" | "githubPages" | "github_pages" | "gitlab-pages" | "gitlabPages" | "gitlab_pages" | "heroku" | "iis" | "iis-handler" | "iisHandler" | "iis_handler" | "iis-node" | "iisNode" | "iis_node" | "koyeb" | "layer0" | "netlify" | "netlify-builder" | "netlifyBuilder" | "netlify_builder" | "netlify-
|
|
18
|
+
export type PresetName = "alwaysdata" | "aws-amplify" | "aws-lambda" | "azure" | "azure-functions" | "azure-swa" | "base-worker" | "bun" | "cleavr" | "cli" | "cloudflare" | "cloudflare-dev" | "cloudflare-durable" | "cloudflare-module" | "cloudflare-module-legacy" | "cloudflare-pages" | "cloudflare-pages-static" | "cloudflare-worker" | "deno" | "deno-deploy" | "deno-server" | "deno-server-legacy" | "digital-ocean" | "edgio" | "firebase" | "firebase-app-hosting" | "flight-control" | "genezio" | "github-pages" | "gitlab-pages" | "heroku" | "iis" | "iis-handler" | "iis-node" | "koyeb" | "layer0" | "netlify" | "netlify-builder" | "netlify-edge" | "netlify-legacy" | "netlify-static" | "nitro-dev" | "nitro-prerender" | "node" | "node-cluster" | "node-listener" | "node-server" | "platform-sh" | "render-com" | "service-worker" | "static" | "stormkit" | "vercel" | "vercel-edge" | "vercel-static" | "winterjs" | "zeabur" | "zeabur-static" | "zerops" | "zerops-static";
|
|
19
|
+
export type PresetNameInput = "alwaysdata" | "aws-amplify" | "awsAmplify" | "aws_amplify" | "aws-lambda" | "awsLambda" | "aws_lambda" | "azure" | "azure-functions" | "azureFunctions" | "azure_functions" | "azure-swa" | "azureSwa" | "azure_swa" | "base-worker" | "baseWorker" | "base_worker" | "bun" | "cleavr" | "cli" | "cloudflare" | "cloudflare-dev" | "cloudflareDev" | "cloudflare_dev" | "cloudflare-durable" | "cloudflareDurable" | "cloudflare_durable" | "cloudflare-module" | "cloudflareModule" | "cloudflare_module" | "cloudflare-module-legacy" | "cloudflareModuleLegacy" | "cloudflare_module_legacy" | "cloudflare-pages" | "cloudflarePages" | "cloudflare_pages" | "cloudflare-pages-static" | "cloudflarePagesStatic" | "cloudflare_pages_static" | "cloudflare-worker" | "cloudflareWorker" | "cloudflare_worker" | "deno" | "deno-deploy" | "denoDeploy" | "deno_deploy" | "deno-server" | "denoServer" | "deno_server" | "deno-server-legacy" | "denoServerLegacy" | "deno_server_legacy" | "digital-ocean" | "digitalOcean" | "digital_ocean" | "edgio" | "firebase" | "firebase-app-hosting" | "firebaseAppHosting" | "firebase_app_hosting" | "flight-control" | "flightControl" | "flight_control" | "genezio" | "github-pages" | "githubPages" | "github_pages" | "gitlab-pages" | "gitlabPages" | "gitlab_pages" | "heroku" | "iis" | "iis-handler" | "iisHandler" | "iis_handler" | "iis-node" | "iisNode" | "iis_node" | "koyeb" | "layer0" | "netlify" | "netlify-builder" | "netlifyBuilder" | "netlify_builder" | "netlify-edge" | "netlifyEdge" | "netlify_edge" | "netlify-legacy" | "netlifyLegacy" | "netlify_legacy" | "netlify-static" | "netlifyStatic" | "netlify_static" | "nitro-dev" | "nitroDev" | "nitro_dev" | "nitro-prerender" | "nitroPrerender" | "nitro_prerender" | "node" | "node-cluster" | "nodeCluster" | "node_cluster" | "node-listener" | "nodeListener" | "node_listener" | "node-server" | "nodeServer" | "node_server" | "platform-sh" | "platformSh" | "platform_sh" | "render-com" | "renderCom" | "render_com" | "service-worker" | "serviceWorker" | "service_worker" | "static" | "stormkit" | "vercel" | "vercel-edge" | "vercelEdge" | "vercel_edge" | "vercel-static" | "vercelStatic" | "vercel_static" | "winterjs" | "zeabur" | "zeabur-static" | "zeaburStatic" | "zeabur_static" | "zerops" | "zerops-static" | "zeropsStatic" | "zerops_static" | (string & {});
|
|
@@ -16,8 +16,8 @@ const cloudflarePages = defineNitroPreset(
|
|
|
16
16
|
entry: "./runtime/cloudflare-pages",
|
|
17
17
|
exportConditions: ["workerd"],
|
|
18
18
|
commands: {
|
|
19
|
-
preview: "npx wrangler --cwd
|
|
20
|
-
deploy: "npx wrangler --cwd
|
|
19
|
+
preview: "npx wrangler --cwd {{ output.dir }} pages dev",
|
|
20
|
+
deploy: "npx wrangler --cwd {{ output.dir }} pages deploy"
|
|
21
21
|
},
|
|
22
22
|
output: {
|
|
23
23
|
dir: "{{ rootDir }}/dist",
|
|
@@ -71,8 +71,8 @@ const cloudflarePagesStatic = defineNitroPreset(
|
|
|
71
71
|
publicDir: "{{ output.dir }}/{{ baseURL }}"
|
|
72
72
|
},
|
|
73
73
|
commands: {
|
|
74
|
-
preview: "npx wrangler --cwd
|
|
75
|
-
deploy: "npx wrangler --cwd
|
|
74
|
+
preview: "npx wrangler --cwd {{ output.dir }} pages dev",
|
|
75
|
+
deploy: "npx wrangler --cwd {{ output.dir }} pages deploy"
|
|
76
76
|
},
|
|
77
77
|
hooks: {
|
|
78
78
|
"build:before": async (nitro) => {
|
|
@@ -104,7 +104,7 @@ export const cloudflareDev = defineNitroPreset(
|
|
|
104
104
|
{
|
|
105
105
|
name: "cloudflare-dev",
|
|
106
106
|
aliases: ["cloudflare-module", "cloudflare-durable", "cloudflare-pages"],
|
|
107
|
-
compatibilityDate: "2025-07-
|
|
107
|
+
compatibilityDate: "2025-07-15",
|
|
108
108
|
url: import.meta.url,
|
|
109
109
|
dev: true
|
|
110
110
|
}
|
|
@@ -118,8 +118,8 @@ const cloudflareModule = defineNitroPreset(
|
|
|
118
118
|
},
|
|
119
119
|
exportConditions: ["workerd"],
|
|
120
120
|
commands: {
|
|
121
|
-
preview: "npx wrangler --cwd
|
|
122
|
-
deploy: "npx wrangler --cwd
|
|
121
|
+
preview: "npx wrangler --cwd {{ output.dir }} dev",
|
|
122
|
+
deploy: "npx wrangler --cwd {{ output.dir }} deploy"
|
|
123
123
|
},
|
|
124
124
|
unenv: [unenvCfExternals],
|
|
125
125
|
rollupConfig: {
|
|
@@ -11,7 +11,7 @@ export const denoServerLegacy = defineNitroPreset(
|
|
|
11
11
|
entry: "./runtime/deno-server",
|
|
12
12
|
exportConditions: ["deno"],
|
|
13
13
|
commands: {
|
|
14
|
-
preview: "deno task --config
|
|
14
|
+
preview: "deno task --config {{ output.dir }}/deno.json start"
|
|
15
15
|
},
|
|
16
16
|
unenv: {
|
|
17
17
|
inject: {
|
|
@@ -12,7 +12,7 @@ const denoDeploy = defineNitroPreset(
|
|
|
12
12
|
serveStatic: "deno",
|
|
13
13
|
commands: {
|
|
14
14
|
preview: "",
|
|
15
|
-
deploy: "cd
|
|
15
|
+
deploy: "cd {{ output.dir }} && deployctl deploy --project=<project_name> ./server/index.ts"
|
|
16
16
|
},
|
|
17
17
|
unenv: unenvDenoPreset,
|
|
18
18
|
rollupConfig: {
|
|
@@ -37,7 +37,7 @@ const denoServer = defineNitroPreset(
|
|
|
37
37
|
entry: "./runtime/deno-server",
|
|
38
38
|
exportConditions: ["deno"],
|
|
39
39
|
commands: {
|
|
40
|
-
preview: "deno task --config
|
|
40
|
+
preview: "deno task --config {{ output.dir }}/deno.json start"
|
|
41
41
|
},
|
|
42
42
|
rollupConfig: {
|
|
43
43
|
external: (id) => id.startsWith("https://"),
|
|
@@ -5,8 +5,8 @@ const edgio = defineNitroPreset(
|
|
|
5
5
|
{
|
|
6
6
|
extends: "node-server",
|
|
7
7
|
commands: {
|
|
8
|
-
deploy: "cd
|
|
9
|
-
preview: "cd
|
|
8
|
+
deploy: "cd {{ output.dir }} && npm run deploy",
|
|
9
|
+
preview: "cd {{ output.dir }} && npm run preview"
|
|
10
10
|
},
|
|
11
11
|
hooks: {
|
|
12
12
|
async compiled(nitro) {
|
|
@@ -111,7 +111,7 @@ const netlifyStatic = defineNitroPreset(
|
|
|
111
111
|
publicDir: "{{ rootDir }}/dist/{{ baseURL }}"
|
|
112
112
|
},
|
|
113
113
|
commands: {
|
|
114
|
-
preview: "npx serve
|
|
114
|
+
preview: "npx serve {{ output.dir }}"
|
|
115
115
|
},
|
|
116
116
|
hooks: {
|
|
117
117
|
async compiled(nitro) {
|
|
@@ -128,25 +128,9 @@ const netlifyStatic = defineNitroPreset(
|
|
|
128
128
|
compatibilityDate: "2024-05-07"
|
|
129
129
|
}
|
|
130
130
|
);
|
|
131
|
-
const netlifyDev = defineNitroPreset(
|
|
132
|
-
{
|
|
133
|
-
extends: "nitro-dev",
|
|
134
|
-
modules: [
|
|
135
|
-
async (nitro) => await import("./dev.mjs").then((m) => m.netlifyDev(nitro))
|
|
136
|
-
]
|
|
137
|
-
},
|
|
138
|
-
{
|
|
139
|
-
name: "netlify-dev",
|
|
140
|
-
aliases: ["netlify"],
|
|
141
|
-
compatibilityDate: "2025-07-13",
|
|
142
|
-
url: import.meta.url,
|
|
143
|
-
dev: true
|
|
144
|
-
}
|
|
145
|
-
);
|
|
146
131
|
export default [
|
|
147
132
|
...netlifyLegacyPresets,
|
|
148
133
|
netlify,
|
|
149
134
|
netlifyEdge,
|
|
150
|
-
netlifyStatic
|
|
151
|
-
netlifyDev
|
|
135
|
+
netlifyStatic
|
|
152
136
|
];
|
|
@@ -16,8 +16,8 @@ const vercel = defineNitroPreset(
|
|
|
16
16
|
publicDir: "{{ output.dir }}/static/{{ baseURL }}"
|
|
17
17
|
},
|
|
18
18
|
commands: {
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
preview: "",
|
|
20
|
+
deploy: "npx vercel deploy --prebuilt"
|
|
21
21
|
},
|
|
22
22
|
hooks: {
|
|
23
23
|
"rollup:before": (nitro) => {
|
|
@@ -45,8 +45,8 @@ const vercelEdge = defineNitroPreset(
|
|
|
45
45
|
publicDir: "{{ output.dir }}/static/{{ baseURL }}"
|
|
46
46
|
},
|
|
47
47
|
commands: {
|
|
48
|
-
|
|
49
|
-
|
|
48
|
+
preview: "",
|
|
49
|
+
deploy: "npx vercel deploy --prebuilt"
|
|
50
50
|
},
|
|
51
51
|
unenv: {
|
|
52
52
|
external: builtnNodeModules.flatMap((m) => `node:${m}`),
|
|
@@ -90,7 +90,8 @@ const vercelStatic = defineNitroPreset(
|
|
|
90
90
|
publicDir: "{{ output.dir }}/static/{{ baseURL }}"
|
|
91
91
|
},
|
|
92
92
|
commands: {
|
|
93
|
-
preview: "npx serve {{ output.publicDir }}"
|
|
93
|
+
preview: "npx serve {{ output.publicDir }}",
|
|
94
|
+
deploy: "npx vercel deploy --prebuilt"
|
|
94
95
|
},
|
|
95
96
|
hooks: {
|
|
96
97
|
"rollup:before": (nitro) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nitropack-nightly",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.13.0-20250716-094945.42a23de2",
|
|
4
4
|
"description": "Build and Deploy Universal JavaScript Servers",
|
|
5
5
|
"repository": "nitrojs/nitro",
|
|
6
6
|
"license": "MIT",
|
|
@@ -77,8 +77,8 @@
|
|
|
77
77
|
],
|
|
78
78
|
"scripts": {
|
|
79
79
|
"build": "pnpm gen-presets && unbuild",
|
|
80
|
-
"dev": "pnpm
|
|
81
|
-
"dev:build": "pnpm
|
|
80
|
+
"dev": "pnpm -C playground dev",
|
|
81
|
+
"dev:build": "pnpm -C playground build",
|
|
82
82
|
"dev:start": "node playground/.output/server/index.mjs",
|
|
83
83
|
"gen-mirror": "pnpm jiti scripts/gen-mirror.ts",
|
|
84
84
|
"gen-node-compat": "pnpm node-ts scripts/gen-node-compat.ts",
|
|
@@ -175,8 +175,6 @@
|
|
|
175
175
|
"@azure/static-web-apps-cli": "^2.0.6",
|
|
176
176
|
"@cloudflare/workers-types": "^4.20250712.0",
|
|
177
177
|
"@deno/types": "^0.0.1",
|
|
178
|
-
"@netlify/dev": "^4.3.8",
|
|
179
|
-
"@netlify/dev-utils": "^3.2.2",
|
|
180
178
|
"@netlify/edge-functions": "^2.15.6",
|
|
181
179
|
"@scalar/api-reference": "^1.32.7",
|
|
182
180
|
"@types/archiver": "^6.0.3",
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
import { resolveModulePath } from "exsolve";
|
|
2
|
-
import { defineLazyEventHandler, fromNodeMiddleware } from "h3";
|
|
3
|
-
export async function netlifyDev(nitro) {
|
|
4
|
-
if (!nitro.options.dev || process.env.NETLIFY_DEV) {
|
|
5
|
-
return;
|
|
6
|
-
}
|
|
7
|
-
const netlifyDevEntry = resolveModulePath("@netlify/dev", {
|
|
8
|
-
from: nitro.options.nodeModulesDirs,
|
|
9
|
-
try: true
|
|
10
|
-
});
|
|
11
|
-
if (!netlifyDevEntry) {
|
|
12
|
-
nitro.logger.warn(
|
|
13
|
-
"Netlify local emulator is not installed. Please install it using `npx nypm i @netlify/dev` to enable dev emulation."
|
|
14
|
-
);
|
|
15
|
-
return;
|
|
16
|
-
}
|
|
17
|
-
const { NetlifyDev } = await import(netlifyDevEntry);
|
|
18
|
-
const logger = nitro.logger.withTag("netlify");
|
|
19
|
-
const netlifyDev2 = new NetlifyDev({
|
|
20
|
-
...nitro.options.netlify?.dev,
|
|
21
|
-
logger,
|
|
22
|
-
projectRoot: nitro.options.rootDir,
|
|
23
|
-
staticFiles: {
|
|
24
|
-
...nitro.options.netlify?.dev?.staticFiles,
|
|
25
|
-
directories: nitro.options.publicAssets.map((d) => d.dir)
|
|
26
|
-
}
|
|
27
|
-
});
|
|
28
|
-
await netlifyDev2.start();
|
|
29
|
-
nitro.hooks.hook("close", async () => {
|
|
30
|
-
await netlifyDev2.stop();
|
|
31
|
-
});
|
|
32
|
-
if (!netlifyDev2.siteIsLinked) {
|
|
33
|
-
logger.log(
|
|
34
|
-
`\u{1F4AD} Linking this project to a Netlify site lets you deploy your site, use any environment variables defined on your team and site and much more. Run \`npx netlify init\` to get started.`
|
|
35
|
-
);
|
|
36
|
-
}
|
|
37
|
-
nitro.options.devHandlers ??= [];
|
|
38
|
-
nitro.options.devHandlers.push({
|
|
39
|
-
handler: defineLazyEventHandler(() => {
|
|
40
|
-
return fromNodeMiddleware(
|
|
41
|
-
async function netlifyPreMiddleware(nodeReq, nodeRes, next) {
|
|
42
|
-
if (!netlifyDev2) {
|
|
43
|
-
return;
|
|
44
|
-
}
|
|
45
|
-
const headers = {};
|
|
46
|
-
const result = await netlifyDev2.handleAndIntrospectNodeRequest(
|
|
47
|
-
nodeReq,
|
|
48
|
-
{
|
|
49
|
-
headersCollector: (key, value) => {
|
|
50
|
-
headers[key] = value;
|
|
51
|
-
},
|
|
52
|
-
serverAddress: `http://localhost:${nodeReq.socket.localPort}`
|
|
53
|
-
}
|
|
54
|
-
);
|
|
55
|
-
const isStaticFile = result?.type === "static";
|
|
56
|
-
if (result && !isStaticFile) {
|
|
57
|
-
fromWebResponse(result.response, nodeRes);
|
|
58
|
-
return;
|
|
59
|
-
}
|
|
60
|
-
for (const key in headers) {
|
|
61
|
-
nodeRes.setHeader(key, headers[key] ?? "");
|
|
62
|
-
}
|
|
63
|
-
next();
|
|
64
|
-
}
|
|
65
|
-
);
|
|
66
|
-
})
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
async function fromWebResponse(webRes, res) {
|
|
70
|
-
res.statusCode = webRes.status;
|
|
71
|
-
for (const [name, value] of webRes.headers.entries()) {
|
|
72
|
-
res.setHeader(name, value);
|
|
73
|
-
}
|
|
74
|
-
if (webRes.body) {
|
|
75
|
-
const reader = webRes.body.getReader();
|
|
76
|
-
const writer = res;
|
|
77
|
-
while (true) {
|
|
78
|
-
const { done, value } = await reader.read();
|
|
79
|
-
if (done) {
|
|
80
|
-
break;
|
|
81
|
-
}
|
|
82
|
-
writer.write(value);
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
res.end();
|
|
86
|
-
}
|