@sveltejs/adapter-netlify 4.3.6 → 4.4.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/edge.js CHANGED
@@ -1,8 +1,7 @@
1
1
  import { Server } from '0SERVER';
2
- import { manifest, prerendered } from 'MANIFEST';
2
+ import { manifest } from 'MANIFEST';
3
3
 
4
4
  const server = new Server(manifest);
5
- const prefix = `/${manifest.appPath}/`;
6
5
 
7
6
  const initialized = server.init({
8
7
  // @ts-ignore
@@ -15,12 +14,6 @@ const initialized = server.init({
15
14
  * @returns { Promise<Response> }
16
15
  */
17
16
  export default async function handler(request, context) {
18
- if (is_static_file(request)) {
19
- // Static files can skip the handler
20
- // TODO can we serve _app/immutable files with an immutable cache header?
21
- return;
22
- }
23
-
24
17
  await initialized;
25
18
  return server.respond(request, {
26
19
  platform: { context },
@@ -29,33 +22,3 @@ export default async function handler(request, context) {
29
22
  }
30
23
  });
31
24
  }
32
-
33
- /**
34
- * @param {Request} request
35
- */
36
- function is_static_file(request) {
37
- const url = new URL(request.url);
38
-
39
- // Assets in the app dir
40
- if (url.pathname.startsWith(prefix)) {
41
- return true;
42
- }
43
-
44
- // prerendered pages and index.html files
45
- const pathname = url.pathname.replace(/\/$/, '');
46
- let file = pathname.substring(1);
47
-
48
- try {
49
- file = decodeURIComponent(file);
50
- } catch {
51
- // ignore
52
- }
53
-
54
- return (
55
- manifest.assets.has(file) ||
56
- manifest.assets.has(file + '/index.html') ||
57
- file in manifest._.server_assets ||
58
- file + '/index.html' in manifest._.server_assets ||
59
- prerendered.has(pathname || '/')
60
- );
61
- }
package/index.d.ts CHANGED
@@ -1,4 +1,3 @@
1
1
  import { Adapter } from '@sveltejs/kit';
2
- import './ambient.js';
3
2
 
4
3
  export default function plugin(opts?: { split?: boolean; edge?: boolean }): Adapter;
package/index.js CHANGED
@@ -14,15 +14,19 @@ import toml from '@iarna/toml';
14
14
  */
15
15
 
16
16
  /**
17
+ * TODO(serhalp) Replace this custom type with an import from `@netlify/edge-functions`,
18
+ * once that type is fixed to include `excludedPath` and `function`.
17
19
  * @typedef {{
18
20
  * functions: Array<
19
21
  * | {
20
22
  * function: string;
21
23
  * path: string;
24
+ * excludedPath?: string | string[];
22
25
  * }
23
26
  * | {
24
27
  * function: string;
25
28
  * pattern: string;
29
+ * excludedPattern?: string | string[];
26
30
  * }
27
31
  * >;
28
32
  * version: 1;
@@ -122,23 +126,6 @@ async function generate_edge_functions({ builder }) {
122
126
 
123
127
  builder.mkdirp('.netlify/edge-functions');
124
128
 
125
- // Don't match the static directory
126
- const pattern = '^/.*$';
127
-
128
- // Go doesn't support lookarounds, so we can't do this
129
- // const pattern = appDir ? `^/(?!${escapeStringRegexp(appDir)}).*$` : '^/.*$';
130
-
131
- /** @type {HandlerManifest} */
132
- const edge_manifest = {
133
- functions: [
134
- {
135
- function: 'render',
136
- pattern
137
- }
138
- ],
139
- version: 1
140
- };
141
-
142
129
  builder.log.minor('Generating Edge Function...');
143
130
  const relativePath = posix.relative(tmp, builder.getServerDirectory());
144
131
 
@@ -153,12 +140,43 @@ async function generate_edge_functions({ builder }) {
153
140
  relativePath
154
141
  });
155
142
 
156
- writeFileSync(
157
- `${tmp}/manifest.js`,
158
- `export const manifest = ${manifest};\n\nexport const prerendered = new Set(${JSON.stringify(
159
- builder.prerendered.paths
160
- )});\n`
161
- );
143
+ writeFileSync(`${tmp}/manifest.js`, `export const manifest = ${manifest};\n`);
144
+
145
+ /** @type {{ assets: Set<string> }} */
146
+ const { assets } = (await import(`${tmp}/manifest.js`)).manifest;
147
+
148
+ const path = '/*';
149
+ // We only need to specify paths without the trailing slash because
150
+ // Netlify will handle the optional trailing slash for us
151
+ const excludedPath = [
152
+ // Contains static files
153
+ `/${builder.getAppPath()}/*`,
154
+ ...builder.prerendered.paths,
155
+ ...Array.from(assets).flatMap((asset) => {
156
+ if (asset.endsWith('/index.html')) {
157
+ const dir = asset.replace(/\/index\.html$/, '');
158
+ return [
159
+ `${builder.config.kit.paths.base}/${asset}`,
160
+ `${builder.config.kit.paths.base}/${dir}`
161
+ ];
162
+ }
163
+ return `${builder.config.kit.paths.base}/${asset}`;
164
+ }),
165
+ // Should not be served by SvelteKit at all
166
+ '/.netlify/*'
167
+ ];
168
+
169
+ /** @type {HandlerManifest} */
170
+ const edge_manifest = {
171
+ functions: [
172
+ {
173
+ function: 'render',
174
+ path,
175
+ excludedPath
176
+ }
177
+ ],
178
+ version: 1
179
+ };
162
180
 
163
181
  await esbuild.build({
164
182
  entryPoints: [`${tmp}/entry.js`],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sveltejs/adapter-netlify",
3
- "version": "4.3.6",
3
+ "version": "4.4.1",
4
4
  "description": "A SvelteKit adapter that creates a Netlify app",
5
5
  "keywords": [
6
6
  "adapter",
@@ -33,21 +33,21 @@
33
33
  ],
34
34
  "dependencies": {
35
35
  "@iarna/toml": "^2.2.5",
36
- "esbuild": "^0.21.5",
36
+ "esbuild": "^0.24.0",
37
37
  "set-cookie-parser": "^2.6.0"
38
38
  },
39
39
  "devDependencies": {
40
- "@netlify/functions": "^2.4.1",
40
+ "@netlify/functions": "^3.0.0",
41
41
  "@rollup/plugin-commonjs": "^28.0.1",
42
42
  "@rollup/plugin-json": "^6.1.0",
43
- "@rollup/plugin-node-resolve": "^15.3.0",
44
- "@sveltejs/vite-plugin-svelte": "^3.0.1",
43
+ "@rollup/plugin-node-resolve": "^16.0.0",
44
+ "@sveltejs/vite-plugin-svelte": "^5.0.1",
45
45
  "@types/node": "^18.19.48",
46
46
  "@types/set-cookie-parser": "^2.4.7",
47
47
  "rollup": "^4.14.2",
48
48
  "typescript": "^5.3.3",
49
- "vitest": "^2.0.1",
50
- "@sveltejs/kit": "^2.7.3"
49
+ "vitest": "^3.0.1",
50
+ "@sveltejs/kit": "^2.16.1"
51
51
  },
52
52
  "peerDependencies": {
53
53
  "@sveltejs/kit": "^2.4.0"