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

Project builds but fails on deploy #9141

Closed
charbelnicolas opened this issue Feb 20, 2023 · 16 comments · Fixed by #9179
Closed

Project builds but fails on deploy #9141

charbelnicolas opened this issue Feb 20, 2023 · 16 comments · Fixed by #9179
Labels
bug Something isn't working

Comments

@charbelnicolas
Copy link

Describe the bug

Today I updated my project with an NPM Update and it no longer works correctly. This is what my package.json look like:

20230220_151727

The project builds succesfully:
20230220_151653

And this is what happens when it gets deployed:

20230220_151833

Click here to see the issue for yourself

Reproduction

I could not reproduce this issue with a clean svelte-kit install. It is mostly a bug based on my project I guess... but this only happened after doing an NPM update today.

Logs

No response

System Info

System:
    OS: Linux 6.1 Arch Linux
    CPU: (8) x64 Intel(R) Core(TM) i7-6700K CPU @ 4.00GHz
    Memory: 29.83 GB / 31.30 GB
    Container: Yes
    Shell: 5.1.16 - /bin/bash
  Binaries:
    Node: 19.6.1 - /usr/bin/node
    Yarn: 1.22.19 - /usr/bin/yarn
    npm: 8.19.2 - /usr/bin/npm
  Browsers:
    Chromium: 110.0.5481.100

Severity

blocking all usage of SvelteKit

Additional Information

No response

@Conduitry
Copy link
Member

Hm. @Rich-Harris @dummdidumm Do we need to rethink using .mjs files if they're unlikely to get the appropriate Content-Type headers served in various static servers? Or at least document the configuration changes that are needed? It looks like this particular site is using nginx.

@charbelnicolas
Copy link
Author

Hm. @Rich-Harris @dummdidumm Do we need to rethink using .mjs files if they're unlikely to get the appropriate Content-Type headers served in various static servers? Or at least document the configuration changes that are needed? It looks like this particular site is using nginx.

Yep, I'm using Nginx :)

@Conduitry
Copy link
Member

In the meantime, you should be able to configure nginx to return the appropriate Content-Type: application/javascript header for .mjs files.

@charbelnicolas
Copy link
Author

In the meantime, you should be able to configure nginx to return the appropriate Content-Type: application/javascript header for .mjs files.

Thank you, I'll see what I can do.

@charbelnicolas
Copy link
Author

I changed the mime.types file on the server and it works now, thank you!

I still get this message though:

20230220_160301

Any idea of why that is?

@dummdidumm
Copy link
Member

Any chance you're using Firefox? The preload optimazation doesn't work there and you instead get a warning like this

@Rich-Harris
Copy link
Member

The screenshot looks like Chrome. I'm actually seeing the same thing on kit.svelte.dev, bizarrely:

image

There's definitely a bug here. Perhaps those modules really aren't being imported, though I don't understand why they'd be in the preload list otherwise

@charbelnicolas
Copy link
Author

charbelnicolas commented Feb 20, 2023

Any chance you're using Firefox? The preload optimazation doesn't work there and you instead get a warning like this

I'm using the latest chrome version

@tony19
Copy link
Contributor

tony19 commented Feb 20, 2023

I'm also seeing this problem but with text/plain:

start.93eb02de.mjs:1 Failed to load module script: Expected a JavaScript module script but the server responded with a MIME type of "text/plain". Strict MIME type checking is enforced for module scripts per HTML spec.
app.1f02cb34.mjs:1 Failed to load module script: Expected a JavaScript module script but the server responded with a MIME type of "text/plain". Strict MIME type checking is enforced for module scripts per HTML spec.

  • Chrome Version 109.0.5414.119
  • macOS Ventura
  • nginx

I tried the fix from #9142 in v1.8.3, but that seemed to have no effect. I had to revert to SvelteKit v1.5.0 for now.

@Conduitry
Copy link
Member

#9142 is unrelated to this issue.

@Rich-Harris
Copy link
Member

@tony19 is that an error you can reproduce or is it something in your logs? if the latter, it's probably because someone tried to load that file after a redeploy happened while they were on the site. it's generally harmless as the client will detect a new version and automatically reload

@tony19
Copy link
Contributor

tony19 commented Feb 20, 2023

@Rich-Harris It's the former... reproducible just by visiting the site. In my case, the site completely fails to load because of that error. I just get a blank screen. I'll try to create an isolated reproduction if needed.

@Rich-Harris
Copy link
Member

@tony19 yes please — it sounds like a separate issue though, so please open a new ticket

@Rich-Harris Rich-Harris added the bug Something isn't working label Feb 21, 2023
@rob-balfre
Copy link

rob-balfre commented Feb 22, 2023

This has broken our SPA builds too... we have the worst CDN on Azure and it doesn't let us serve .mjs files.

This a deliberate change to force us over to Vercel 😂 ??

@wickning1
Copy link

I also found that the precompress option fails after the switch to mjs, likely because of this glob

const files = await glob('**/*.{html,js,json,css,svg,xml,wasm}', {

@polyzen
Copy link

polyzen commented Feb 23, 2023

Relevant: https://pagure.io/mailcap/pull-request/10
Mailcap strictly obeys https://www.iana.org/assignments/media-types/media-types.xhtml . I can not merge this until mjs is recognized by IANA as valid file extension.

On Arch Linux (and other distros perhaps), nginx pulls in mailcap for mime.types use by default.

Rich-Harris added a commit that referenced this issue Feb 25, 2023
* fix: revert mjs extension usage by default, make it an option

fixes #9141

* fix tests

* reword

* include .mjs files in precompression

* convert to preloadStrategy option

* default

* DRY

* Update packages/kit/types/index.d.ts

* fix

* use modulepreload on basic test

* fix

* another test

---------

Co-authored-by: Rich Harris <hello@rich-harris.dev>
Co-authored-by: Rich Harris <richard.a.harris@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants