question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot build SvelteKit app with `@vitejs/plugin-legacy`

See original GitHub issue

Describe the bug

In case some Vite plugins are set in the config, command npm run build fails using latest SvelteKit version, whereas it was not failing using older versions.

Reproduction

npx degit https://github.com/nicomouss/sveltekit-build-fail.git sveltekit-build-fail
cd sveltekit-build-fail
npm install
npm run build

This successfully builds a basic SvelteKit skeleton app (with a Vite plugin added to its build config) based on a previous version of SvelteKit. You can check the libraries in use by running npm list --depth=0, this should displays the following (= the setup you would have gotten by creating a SvelteKit app a couple weeks ago, like I did back then):

├── @sveltejs/adapter-static@1.0.0-next.22
├── @sveltejs/kit@1.0.0-next.201
├── @vitejs/plugin-legacy@1.6.4
├── svelte@3.44.2

Now let’s upgrade our app to the latest version of SvelteKit (= the setup you would get by creating a SvelteKit app as for now):

npm i -D @sveltejs/kit@1.0.0-next.218
npm i -D svelte@3.45.0
npm i -D @sveltejs/adapter-static@1.0.0-next.24

Then run npm run build.

The build now fails with the following exception:

> Cannot read property 'filter' of undefined

Thus upgrading to latest SvelteKit version can break the build of an app.

In this case, there seems to be a side effect regarding Vite plugins. Because if you open svelte.config.js and change it from this:

vite: {
	plugins: [
           legacy({
		targets: ['defaults', 'not IE 11']
	   })
	]
}

to this:

vite: {
	plugins: []
}

Then the build works successfully again. Only you loose the plugin you have been successfully using till now…

Logs

No response

System Info

Latest published SvelteKit librairies

Severity

annoyance

Additional Information

No response

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:11 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
dimavolocommented, Feb 3, 2022

Same problem here. As @benmccann pointed out, the issue is await vite.build(config) returns an array, not a single object. SvelteKit is trying to destructure {output} from [ { output: [Array] }, { output: [Array] } ] }.

My goal is to support legacy Safari on iPhone 4s.

0reactions
benmccanncommented, Feb 8, 2022

As I said when this was closed, we already have an issue to track this. Please follow https://github.com/sveltejs/kit/issues/12

Read more comments on GitHub >

github_iconTop Results From Across the Web

0 - Stack Overflow
I'm trying to deploy a sveltekit app to vercel with adapter-vercel . It's just a basic SPA app. ... These are my settings...
Read more >
Introduction • Docs • SvelteKit
SvelteKit is a framework for rapid development of robust, performant web applications. Building an app with all the modern best practices is fiendishly ......
Read more >
Creating your first Svelte App with SvelteKit - Fjolt
Svelte is a frontend tool for creating web applications. In this tutorial we'll be looking at how to make your first Svelte application....
Read more >
@sveltejs/adapter-static - npm
Adapter for SvelteKit apps that prerenders your entire site as a ... If svelte-kit build fails because of pages that can't be loaded...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found