Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[breaking] remove writeStatic to align with Vite #5618

Merged
merged 2 commits into from
Jul 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .changeset/smooth-cars-reflect.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
'@sveltejs/adapter-cloudflare': patch
'@sveltejs/adapter-cloudflare-workers': patch
'@sveltejs/adapter-netlify': patch
'@sveltejs/adapter-node': patch
'@sveltejs/adapter-static': patch
'@sveltejs/adapter-vercel': patch
'@sveltejs/kit': patch
---

[breaking] remove writeStatic to align with Vite
1 change: 0 additions & 1 deletion packages/adapter-cloudflare-workers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ export default function () {

builder.log.minor('Copying assets...');
builder.writeClient(site.bucket);
builder.writeStatic(site.bucket);
builder.writePrerendered(site.bucket);
}
};
Expand Down
1 change: 0 additions & 1 deletion packages/adapter-cloudflare/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ export default function () {
builder.rimraf(tmp);
builder.mkdirp(tmp);

builder.writeStatic(dest);
builder.writeClient(dest);
builder.writePrerendered(dest);

Expand Down
3 changes: 1 addition & 2 deletions packages/adapter-netlify/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ export default function ({ split = false, edge = edge_set_in_env_var } = {}) {
builder.log.minor(`Publishing to "${publish}"`);

builder.log.minor('Copying assets...');
builder.writeStatic(publish);
builder.writeClient(publish);
builder.writePrerendered(publish);

Expand Down Expand Up @@ -232,7 +231,7 @@ async function generate_lambda_functions({ builder, publish, split, esm }) {
redirects.push('* /.netlify/functions/render 200');
}

// this should happen at the end, after builder.writeStatic(...),
// this should happen at the end, after builder.writeClient(...),
// so that generated redirects are appended to custom redirects
// rather than replaced by them
builder.log.minor('Writing redirects...');
Expand Down
1 change: 0 additions & 1 deletion packages/adapter-node/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ export default function (opts = {}) {
builder.log.minor('Copying assets');
builder.writeClient(`${out}/client`);
builder.writeServer(`${out}/server`);
builder.writeStatic(`${out}/static`);
builder.writePrerendered(`${out}/prerendered`);

writeFileSync(
Expand Down
1 change: 0 additions & 1 deletion packages/adapter-static/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ export default function (options) {
builder.rimraf(assets);
builder.rimraf(pages);

builder.writeStatic(assets);
builder.writeClient(assets);
builder.writePrerendered(pages, { fallback });

Expand Down
1 change: 0 additions & 1 deletion packages/adapter-vercel/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,6 @@ export default function ({ external = [], edge, split } = {}) {

builder.log.minor('Copying assets...');

builder.writeStatic(dirs.static);
builder.writeClient(dirs.static);
builder.writePrerendered(dirs.static);

Expand Down
16 changes: 12 additions & 4 deletions packages/kit/src/core/adapt/builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,10 @@ export function create_builder({ config, build_data, prerendered, log }) {
},

writeClient(dest) {
return copy(`${config.kit.outDir}/output/client`, dest);
return [
...copy(`${config.kit.outDir}/output/client`, dest),
...copy(config.kit.files.assets, dest)
];
},

writePrerendered(dest, { fallback } = {}) {
Expand All @@ -141,11 +144,16 @@ export function create_builder({ config, build_data, prerendered, log }) {
return copy(`${config.kit.outDir}/output/server`, dest);
},

writeStatic(dest) {
return copy(config.kit.files.assets, dest);
// TODO remove these methods for 1.0
// @ts-expect-error
writeStatic() {
throw new Error(
`writeStatic has been removed. Please ensure you are using the latest version of ${
config.kit.adapter.name || 'your adapter'
}`
);
},

// @ts-expect-error
async prerender() {
throw new Error(
'builder.prerender() has been removed. Prerendering now takes place in the build phase — see builder.prerender and builder.writePrerendered'
Expand Down
19 changes: 7 additions & 12 deletions packages/kit/src/core/adapt/builder.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,22 +39,17 @@ test('copy files', () => {

const dest = join(__dirname, 'output');

rmSync(dest, { recursive: true, force: true });
builder.writeStatic(dest);

assert.equal(
glob('**', {
cwd: /** @type {import('types').ValidatedConfig} */ (mocked).kit.files.assets,
dot: true
}),
glob('**', { cwd: dest, dot: true })
);

rmSync(dest, { recursive: true, force: true });
builder.writeClient(dest);

assert.equal(
glob('**', { cwd: `${outDir}/output/client`, dot: true }),
[
...glob('**', {
cwd: /** @type {import('types').ValidatedConfig} */ (mocked).kit.files.assets,
dot: true
}),
...glob('**', { cwd: `${outDir}/output/client`, dot: true })
],
glob('**', { cwd: dest, dot: true })
);

Expand Down
5 changes: 0 additions & 5 deletions packages/kit/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,6 @@ export interface Builder {
* @returns an array of paths corresponding to the files that have been created by the copy
*/
writeServer(dest: string): string[];
/**
* @param dest the destination folder to which files should be copied
* @returns an array of paths corresponding to the files that have been created by the copy
*/
writeStatic(dest: string): string[];
/**
* @param from the source file or folder
* @param to the destination file or folder
Expand Down