Skip to content

Commit 586d9be

Browse files
authored
Upgrade to Vite 2.9 (#4468)
* Upgrade to Vite 2.9 * fix pnpm check failure
1 parent 69913e9 commit 586d9be

File tree

6 files changed

+272
-50
lines changed

6 files changed

+272
-50
lines changed

.changeset/many-eyes-travel.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@sveltejs/kit': patch
3+
---
4+
5+
Upgrade to Vite 2.9

packages/adapter-cloudflare/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
"esbuild": "^0.14.21"
3333
},
3434
"devDependencies": {
35+
"@types/ws": "^8.5.3",
3536
"typescript": "^4.6.2"
3637
},
3738
"publishConfig": {

packages/kit/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"dependencies": {
1313
"@sveltejs/vite-plugin-svelte": "^1.0.0-next.32",
1414
"sade": "^1.7.4",
15-
"vite": "^2.8.0"
15+
"vite": "^2.9.0"
1616
},
1717
"devDependencies": {
1818
"@playwright/test": "^1.19.1",

packages/kit/src/core/dev/plugin.js

Lines changed: 11 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ export async function create_plugin(config, cwd) {
6262
const url = id.startsWith('..') ? `/@fs${path.posix.resolve(id)}` : `/${id}`;
6363

6464
const module = /** @type {import('types').SSRComponent} */ (
65-
await vite.ssrLoadModule(url)
65+
await vite.ssrLoadModule(url, { fixStacktrace: false })
6666
);
6767
const node = await vite.moduleGraph.getModuleByUrl(url);
6868

@@ -84,7 +84,7 @@ export async function create_plugin(config, cwd) {
8484
(query.has('svelte') && query.get('type') === 'style')
8585
) {
8686
try {
87-
const mod = await vite.ssrLoadModule(dep.url);
87+
const mod = await vite.ssrLoadModule(dep.url, { fixStacktrace: false });
8888
styles[dep.url] = mod.default;
8989
} catch {
9090
// this can happen with dynamically imported modules, I think
@@ -117,7 +117,7 @@ export async function create_plugin(config, cwd) {
117117
shadow: route.shadow
118118
? async () => {
119119
const url = path.resolve(cwd, /** @type {string} */ (route.shadow));
120-
return await vite.ssrLoadModule(url);
120+
return await vite.ssrLoadModule(url, { fixStacktrace: false });
121121
}
122122
: null,
123123
a: route.a.map((id) => manifest_data.components.indexOf(id)),
@@ -133,7 +133,7 @@ export async function create_plugin(config, cwd) {
133133
types,
134134
load: async () => {
135135
const url = path.resolve(cwd, route.file);
136-
return await vite.ssrLoadModule(url);
136+
return await vite.ssrLoadModule(url, { fixStacktrace: false });
137137
}
138138
};
139139
}),
@@ -144,7 +144,7 @@ export async function create_plugin(config, cwd) {
144144
for (const key in manifest_data.matchers) {
145145
const file = manifest_data.matchers[key];
146146
const url = path.resolve(cwd, file);
147-
const module = await vite.ssrLoadModule(url);
147+
const module = await vite.ssrLoadModule(url, { fixStacktrace: false });
148148

149149
if (module.match) {
150150
matchers[key] = module.match;
@@ -161,20 +161,7 @@ export async function create_plugin(config, cwd) {
161161

162162
/** @param {Error} error */
163163
function fix_stack_trace(error) {
164-
// TODO https://github.com/vitejs/vite/issues/7045
165-
166-
// ideally vite would expose ssrRewriteStacktrace, but
167-
// in lieu of that, we can implement it ourselves. we
168-
// don't want to mutate the error object, because
169-
// the stack trace could be 'fixed' multiple times,
170-
// and Vite will fix stack traces before we even
171-
// see them if they occur during ssrLoadModule
172-
const original = error.stack;
173-
vite.ssrFixStacktrace(error);
174-
const fixed = error.stack;
175-
error.stack = original;
176-
177-
return fixed;
164+
return error.stack ? vite.ssrRewriteStacktrace(error.stack) : error.stack;
178165
}
179166

180167
update_manifest();
@@ -220,7 +207,7 @@ export async function create_plugin(config, cwd) {
220207

221208
/** @type {Partial<import('types').Hooks>} */
222209
const user_hooks = resolve_entry(config.kit.files.hooks)
223-
? await vite.ssrLoadModule(`/${config.kit.files.hooks}`)
210+
? await vite.ssrLoadModule(`/${config.kit.files.hooks}`, { fixStacktrace: false })
224211
: {};
225212

226213
const handle = user_hooks.handle || (({ event, resolve }) => resolve(event));
@@ -260,13 +247,15 @@ export async function create_plugin(config, cwd) {
260247
// can get loaded twice via different URLs, which causes failures. Might
261248
// require changes to Vite to fix
262249
const { default: root } = await vite.ssrLoadModule(
263-
`/${posixify(path.relative(cwd, `${config.kit.outDir}/generated/root.svelte`))}`
250+
`/${posixify(path.relative(cwd, `${config.kit.outDir}/generated/root.svelte`))}`,
251+
{ fixStacktrace: false }
264252
);
265253

266254
const paths = await vite.ssrLoadModule(
267255
process.env.BUNDLED
268256
? `/${posixify(path.relative(cwd, `${config.kit.outDir}/runtime/paths.js`))}`
269-
: `/@fs${runtime}/paths.js`
257+
: `/@fs${runtime}/paths.js`,
258+
{ fixStacktrace: false }
270259
);
271260

272261
paths.set_paths({

0 commit comments

Comments
 (0)