@sveltejs/adapter-netlify 2.0.1 → 2.0.3
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/esm/serverless.js +1 -0
- package/files/esm/shims.js +6 -1
- package/index.js +21 -10
- package/package.json +2 -2
package/files/esm/serverless.js
CHANGED
package/files/esm/shims.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ReadableStream as ReadableStream$1, TransformStream, WritableStream } from 'node:stream/web';
|
|
2
|
+
import buffer from 'node:buffer';
|
|
2
3
|
import { webcrypto } from 'node:crypto';
|
|
3
4
|
import require$$0$1 from 'assert';
|
|
4
5
|
import require$$4 from 'net';
|
|
@@ -20744,6 +20745,9 @@ function requireUndici () {
|
|
|
20744
20745
|
|
|
20745
20746
|
var undiciExports = requireUndici();
|
|
20746
20747
|
|
|
20748
|
+
// @ts-expect-error
|
|
20749
|
+
const File = buffer.File ?? undiciExports.File;
|
|
20750
|
+
|
|
20747
20751
|
/** @type {Record<string, any>} */
|
|
20748
20752
|
const globals = {
|
|
20749
20753
|
crypto: webcrypto,
|
|
@@ -20754,7 +20758,8 @@ const globals = {
|
|
|
20754
20758
|
ReadableStream: ReadableStream$1,
|
|
20755
20759
|
TransformStream,
|
|
20756
20760
|
WritableStream,
|
|
20757
|
-
FormData: undiciExports.FormData
|
|
20761
|
+
FormData: undiciExports.FormData,
|
|
20762
|
+
File
|
|
20758
20763
|
};
|
|
20759
20764
|
|
|
20760
20765
|
// exported for dev/preview and node environments
|
package/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { appendFileSync, existsSync, readFileSync, writeFileSync } from 'fs';
|
|
1
|
+
import { appendFileSync, existsSync, readdirSync, readFileSync, writeFileSync } from 'fs';
|
|
2
2
|
import { dirname, join, resolve, posix } from 'path';
|
|
3
3
|
import { fileURLToPath } from 'url';
|
|
4
4
|
import esbuild from 'esbuild';
|
|
@@ -33,6 +33,8 @@ const edge_set_in_env_var =
|
|
|
33
33
|
process.env.NETLIFY_SVELTEKIT_USE_EDGE === 'true' ||
|
|
34
34
|
process.env.NETLIFY_SVELTEKIT_USE_EDGE === '1';
|
|
35
35
|
|
|
36
|
+
const FUNCTION_PREFIX = 'sveltekit-';
|
|
37
|
+
|
|
36
38
|
/** @type {import('.').default} */
|
|
37
39
|
export default function ({ split = false, edge = edge_set_in_env_var } = {}) {
|
|
38
40
|
return {
|
|
@@ -54,11 +56,18 @@ export default function ({ split = false, edge = edge_set_in_env_var } = {}) {
|
|
|
54
56
|
// empty out existing build directories
|
|
55
57
|
builder.rimraf(publish);
|
|
56
58
|
builder.rimraf('.netlify/edge-functions');
|
|
57
|
-
builder.rimraf('.netlify/functions-internal');
|
|
58
59
|
builder.rimraf('.netlify/server');
|
|
59
60
|
builder.rimraf('.netlify/package.json');
|
|
60
61
|
builder.rimraf('.netlify/serverless.js');
|
|
61
62
|
|
|
63
|
+
if (existsSync('.netlify/functions-internal')) {
|
|
64
|
+
for (const file of readdirSync('.netlify/functions-internal')) {
|
|
65
|
+
if (file.startsWith(FUNCTION_PREFIX)) {
|
|
66
|
+
builder.rimraf(join('.netlify/functions-internal', file));
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
62
71
|
builder.log.minor(`Publishing to "${publish}"`);
|
|
63
72
|
|
|
64
73
|
builder.log.minor('Copying assets...');
|
|
@@ -154,7 +163,7 @@ async function generate_edge_functions({ builder }) {
|
|
|
154
163
|
* @param { boolean } params.split
|
|
155
164
|
*/
|
|
156
165
|
async function generate_lambda_functions({ builder, publish, split }) {
|
|
157
|
-
builder.mkdirp('.netlify/functions-internal');
|
|
166
|
+
builder.mkdirp('.netlify/functions-internal/.svelte-kit');
|
|
158
167
|
|
|
159
168
|
/** @type {string[]} */
|
|
160
169
|
const redirects = [];
|
|
@@ -195,7 +204,8 @@ async function generate_lambda_functions({ builder, publish, split }) {
|
|
|
195
204
|
}
|
|
196
205
|
|
|
197
206
|
const pattern = `/${parts.join('/')}`;
|
|
198
|
-
const name =
|
|
207
|
+
const name =
|
|
208
|
+
FUNCTION_PREFIX + (parts.join('-').replace(/[:.]/g, '_').replace('*', '__rest') || 'index');
|
|
199
209
|
|
|
200
210
|
// skip routes with identical patterns, they were already folded into another function
|
|
201
211
|
if (seen.has(pattern)) continue;
|
|
@@ -203,10 +213,11 @@ async function generate_lambda_functions({ builder, publish, split }) {
|
|
|
203
213
|
|
|
204
214
|
// figure out which lower priority routes should be considered fallbacks
|
|
205
215
|
for (let j = i + 1; j < builder.routes.length; j += 1) {
|
|
206
|
-
|
|
216
|
+
const other = builder.routes[j];
|
|
217
|
+
if (other.prerender === true) continue;
|
|
207
218
|
|
|
208
|
-
if (matches(route.segments,
|
|
209
|
-
routes.push(
|
|
219
|
+
if (matches(route.segments, other.segments)) {
|
|
220
|
+
routes.push(other);
|
|
210
221
|
}
|
|
211
222
|
}
|
|
212
223
|
|
|
@@ -230,9 +241,9 @@ async function generate_lambda_functions({ builder, publish, split }) {
|
|
|
230
241
|
|
|
231
242
|
const fn = `import { init } from '../serverless.js';\n\nexport const handler = init(${manifest});\n`;
|
|
232
243
|
|
|
233
|
-
writeFileSync(`.netlify/functions-internal
|
|
234
|
-
writeFileSync(
|
|
235
|
-
redirects.push(
|
|
244
|
+
writeFileSync(`.netlify/functions-internal/${FUNCTION_PREFIX}render.json`, fn_config);
|
|
245
|
+
writeFileSync(`.netlify/functions-internal/${FUNCTION_PREFIX}render.mjs`, fn);
|
|
246
|
+
redirects.push(`* /.netlify/functions/${FUNCTION_PREFIX}render 200`);
|
|
236
247
|
}
|
|
237
248
|
|
|
238
249
|
// this should happen at the end, after builder.writeClient(...),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sveltejs/adapter-netlify",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.3",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/sveltejs/kit",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"rollup": "^3.7.0",
|
|
39
39
|
"typescript": "^4.9.4",
|
|
40
40
|
"uvu": "^0.5.6",
|
|
41
|
-
"@sveltejs/kit": "^1.5.
|
|
41
|
+
"@sveltejs/kit": "^1.5.3"
|
|
42
42
|
},
|
|
43
43
|
"peerDependencies": {
|
|
44
44
|
"@sveltejs/kit": "^1.5.0"
|