@sveltejs/adapter-netlify 5.1.0 → 5.2.0
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 +48 -5
- package/package.json +3 -3
package/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/** @import { BuildOptions } from 'esbuild' */
|
|
1
2
|
import { appendFileSync, existsSync, readdirSync, readFileSync, writeFileSync } from 'node:fs';
|
|
2
3
|
import { dirname, join, resolve, posix } from 'node:path';
|
|
3
4
|
import { fileURLToPath } from 'node:url';
|
|
@@ -106,7 +107,8 @@ export default function ({ split = false, edge = edge_set_in_env_var } = {}) {
|
|
|
106
107
|
}
|
|
107
108
|
|
|
108
109
|
return true;
|
|
109
|
-
}
|
|
110
|
+
},
|
|
111
|
+
instrumentation: () => true
|
|
110
112
|
}
|
|
111
113
|
};
|
|
112
114
|
}
|
|
@@ -174,9 +176,8 @@ async function generate_edge_functions({ builder }) {
|
|
|
174
176
|
version: 1
|
|
175
177
|
};
|
|
176
178
|
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
outfile: '.netlify/edge-functions/render.js',
|
|
179
|
+
/** @type {BuildOptions} */
|
|
180
|
+
const esbuild_config = {
|
|
180
181
|
bundle: true,
|
|
181
182
|
format: 'esm',
|
|
182
183
|
platform: 'browser',
|
|
@@ -194,7 +195,28 @@ async function generate_edge_functions({ builder }) {
|
|
|
194
195
|
// https://docs.netlify.com/edge-functions/api/#runtime-environment
|
|
195
196
|
external: builtinModules.map((id) => `node:${id}`),
|
|
196
197
|
alias: Object.fromEntries(builtinModules.map((id) => [id, `node:${id}`]))
|
|
197
|
-
}
|
|
198
|
+
};
|
|
199
|
+
await Promise.all([
|
|
200
|
+
esbuild.build({
|
|
201
|
+
entryPoints: [`${tmp}/entry.js`],
|
|
202
|
+
outfile: '.netlify/edge-functions/render.js',
|
|
203
|
+
...esbuild_config
|
|
204
|
+
}),
|
|
205
|
+
builder.hasServerInstrumentationFile() &&
|
|
206
|
+
esbuild.build({
|
|
207
|
+
entryPoints: [`${builder.getServerDirectory()}/instrumentation.server.js`],
|
|
208
|
+
outfile: '.netlify/edge/instrumentation.server.js',
|
|
209
|
+
...esbuild_config
|
|
210
|
+
})
|
|
211
|
+
]);
|
|
212
|
+
|
|
213
|
+
if (builder.hasServerInstrumentationFile()) {
|
|
214
|
+
builder.instrument({
|
|
215
|
+
entrypoint: '.netlify/edge-functions/render.js',
|
|
216
|
+
instrumentation: '.netlify/edge/instrumentation.server.js',
|
|
217
|
+
start: '.netlify/edge/start.js'
|
|
218
|
+
});
|
|
219
|
+
}
|
|
198
220
|
|
|
199
221
|
writeFileSync('.netlify/edge-functions/manifest.json', JSON.stringify(edge_manifest));
|
|
200
222
|
}
|
|
@@ -272,6 +294,16 @@ function generate_lambda_functions({ builder, publish, split }) {
|
|
|
272
294
|
|
|
273
295
|
writeFileSync(`.netlify/functions-internal/${name}.mjs`, fn);
|
|
274
296
|
writeFileSync(`.netlify/functions-internal/${name}.json`, fn_config);
|
|
297
|
+
if (builder.hasServerInstrumentationFile()) {
|
|
298
|
+
builder.instrument({
|
|
299
|
+
entrypoint: `.netlify/functions-internal/${name}.mjs`,
|
|
300
|
+
instrumentation: '.netlify/server/instrumentation.server.js',
|
|
301
|
+
start: `.netlify/functions-start/${name}.start.mjs`,
|
|
302
|
+
module: {
|
|
303
|
+
exports: ['handler']
|
|
304
|
+
}
|
|
305
|
+
});
|
|
306
|
+
}
|
|
275
307
|
|
|
276
308
|
const redirect = `/.netlify/functions/${name} 200`;
|
|
277
309
|
redirects.push(`${pattern} ${redirect}`);
|
|
@@ -286,6 +318,17 @@ function generate_lambda_functions({ builder, publish, split }) {
|
|
|
286
318
|
|
|
287
319
|
writeFileSync(`.netlify/functions-internal/${FUNCTION_PREFIX}render.json`, fn_config);
|
|
288
320
|
writeFileSync(`.netlify/functions-internal/${FUNCTION_PREFIX}render.mjs`, fn);
|
|
321
|
+
if (builder.hasServerInstrumentationFile()) {
|
|
322
|
+
builder.instrument({
|
|
323
|
+
entrypoint: `.netlify/functions-internal/${FUNCTION_PREFIX}render.mjs`,
|
|
324
|
+
instrumentation: '.netlify/server/instrumentation.server.js',
|
|
325
|
+
start: `.netlify/functions-start/${FUNCTION_PREFIX}render.start.mjs`,
|
|
326
|
+
module: {
|
|
327
|
+
exports: ['handler']
|
|
328
|
+
}
|
|
329
|
+
});
|
|
330
|
+
}
|
|
331
|
+
|
|
289
332
|
redirects.push(`* /.netlify/functions/${FUNCTION_PREFIX}render 200`);
|
|
290
333
|
}
|
|
291
334
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sveltejs/adapter-netlify",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.2.0",
|
|
4
4
|
"description": "A SvelteKit adapter that creates a Netlify app",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"adapter",
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
],
|
|
13
13
|
"repository": {
|
|
14
14
|
"type": "git",
|
|
15
|
-
"url": "https://github.com/sveltejs/kit",
|
|
15
|
+
"url": "git+https://github.com/sveltejs/kit.git",
|
|
16
16
|
"directory": "packages/adapter-netlify"
|
|
17
17
|
},
|
|
18
18
|
"license": "MIT",
|
|
@@ -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.31.0"
|
|
52
52
|
},
|
|
53
53
|
"peerDependencies": {
|
|
54
54
|
"@sveltejs/kit": "^2.4.0"
|