@sveltejs/adapter-netlify 1.0.0-next.55 → 1.0.0-next.58
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/README.md +17 -13
- package/files/edge.js +8 -14
- package/index.js +16 -13
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -16,19 +16,19 @@ You can then configure it inside of `svelte.config.js`:
|
|
|
16
16
|
import adapter from '@sveltejs/adapter-netlify';
|
|
17
17
|
|
|
18
18
|
export default {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
19
|
+
kit: {
|
|
20
|
+
// default options are shown
|
|
21
|
+
adapter: adapter({
|
|
22
|
+
// if true, will create a Netlify Edge Function rather
|
|
23
|
+
// than using standard Node-based functions
|
|
24
|
+
edge: false,
|
|
25
|
+
|
|
26
|
+
// if true, will split your app into multiple functions
|
|
27
|
+
// instead of creating a single one for the entire app.
|
|
28
|
+
// if `edge` is true, this option cannot be used
|
|
29
|
+
split: false
|
|
30
|
+
})
|
|
31
|
+
}
|
|
32
32
|
};
|
|
33
33
|
```
|
|
34
34
|
|
|
@@ -42,6 +42,10 @@ Then, make sure you have a [netlify.toml](https://docs.netlify.com/configure-bui
|
|
|
42
42
|
|
|
43
43
|
If the `netlify.toml` file or the `build.publish` value is missing, a default value of `"build"` will be used. Note that if you have set the publish directory in the Netlify UI to something else then you will need to set it in `netlify.toml` too, or use the default value of `"build"`.
|
|
44
44
|
|
|
45
|
+
### Node version
|
|
46
|
+
|
|
47
|
+
New projects will use Node 16 by default. However, if you're upgrading a project you created a while ago it may be stuck on an older version. See [the Netlify docs](https://docs.netlify.com/configure-builds/manage-dependencies/#node-js-and-javascript) for details on manually specifying Node 16 or newer.
|
|
48
|
+
|
|
45
49
|
## Netlify Edge Functions (beta)
|
|
46
50
|
|
|
47
51
|
SvelteKit supports the beta release of Netlify Edge Functions. If you pass the option `edge: true` to the `adapter` function, server-side rendering will happen in a Deno-based edge function that's deployed close to the site visitor. If set to `false` (the default), the site will deploy to standard Node-based Netlify Functions.
|
package/files/edge.js
CHANGED
|
@@ -9,24 +9,18 @@ const prefix = `/${manifest.appDir}/`;
|
|
|
9
9
|
* @param { any } context
|
|
10
10
|
* @returns { Promise<Response> }
|
|
11
11
|
*/
|
|
12
|
-
export default
|
|
12
|
+
export default function handler(request, context) {
|
|
13
13
|
if (is_static_file(request)) {
|
|
14
14
|
// Static files can skip the handler
|
|
15
15
|
return;
|
|
16
16
|
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
return response;
|
|
25
|
-
} catch (error) {
|
|
26
|
-
return new Response('Error rendering route:' + (error.message || error.toString()), {
|
|
27
|
-
status: 500
|
|
28
|
-
});
|
|
29
|
-
}
|
|
17
|
+
|
|
18
|
+
return server.respond(request, {
|
|
19
|
+
platform: { context },
|
|
20
|
+
getClientAddress() {
|
|
21
|
+
return request.headers.get('x-nf-client-connection-ip');
|
|
22
|
+
}
|
|
23
|
+
});
|
|
30
24
|
}
|
|
31
25
|
|
|
32
26
|
/**
|
package/index.js
CHANGED
|
@@ -54,6 +54,19 @@ export default function ({ split = false, edge = edge_set_in_env_var } = {}) {
|
|
|
54
54
|
|
|
55
55
|
builder.log.minor(`Publishing to "${publish}"`);
|
|
56
56
|
|
|
57
|
+
builder.log.minor('Copying assets...');
|
|
58
|
+
builder.writeStatic(publish);
|
|
59
|
+
builder.writeClient(publish);
|
|
60
|
+
builder.writePrerendered(publish);
|
|
61
|
+
|
|
62
|
+
builder.log.minor('Writing custom headers...');
|
|
63
|
+
const headers_file = join(publish, '_headers');
|
|
64
|
+
builder.copy('_headers', headers_file);
|
|
65
|
+
appendFileSync(
|
|
66
|
+
headers_file,
|
|
67
|
+
`\n\n/${builder.config.kit.appDir}/*\n cache-control: public\n cache-control: immutable\n cache-control: max-age=31536000\n`
|
|
68
|
+
);
|
|
69
|
+
|
|
57
70
|
// for esbuild, use ESM
|
|
58
71
|
// for zip-it-and-ship-it, use CJS until https://github.com/netlify/zip-it-and-ship-it/issues/750
|
|
59
72
|
const esm = netlify_config?.functions?.node_bundler === 'esbuild';
|
|
@@ -67,19 +80,6 @@ export default function ({ split = false, edge = edge_set_in_env_var } = {}) {
|
|
|
67
80
|
} else {
|
|
68
81
|
await generate_lambda_functions({ builder, esm, split, publish });
|
|
69
82
|
}
|
|
70
|
-
|
|
71
|
-
builder.log.minor('Copying assets...');
|
|
72
|
-
builder.writeStatic(publish);
|
|
73
|
-
builder.writeClient(publish);
|
|
74
|
-
builder.writePrerendered(publish);
|
|
75
|
-
|
|
76
|
-
builder.log.minor('Writing custom headers...');
|
|
77
|
-
const headers_file = join(publish, '_headers');
|
|
78
|
-
builder.copy('_headers', headers_file);
|
|
79
|
-
appendFileSync(
|
|
80
|
-
headers_file,
|
|
81
|
-
`\n\n/${builder.config.kit.appDir}/*\n cache-control: public\n cache-control: immutable\n cache-control: max-age=31536000\n`
|
|
82
|
-
);
|
|
83
83
|
}
|
|
84
84
|
};
|
|
85
85
|
}
|
|
@@ -230,6 +230,9 @@ function generate_lambda_functions({ builder, publish, split, esm }) {
|
|
|
230
230
|
redirects.push('* /.netlify/functions/render 200');
|
|
231
231
|
}
|
|
232
232
|
|
|
233
|
+
// this should happen at the end, after builder.writeStatic(...),
|
|
234
|
+
// so that generated redirects are appended to custom redirects
|
|
235
|
+
// rather than replaced by them
|
|
233
236
|
builder.log.minor('Writing redirects...');
|
|
234
237
|
const redirect_file = join(publish, '_redirects');
|
|
235
238
|
if (existsSync('_redirects')) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sveltejs/adapter-netlify",
|
|
3
|
-
"version": "1.0.0-next.
|
|
3
|
+
"version": "1.0.0-next.58",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/sveltejs/kit",
|
|
@@ -31,7 +31,8 @@
|
|
|
31
31
|
"@rollup/plugin-commonjs": "^21.0.0",
|
|
32
32
|
"@rollup/plugin-json": "^4.1.0",
|
|
33
33
|
"@rollup/plugin-node-resolve": "^13.0.5",
|
|
34
|
-
"@sveltejs/kit": "1.0.0-next.
|
|
34
|
+
"@sveltejs/kit": "1.0.0-next.331",
|
|
35
|
+
"@types/node": "^14.14.20",
|
|
35
36
|
"rimraf": "^3.0.2",
|
|
36
37
|
"rollup": "^2.58.0",
|
|
37
38
|
"typescript": "^4.6.2",
|