@sveltejs/adapter-netlify 6.0.0 → 6.0.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/index.js +62 -14
- package/package.json +2 -2
package/index.js
CHANGED
|
@@ -191,7 +191,7 @@ async function generate_edge_functions({ builder }) {
|
|
|
191
191
|
outfile: '.netlify/edge-functions/render.js',
|
|
192
192
|
...esbuild_config
|
|
193
193
|
}),
|
|
194
|
-
builder.hasServerInstrumentationFile
|
|
194
|
+
builder.hasServerInstrumentationFile() &&
|
|
195
195
|
esbuild.build({
|
|
196
196
|
entryPoints: [`${builder.getServerDirectory()}/instrumentation.server.js`],
|
|
197
197
|
outfile: '.netlify/edge/instrumentation.server.js',
|
|
@@ -199,8 +199,8 @@ async function generate_edge_functions({ builder }) {
|
|
|
199
199
|
})
|
|
200
200
|
]);
|
|
201
201
|
|
|
202
|
-
if (builder.hasServerInstrumentationFile
|
|
203
|
-
builder.instrument
|
|
202
|
+
if (builder.hasServerInstrumentationFile()) {
|
|
203
|
+
builder.instrument({
|
|
204
204
|
entrypoint: '.netlify/edge-functions/render.js',
|
|
205
205
|
instrumentation: '.netlify/edge/instrumentation.server.js',
|
|
206
206
|
start: '.netlify/edge/start.js'
|
|
@@ -245,7 +245,8 @@ function generate_lambda_functions({ builder, publish, split }) {
|
|
|
245
245
|
parts.push('*');
|
|
246
246
|
break; // Netlify redirects don't allow anything after a *
|
|
247
247
|
} else if (segment.dynamic) {
|
|
248
|
-
|
|
248
|
+
// URLPattern requires params to start with letters
|
|
249
|
+
parts.push(`:param${parts.length}`);
|
|
249
250
|
} else {
|
|
250
251
|
parts.push(segment.content);
|
|
251
252
|
}
|
|
@@ -274,18 +275,21 @@ function generate_lambda_functions({ builder, publish, split }) {
|
|
|
274
275
|
routes
|
|
275
276
|
});
|
|
276
277
|
|
|
277
|
-
const fn =
|
|
278
|
+
const fn = generate_serverless_function_module(manifest);
|
|
279
|
+
const config = generate_config_export(pattern);
|
|
278
280
|
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
builder.instrument
|
|
281
|
+
if (builder.hasServerInstrumentationFile()) {
|
|
282
|
+
writeFileSync(`.netlify/functions-internal/${name}.mjs`, fn);
|
|
283
|
+
builder.instrument({
|
|
282
284
|
entrypoint: `.netlify/functions-internal/${name}.mjs`,
|
|
283
285
|
instrumentation: '.netlify/server/instrumentation.server.js',
|
|
284
286
|
start: `.netlify/functions-start/${name}.start.mjs`,
|
|
285
287
|
module: {
|
|
286
|
-
|
|
288
|
+
generateText: generate_traced_module(config)
|
|
287
289
|
}
|
|
288
290
|
});
|
|
291
|
+
} else {
|
|
292
|
+
writeFileSync(`.netlify/functions-internal/${name}.mjs`, `${fn}\n${config}`);
|
|
289
293
|
}
|
|
290
294
|
}
|
|
291
295
|
} else {
|
|
@@ -293,18 +297,21 @@ function generate_lambda_functions({ builder, publish, split }) {
|
|
|
293
297
|
relativePath: '../server'
|
|
294
298
|
});
|
|
295
299
|
|
|
296
|
-
const fn =
|
|
300
|
+
const fn = generate_serverless_function_module(manifest);
|
|
301
|
+
const config = generate_config_export('/*');
|
|
297
302
|
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
builder.instrument
|
|
303
|
+
if (builder.hasServerInstrumentationFile()) {
|
|
304
|
+
writeFileSync(`.netlify/functions-internal/${FUNCTION_PREFIX}render.mjs`, fn);
|
|
305
|
+
builder.instrument({
|
|
301
306
|
entrypoint: `.netlify/functions-internal/${FUNCTION_PREFIX}render.mjs`,
|
|
302
307
|
instrumentation: '.netlify/server/instrumentation.server.js',
|
|
303
308
|
start: `.netlify/functions-start/${FUNCTION_PREFIX}render.start.mjs`,
|
|
304
309
|
module: {
|
|
305
|
-
|
|
310
|
+
generateText: generate_traced_module(config)
|
|
306
311
|
}
|
|
307
312
|
});
|
|
313
|
+
} else {
|
|
314
|
+
writeFileSync(`.netlify/functions-internal/${FUNCTION_PREFIX}render.mjs`, `${fn}\n${config}`);
|
|
308
315
|
}
|
|
309
316
|
}
|
|
310
317
|
|
|
@@ -386,3 +393,44 @@ function matches(a, b) {
|
|
|
386
393
|
return b.length === 1 && b[0].rest;
|
|
387
394
|
}
|
|
388
395
|
}
|
|
396
|
+
|
|
397
|
+
/**
|
|
398
|
+
* @param {string} manifest
|
|
399
|
+
* @returns {string}
|
|
400
|
+
*/
|
|
401
|
+
function generate_serverless_function_module(manifest) {
|
|
402
|
+
return `\
|
|
403
|
+
import { init } from '../serverless.js';
|
|
404
|
+
|
|
405
|
+
export default init(${manifest});
|
|
406
|
+
`;
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
/**
|
|
410
|
+
* @param {string} pattern
|
|
411
|
+
* @returns {string}
|
|
412
|
+
*/
|
|
413
|
+
function generate_config_export(pattern) {
|
|
414
|
+
return `\
|
|
415
|
+
export const config = {
|
|
416
|
+
path: "${pattern}",
|
|
417
|
+
excludedPath: "/.netlify/*",
|
|
418
|
+
preferStatic: true
|
|
419
|
+
};
|
|
420
|
+
`;
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
/**
|
|
424
|
+
* @param {string} config
|
|
425
|
+
* @returns {(opts: { instrumentation: string; start: string }) => string}
|
|
426
|
+
*/
|
|
427
|
+
function generate_traced_module(config) {
|
|
428
|
+
return ({ instrumentation, start }) => {
|
|
429
|
+
return `\
|
|
430
|
+
import './${instrumentation}';
|
|
431
|
+
const { default: _0 } = await import('./${start}');
|
|
432
|
+
export { _0 as default };
|
|
433
|
+
|
|
434
|
+
${config}`;
|
|
435
|
+
};
|
|
436
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sveltejs/adapter-netlify",
|
|
3
|
-
"version": "6.0.
|
|
3
|
+
"version": "6.0.2",
|
|
4
4
|
"description": "A SvelteKit adapter that creates a Netlify app",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"adapter",
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"rollup": "^4.14.2",
|
|
51
51
|
"typescript": "^5.3.3",
|
|
52
52
|
"vitest": "^4.0.0",
|
|
53
|
-
"@sveltejs/kit": "^2.
|
|
53
|
+
"@sveltejs/kit": "^2.52.2"
|
|
54
54
|
},
|
|
55
55
|
"peerDependencies": {
|
|
56
56
|
"@sveltejs/kit": "^2.31.0"
|