@sveltejs/adapter-netlify 1.0.0-next.48 → 1.0.0-next.50
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 +3 -1
- package/files/cjs/handler.js +2 -2
- package/files/esm/handler.js +2 -2
- package/index.js +3 -7
- package/package.json +4 -2
package/README.md
CHANGED
|
@@ -57,7 +57,9 @@ During compilation, redirect rules are automatically appended to your `_redirect
|
|
|
57
57
|
|
|
58
58
|
### Using Netlify Functions
|
|
59
59
|
|
|
60
|
-
[Netlify Functions](https://docs.netlify.com/functions/overview/)
|
|
60
|
+
With this adapter, SvelteKit endpoints are hosted as [Netlify Functions](https://docs.netlify.com/functions/overview/). Netlify function handlers have additional context, including [Netlify Identity](https://docs.netlify.com/visitor-access/identity/) information. You can access this context via the `event.platform.context` field inside your hooks and endpoints.
|
|
61
|
+
|
|
62
|
+
Additionally, you can add your own Netlify functions by creating a directory for them and adding the configuration to your `netlify.toml` file. For example:
|
|
61
63
|
|
|
62
64
|
```toml
|
|
63
65
|
[build]
|
package/files/cjs/handler.js
CHANGED
|
@@ -49,8 +49,8 @@ function split_headers(headers) {
|
|
|
49
49
|
function init(manifest) {
|
|
50
50
|
const server = new _0SERVER.Server(manifest);
|
|
51
51
|
|
|
52
|
-
return async (event) => {
|
|
53
|
-
const rendered = await server.respond(to_request(event));
|
|
52
|
+
return async (event, context) => {
|
|
53
|
+
const rendered = await server.respond(to_request(event), { platform: { context } });
|
|
54
54
|
|
|
55
55
|
const partial_response = {
|
|
56
56
|
statusCode: rendered.status,
|
package/files/esm/handler.js
CHANGED
|
@@ -45,8 +45,8 @@ function split_headers(headers) {
|
|
|
45
45
|
function init(manifest) {
|
|
46
46
|
const server = new Server(manifest);
|
|
47
47
|
|
|
48
|
-
return async (event) => {
|
|
49
|
-
const rendered = await server.respond(to_request(event));
|
|
48
|
+
return async (event, context) => {
|
|
49
|
+
const rendered = await server.respond(to_request(event), { platform: { context } });
|
|
50
50
|
|
|
51
51
|
const partial_response = {
|
|
52
52
|
statusCode: rendered.status,
|
package/index.js
CHANGED
|
@@ -12,7 +12,7 @@ import toml from '@iarna/toml';
|
|
|
12
12
|
* } & toml.JsonMap} NetlifyConfig
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
|
-
const files = fileURLToPath(new URL('./files', import.meta.url));
|
|
15
|
+
const files = fileURLToPath(new URL('./files', import.meta.url).href);
|
|
16
16
|
|
|
17
17
|
/** @type {import('.')} */
|
|
18
18
|
export default function ({ split = false } = {}) {
|
|
@@ -36,11 +36,6 @@ export default function ({ split = false } = {}) {
|
|
|
36
36
|
|
|
37
37
|
builder.log.minor(`Publishing to "${publish}"`);
|
|
38
38
|
|
|
39
|
-
builder.log.minor('Prerendering static pages...');
|
|
40
|
-
await builder.prerender({
|
|
41
|
-
dest: publish
|
|
42
|
-
});
|
|
43
|
-
|
|
44
39
|
builder.writeServer('.netlify/server');
|
|
45
40
|
|
|
46
41
|
// for esbuild, use ESM
|
|
@@ -127,6 +122,7 @@ export default function ({ split = false } = {}) {
|
|
|
127
122
|
builder.log.minor('Copying assets...');
|
|
128
123
|
builder.writeStatic(publish);
|
|
129
124
|
builder.writeClient(publish);
|
|
125
|
+
builder.writePrerendered(publish);
|
|
130
126
|
|
|
131
127
|
builder.log.minor('Writing redirects...');
|
|
132
128
|
const redirect_file = join(publish, '_redirects');
|
|
@@ -138,7 +134,7 @@ export default function ({ split = false } = {}) {
|
|
|
138
134
|
builder.copy('_headers', headers_file);
|
|
139
135
|
appendFileSync(
|
|
140
136
|
headers_file,
|
|
141
|
-
`\n\n/${builder.appDir}/*\n cache-control: public\n cache-control: immutable\n cache-control: max-age=31536000\n`
|
|
137
|
+
`\n\n/${builder.config.kit.appDir}/*\n cache-control: public\n cache-control: immutable\n cache-control: max-age=31536000\n`
|
|
142
138
|
);
|
|
143
139
|
}
|
|
144
140
|
};
|
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.50",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/sveltejs/kit",
|
|
@@ -31,15 +31,17 @@
|
|
|
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.293",
|
|
35
35
|
"rimraf": "^3.0.2",
|
|
36
36
|
"rollup": "^2.58.0",
|
|
37
|
+
"typescript": "^4.6.2",
|
|
37
38
|
"uvu": "^0.5.2"
|
|
38
39
|
},
|
|
39
40
|
"scripts": {
|
|
40
41
|
"dev": "rimraf files && rollup -cw",
|
|
41
42
|
"build": "rimraf files && rollup -c",
|
|
42
43
|
"test": "uvu src \"(spec\\.js|test[\\\\/]index\\.js)\"",
|
|
44
|
+
"check": "tsc",
|
|
43
45
|
"lint": "eslint --ignore-path .gitignore \"**/*.{ts,js,svelte}\" && npm run check-format",
|
|
44
46
|
"format": "npm run check-format -- --write",
|
|
45
47
|
"check-format": "prettier --check . --config ../../.prettierrc --ignore-path .gitignore"
|