@sveltejs/adapter-netlify 5.2.0 → 5.2.2
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/files/serverless.js +5 -6
- package/index.js +25 -13
- package/package.json +2 -2
package/files/serverless.js
CHANGED
|
@@ -290,8 +290,9 @@ function createReadableStream(file) {
|
|
|
290
290
|
function init(manifest) {
|
|
291
291
|
const server = new Server(manifest);
|
|
292
292
|
|
|
293
|
+
/** @type {Promise<void> | null} */
|
|
293
294
|
let init_promise = server.init({
|
|
294
|
-
env: process.env,
|
|
295
|
+
env: /** @type {Record<string, string>} */ (process.env),
|
|
295
296
|
read: (file) => createReadableStream(`.netlify/server/${file}`)
|
|
296
297
|
});
|
|
297
298
|
|
|
@@ -304,7 +305,7 @@ function init(manifest) {
|
|
|
304
305
|
const response = await server.respond(to_request(event), {
|
|
305
306
|
platform: { context },
|
|
306
307
|
getClientAddress() {
|
|
307
|
-
return event.headers['x-nf-client-connection-ip'];
|
|
308
|
+
return /** @type {string} */ (event.headers['x-nf-client-connection-ip']);
|
|
308
309
|
}
|
|
309
310
|
});
|
|
310
311
|
|
|
@@ -335,13 +336,11 @@ function init(manifest) {
|
|
|
335
336
|
* @param {import('@netlify/functions').HandlerEvent} event
|
|
336
337
|
* @returns {Request}
|
|
337
338
|
*/
|
|
338
|
-
function to_request(
|
|
339
|
-
const { httpMethod, headers, rawUrl, body, isBase64Encoded } = event;
|
|
340
|
-
|
|
339
|
+
function to_request({ httpMethod, headers, rawUrl, body, isBase64Encoded }) {
|
|
341
340
|
/** @type {RequestInit} */
|
|
342
341
|
const init = {
|
|
343
342
|
method: httpMethod,
|
|
344
|
-
headers: new Headers(headers)
|
|
343
|
+
headers: new Headers(/** @type {Record<string, string>} */ (headers))
|
|
345
344
|
};
|
|
346
345
|
|
|
347
346
|
if (httpMethod !== 'GET' && httpMethod !== 'HEAD') {
|
package/index.js
CHANGED
|
@@ -17,6 +17,17 @@ const [kit_major, kit_minor] = VERSION.split('.');
|
|
|
17
17
|
* } & toml.JsonMap} NetlifyConfig
|
|
18
18
|
*/
|
|
19
19
|
|
|
20
|
+
/**
|
|
21
|
+
* @template T
|
|
22
|
+
* @template {keyof T} K
|
|
23
|
+
* @typedef {Partial<Omit<T, K>> & Required<Pick<T, K>>} PartialExcept
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* We use a custom `Builder` type here to support the minimum version of SvelteKit.
|
|
28
|
+
* @typedef {PartialExcept<import('@sveltejs/kit').Builder, 'log' | 'rimraf' | 'mkdirp' | 'config' | 'prerendered' | 'routes' | 'createEntries' | 'findServerAssets' | 'generateFallback' | 'generateEnvModule' | 'generateManifest' | 'getBuildDirectory' | 'getClientDirectory' | 'getServerDirectory' | 'getAppPath' | 'writeClient' | 'writePrerendered' | 'writePrerendered' | 'writeServer' | 'copy' | 'compress'>} Builder2_4_0
|
|
29
|
+
*/
|
|
30
|
+
|
|
20
31
|
const name = '@sveltejs/adapter-netlify';
|
|
21
32
|
const files = fileURLToPath(new URL('./files', import.meta.url).href);
|
|
22
33
|
|
|
@@ -30,7 +41,7 @@ const FUNCTION_PREFIX = 'sveltekit-';
|
|
|
30
41
|
export default function ({ split = false, edge = edge_set_in_env_var } = {}) {
|
|
31
42
|
return {
|
|
32
43
|
name,
|
|
33
|
-
|
|
44
|
+
/** @param {Builder2_4_0} builder */
|
|
34
45
|
async adapt(builder) {
|
|
35
46
|
if (!builder.routes) {
|
|
36
47
|
throw new Error(
|
|
@@ -114,7 +125,7 @@ export default function ({ split = false, edge = edge_set_in_env_var } = {}) {
|
|
|
114
125
|
}
|
|
115
126
|
/**
|
|
116
127
|
* @param { object } params
|
|
117
|
-
* @param {
|
|
128
|
+
* @param {Builder2_4_0} params.builder
|
|
118
129
|
*/
|
|
119
130
|
async function generate_edge_functions({ builder }) {
|
|
120
131
|
const tmp = builder.getBuildDirectory('netlify-tmp');
|
|
@@ -148,7 +159,8 @@ async function generate_edge_functions({ builder }) {
|
|
|
148
159
|
// Netlify will handle the optional trailing slash for us
|
|
149
160
|
const excluded = [
|
|
150
161
|
// Contains static files
|
|
151
|
-
`/${builder.getAppPath()}/*`,
|
|
162
|
+
`/${builder.getAppPath()}/immutable/*`,
|
|
163
|
+
`/${builder.getAppPath()}/version.json`,
|
|
152
164
|
...builder.prerendered.paths,
|
|
153
165
|
...Array.from(assets).flatMap((asset) => {
|
|
154
166
|
if (asset.endsWith('/index.html')) {
|
|
@@ -202,7 +214,7 @@ async function generate_edge_functions({ builder }) {
|
|
|
202
214
|
outfile: '.netlify/edge-functions/render.js',
|
|
203
215
|
...esbuild_config
|
|
204
216
|
}),
|
|
205
|
-
builder.hasServerInstrumentationFile() &&
|
|
217
|
+
builder.hasServerInstrumentationFile?.() &&
|
|
206
218
|
esbuild.build({
|
|
207
219
|
entryPoints: [`${builder.getServerDirectory()}/instrumentation.server.js`],
|
|
208
220
|
outfile: '.netlify/edge/instrumentation.server.js',
|
|
@@ -210,8 +222,8 @@ async function generate_edge_functions({ builder }) {
|
|
|
210
222
|
})
|
|
211
223
|
]);
|
|
212
224
|
|
|
213
|
-
if (builder.hasServerInstrumentationFile()) {
|
|
214
|
-
builder.instrument({
|
|
225
|
+
if (builder.hasServerInstrumentationFile?.()) {
|
|
226
|
+
builder.instrument?.({
|
|
215
227
|
entrypoint: '.netlify/edge-functions/render.js',
|
|
216
228
|
instrumentation: '.netlify/edge/instrumentation.server.js',
|
|
217
229
|
start: '.netlify/edge/start.js'
|
|
@@ -222,7 +234,7 @@ async function generate_edge_functions({ builder }) {
|
|
|
222
234
|
}
|
|
223
235
|
/**
|
|
224
236
|
* @param { object } params
|
|
225
|
-
* @param {
|
|
237
|
+
* @param {Builder2_4_0} params.builder
|
|
226
238
|
* @param { string } params.publish
|
|
227
239
|
* @param { boolean } params.split
|
|
228
240
|
*/
|
|
@@ -294,8 +306,8 @@ function generate_lambda_functions({ builder, publish, split }) {
|
|
|
294
306
|
|
|
295
307
|
writeFileSync(`.netlify/functions-internal/${name}.mjs`, fn);
|
|
296
308
|
writeFileSync(`.netlify/functions-internal/${name}.json`, fn_config);
|
|
297
|
-
if (builder.hasServerInstrumentationFile()) {
|
|
298
|
-
builder.instrument({
|
|
309
|
+
if (builder.hasServerInstrumentationFile?.()) {
|
|
310
|
+
builder.instrument?.({
|
|
299
311
|
entrypoint: `.netlify/functions-internal/${name}.mjs`,
|
|
300
312
|
instrumentation: '.netlify/server/instrumentation.server.js',
|
|
301
313
|
start: `.netlify/functions-start/${name}.start.mjs`,
|
|
@@ -318,8 +330,8 @@ function generate_lambda_functions({ builder, publish, split }) {
|
|
|
318
330
|
|
|
319
331
|
writeFileSync(`.netlify/functions-internal/${FUNCTION_PREFIX}render.json`, fn_config);
|
|
320
332
|
writeFileSync(`.netlify/functions-internal/${FUNCTION_PREFIX}render.mjs`, fn);
|
|
321
|
-
if (builder.hasServerInstrumentationFile()) {
|
|
322
|
-
builder.instrument({
|
|
333
|
+
if (builder.hasServerInstrumentationFile?.()) {
|
|
334
|
+
builder.instrument?.({
|
|
323
335
|
entrypoint: `.netlify/functions-internal/${FUNCTION_PREFIX}render.mjs`,
|
|
324
336
|
instrumentation: '.netlify/server/instrumentation.server.js',
|
|
325
337
|
start: `.netlify/functions-start/${FUNCTION_PREFIX}render.start.mjs`,
|
|
@@ -356,8 +368,8 @@ function get_netlify_config() {
|
|
|
356
368
|
}
|
|
357
369
|
|
|
358
370
|
/**
|
|
359
|
-
* @param {NetlifyConfig} netlify_config
|
|
360
|
-
* @param {
|
|
371
|
+
* @param {NetlifyConfig | null} netlify_config
|
|
372
|
+
* @param {Builder2_4_0} builder
|
|
361
373
|
**/
|
|
362
374
|
function get_publish_directory(netlify_config, builder) {
|
|
363
375
|
if (netlify_config) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sveltejs/adapter-netlify",
|
|
3
|
-
"version": "5.2.
|
|
3
|
+
"version": "5.2.2",
|
|
4
4
|
"description": "A SvelteKit adapter that creates a Netlify app",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"adapter",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"rollup": "^4.14.2",
|
|
49
49
|
"typescript": "^5.3.3",
|
|
50
50
|
"vitest": "^3.2.3",
|
|
51
|
-
"@sveltejs/kit": "^2.
|
|
51
|
+
"@sveltejs/kit": "^2.33.1"
|
|
52
52
|
},
|
|
53
53
|
"peerDependencies": {
|
|
54
54
|
"@sveltejs/kit": "^2.4.0"
|