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

[BUG] JSON imports fail at runtime with bundler #3347

Open
4 tasks done
cloudhead opened this issue May 21, 2021 · 2 comments
Open
4 tasks done

[BUG] JSON imports fail at runtime with bundler #3347

cloudhead opened this issue May 21, 2021 · 2 comments

Comments

@cloudhead
Copy link

cloudhead commented May 21, 2021

Bug Report Quick Checklist

  • I am on the latest version of Snowpack & all plugins.
  • I use package manager npm (Fill in: npm, yarn, pnpm, etc).
  • I run Snowpack on OS Linux (Fill in: Windows, Mac, Linux, etc).
  • I run Snowpack on Node.js v12+

Describe the bug

  • I have an import config from "./config.json" in one of my typescript files.
  • This builds fine, with no errors, however when the app is opened in the browser, I get an error in the console: Failed to load module script: The server responded with a non-JavaScript MIME type of "application/json". Strict MIME type checking is enforced for module scripts per HTML spec.

To Reproduce

  1. npx create-snowpack-app dir --template @snowpack/app-template-svelte-typescript
  2. Create a .json file in src/ and import it from index.ts.
  3. Set bundle: true in snowpack's optimize config
  4. npm run build
  5. Go in the build/ folder and start a webserver
  6. Open the app in your browser
  7. See error in the console!

Expected behavior

There should be no error. The .json file should import without problem, just like with bundle: false.

Anything else?

Looks like the issue is caused by bundle: true.

@awu43
Copy link
Contributor

awu43 commented May 25, 2021

Looks like the same as #3109, try the workaround here.

@amatiash
Copy link

I have the same issue. Fails to load logo.svg. When bundle: true

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants