@sveltejs/adapter-netlify 5.2.0 → 5.2.1
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 +23 -12
- 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');
|
|
@@ -202,7 +213,7 @@ async function generate_edge_functions({ builder }) {
|
|
|
202
213
|
outfile: '.netlify/edge-functions/render.js',
|
|
203
214
|
...esbuild_config
|
|
204
215
|
}),
|
|
205
|
-
builder.hasServerInstrumentationFile() &&
|
|
216
|
+
builder.hasServerInstrumentationFile?.() &&
|
|
206
217
|
esbuild.build({
|
|
207
218
|
entryPoints: [`${builder.getServerDirectory()}/instrumentation.server.js`],
|
|
208
219
|
outfile: '.netlify/edge/instrumentation.server.js',
|
|
@@ -210,8 +221,8 @@ async function generate_edge_functions({ builder }) {
|
|
|
210
221
|
})
|
|
211
222
|
]);
|
|
212
223
|
|
|
213
|
-
if (builder.hasServerInstrumentationFile()) {
|
|
214
|
-
builder.instrument({
|
|
224
|
+
if (builder.hasServerInstrumentationFile?.()) {
|
|
225
|
+
builder.instrument?.({
|
|
215
226
|
entrypoint: '.netlify/edge-functions/render.js',
|
|
216
227
|
instrumentation: '.netlify/edge/instrumentation.server.js',
|
|
217
228
|
start: '.netlify/edge/start.js'
|
|
@@ -222,7 +233,7 @@ async function generate_edge_functions({ builder }) {
|
|
|
222
233
|
}
|
|
223
234
|
/**
|
|
224
235
|
* @param { object } params
|
|
225
|
-
* @param {
|
|
236
|
+
* @param {Builder2_4_0} params.builder
|
|
226
237
|
* @param { string } params.publish
|
|
227
238
|
* @param { boolean } params.split
|
|
228
239
|
*/
|
|
@@ -294,8 +305,8 @@ function generate_lambda_functions({ builder, publish, split }) {
|
|
|
294
305
|
|
|
295
306
|
writeFileSync(`.netlify/functions-internal/${name}.mjs`, fn);
|
|
296
307
|
writeFileSync(`.netlify/functions-internal/${name}.json`, fn_config);
|
|
297
|
-
if (builder.hasServerInstrumentationFile()) {
|
|
298
|
-
builder.instrument({
|
|
308
|
+
if (builder.hasServerInstrumentationFile?.()) {
|
|
309
|
+
builder.instrument?.({
|
|
299
310
|
entrypoint: `.netlify/functions-internal/${name}.mjs`,
|
|
300
311
|
instrumentation: '.netlify/server/instrumentation.server.js',
|
|
301
312
|
start: `.netlify/functions-start/${name}.start.mjs`,
|
|
@@ -318,8 +329,8 @@ function generate_lambda_functions({ builder, publish, split }) {
|
|
|
318
329
|
|
|
319
330
|
writeFileSync(`.netlify/functions-internal/${FUNCTION_PREFIX}render.json`, fn_config);
|
|
320
331
|
writeFileSync(`.netlify/functions-internal/${FUNCTION_PREFIX}render.mjs`, fn);
|
|
321
|
-
if (builder.hasServerInstrumentationFile()) {
|
|
322
|
-
builder.instrument({
|
|
332
|
+
if (builder.hasServerInstrumentationFile?.()) {
|
|
333
|
+
builder.instrument?.({
|
|
323
334
|
entrypoint: `.netlify/functions-internal/${FUNCTION_PREFIX}render.mjs`,
|
|
324
335
|
instrumentation: '.netlify/server/instrumentation.server.js',
|
|
325
336
|
start: `.netlify/functions-start/${FUNCTION_PREFIX}render.start.mjs`,
|
|
@@ -356,8 +367,8 @@ function get_netlify_config() {
|
|
|
356
367
|
}
|
|
357
368
|
|
|
358
369
|
/**
|
|
359
|
-
* @param {NetlifyConfig} netlify_config
|
|
360
|
-
* @param {
|
|
370
|
+
* @param {NetlifyConfig | null} netlify_config
|
|
371
|
+
* @param {Builder2_4_0} builder
|
|
361
372
|
**/
|
|
362
373
|
function get_publish_directory(netlify_config, builder) {
|
|
363
374
|
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.1",
|
|
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.31.
|
|
51
|
+
"@sveltejs/kit": "^2.31.1"
|
|
52
52
|
},
|
|
53
53
|
"peerDependencies": {
|
|
54
54
|
"@sveltejs/kit": "^2.4.0"
|