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

Forcing Bun execution (--bun) of Vite 6 dev with Sass plugin crashes with import.meta is only valid inside modules #16008

Closed
jakeboone02 opened this issue Dec 27, 2024 · 2 comments
Labels
bug Something isn't working needs triage

Comments

@jakeboone02
Copy link
Contributor

jakeboone02 commented Dec 27, 2024

What version of Bun is running?

1.1.42+50eec0025

What platform is your computer?

Linux 5.15.167.4-microsoft-standard-WSL2 x86_64 x86_64

What steps can reproduce the bug?

Create a new vanilla JS Vite project, install dependencies, then install sass:

bun create vite bunx-bun-vite-scss-test
# ✔ Select a framework: › Vanilla
# ✔ Select a variant: › JavaScript
cd bunx-bun-vite-scss-test
bun install
bun add -d sass

Create a src/styles.scss file with any valid contents (I used h1 { color: rebeccapurple; }).

Add the following line inside the <head> tag in index.html:

<link rel="stylesheet" href="./src/styles.scss">

Force Bun to run Vite's dev server:

bun --bun vite

What is the expected behavior?

No error.

What do you see instead?

$ bunx --bun vite

  VITE v6.0.6  ready in 163 ms

  ➜  Local:   http://localhost:5173/
  ➜  Network: use --host to expose
  ➜  press h + enter to show help
5:08:26 PM [vite] Internal server error: import.meta is only valid inside modules.
  Plugin: vite:css
  File: ~/git/bunx-bun-vite-scss-test/styles.scss?direct:12732:20
      at <parse> (:7)
      at AsyncFunction (native)
      at new FakeWorker (~/git/bunx-bun-vite-scss-test/node_modules/vite/dist/node/chunks/dep-0AosnpPU.js:12732:20)
      at new WorkerWithFallback (~/git/bunx-bun-vite-scss-test/node_modules/vite/dist/node/chunks/dep-0AosnpPU.js:12773:28)
      at makeModernScssWorker (~/git/bunx-bun-vite-scss-test/node_modules/vite/dist/node/chunks/dep-0AosnpPU.js:49156:22)
      at <anonymous> (~/git/bunx-bun-vite-scss-test/node_modules/vite/dist/node/chunks/dep-0AosnpPU.js:49302:49)
      at process (~/git/bunx-bun-vite-scss-test/node_modules/vite/dist/node/chunks/dep-0AosnpPU.js:49293:19)
      at <anonymous> (~/git/bunx-bun-vite-scss-test/node_modules/vite/dist/node/chunks/dep-0AosnpPU.js:48417:34)
      at compileCSSPreprocessors (~/git/bunx-bun-vite-scss-test/node_modules/vite/dist/node/chunks/dep-0AosnpPU.js:48403:40)
      at <anonymous> (~/git/bunx-bun-vite-scss-test/node_modules/vite/dist/node/chunks/dep-0AosnpPU.js:48475:38)
      at processTicksAndRejections (native:7:39)

Additional information

Vite 5 does not exhibit this problem, and running bun vite doesn't either, so I'm pretty sure it's not a Vite or Sass bug but a Node compatibility issue with Bun.

@jakeboone02 jakeboone02 added bug Something isn't working needs triage labels Dec 27, 2024
@kaij
Copy link

kaij commented Dec 27, 2024

Same as #15738

@jakeboone02
Copy link
Contributor Author

You're right, definitely a dupe. Sorry about that!

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

No branches or pull requests

3 participants