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

[fix] avoid manifest collisions #5874

Merged
merged 2 commits into from
Aug 15, 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
5 changes: 5 additions & 0 deletions .changeset/rare-deers-hunt.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@sveltejs/kit': patch
---

[fix] avoid manifest collisions
4 changes: 3 additions & 1 deletion packages/kit/src/vite/build/build_server.js
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,9 @@ export async function build_server(options, client) {
const { chunks } = await create_build(merged_config);

/** @type {import('vite').Manifest} */
const vite_manifest = JSON.parse(fs.readFileSync(`${output_dir}/server/manifest.json`, 'utf-8'));
const vite_manifest = JSON.parse(
fs.readFileSync(`${output_dir}/server/${vite_config.build.manifest}`, 'utf-8')
);

mkdirp(`${output_dir}/server/nodes`);
mkdirp(`${output_dir}/server/stylesheets`);
Expand Down
3 changes: 2 additions & 1 deletion packages/kit/src/vite/build/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@ export const get_default_config = function ({ config, input, ssr, outDir }) {
base: assets_base(config.kit),
build: {
cssCodeSplit: true,
manifest: true,
// don't use the default name to avoid collisions with 'static/manifest.json'
manifest: 'vite-manifest.json',
outDir,
polyfillModulePreload: false,
rollupOptions: {
Expand Down
6 changes: 5 additions & 1 deletion packages/kit/src/vite/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ function kit() {
function client_build_info(assets, chunks) {
/** @type {import('vite').Manifest} */
const vite_manifest = JSON.parse(
fs.readFileSync(`${paths.client_out_dir}/manifest.json`, 'utf-8')
fs.readFileSync(`${paths.client_out_dir}/${vite_config.build.manifest}`, 'utf-8')
);

const entry_id = posixify(
Expand Down Expand Up @@ -428,6 +428,10 @@ function kit() {
`See ${colors.bold().cyan('https://kit.svelte.dev/docs/adapters')} to learn how to configure your app to run on the platform of your choosing`
);
}

// avoid making the manifest available to users
fs.unlinkSync(`${paths.output_dir}/client/${vite_config.build.manifest}`);
fs.unlinkSync(`${paths.output_dir}/server/${vite_config.build.manifest}`);
},

/**
Expand Down