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

Improper import in route does not throw but builds nothing #5413

Closed
iverks opened this issue Jul 8, 2022 · 6 comments
Closed

Improper import in route does not throw but builds nothing #5413

iverks opened this issue Jul 8, 2022 · 6 comments
Labels
bug Something isn't working error handling

Comments

@iverks
Copy link

iverks commented Jul 8, 2022

Describe the bug

When a page (a .svelte-file in the src/routes directory) has a broken import:
I run npm run build.
No errors are thrown, no warnings are given and the site doesnt build.

Expected behaviour would be one of:

  • Build fails with error
  • Build succeeds with warning
  • Build succeeds without warning, but throws in runtime

Reproduction

https://github.com/iverks/sveltekit_import_bug

npm install
npm run build - nothing gets built, but no errors

Then you can comment out the import in index.svelte, and it builds just fine

Logs

PS C:\Users\ivism\Progging\bug> npm run build
npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead.

> [email protected] build
> vite build

vite v2.9.13 building for production...
✓ 13 modules transformed.

System Info

Testen on Windows 10 and windows 11.

From win10:
  System:
    OS: Windows 10 10.0.19042
    CPU: (8) x64 11th Gen Intel(R) Core(TM) i7-1165G7 @ 2.80GHz
    Memory: 4.37 GB / 15.71 GB
  Binaries:
    Node: 16.16.0 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.19 - ~\AppData\Roaming\npm\yarn.CMD
    npm: 8.5.1 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Edge: Spartan (44.19041.423.0), Chromium (103.0.1264.44)
    Internet Explorer: 11.0.19041.1

Severity

serious, but I can work around it

Additional Information

About severity: I guess it could be considered "annoying", but its terrible DX and was almost impossible to debug.
Tested with adapter-node and adapter-static.
This is using the latest package.json, vite.config.js, svelte.config.js setup supplied by npm create svelte app-name

@ZerdoX-x
Copy link

ZerdoX-x commented Jul 10, 2022

Spend about two hours on this issue, but found way that can help someone debug this faster: just run npm run dev (vite dev), interact with your application a little so it would throw an error. After that you could see which import is broken.

In my case it was postcss.config.js which was refactored from require to import from as for postcss/postcss-load-config#230 but apparently postcss-load-config doesn't respect type: "module", so I had to rename postcss.config.js to postcss.config.mjs.

Hopefully this would be resolved as much as possible.

For sveltekit dev team and volunteers: I was upgrading from 357 to 367 and this bug was likely introduced in #5332
Even tho I'd even say I didn't have this bug before having vite.config.js was a must (but I was using this feature as experimental)

upd: this is literally the hell if your CI/CD fails because of this but local builds are passing and everything builds fine.

@kuechlerm
Copy link

@ZerdoX-x In my situation that was not helpful because the import error was in some long forgotton playground file.

I think the most helpful way to find errors in your code is to

call svelte-check

and then fix all errors.

I would not call this bug "annoying". I was not able to deploy my app for some hours. Yes, we can roll back to an older version. But there were so many changes, that it was a bit hard to pin down the culprit. I would suggest fixing this quickly or at least leave a hint somewhere to use svelte-check with build.

@ZerdoX-x
Copy link

@kuechlerm Yep.
In your case dev mode is not helpful.
In my case svelte-check is not helpful (as it doesn't check how project builds. my issue was with postcss config)

So I guess the most reliable way to check why build fails is to downgrade @sveltejs/kit package. It might not work if cause of your build failing is updating @sveltejs/kit itself. In this case you must read update notes for each version you get over (actually you need to do this when upgrading even if your build works fine).

@benmccann
Copy link
Member

Fixed. Thanks for tracking this down @gtm-nayan

@isaac-mcfadyen
Copy link
Contributor

isaac-mcfadyen commented Jul 17, 2022

Just a heads-up that I caught this issue a while back and was directed to file on Vite's tracker: #5382

I assume that this was a SvelteKit specific issue and not a Vite issue? In which case I don't need to make a Vite Issue?

@bluwy
Copy link
Member

bluwy commented Jul 17, 2022

Yeah this was a SvelteKit specific issue. No need to open an issue in Vite.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working error handling
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants