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

minify: 'terser' gives [vite:terser] import.meta is only valid inside modules.error when building #19028

Closed
7 tasks done
Gotxiko opened this issue Dec 20, 2024 · 2 comments
Closed
7 tasks done

Comments

@Gotxiko
Copy link

Gotxiko commented Dec 20, 2024

Describe the bug

After updating to Vite 6.0.4 (still happening in 6.0.5) , trying to run a build gives the following error if minify: 'terser', is defined inside build in vite.config.ts. Removing or commenting this line performs the build process without issues.

vite v6.0.5 building for development...
✓ 3 modules transformed.
x Build failed in 65ms
error during build:
[vite:terser] import.meta is only valid inside modules.
    at <parse> (:6)
    at AsyncFunction (native)
    at new FakeWorker (/../node_modules/vite/dist/node/chunks/dep-BZMjGe_U.js:12732:20)
    at new WorkerWithFallback (/../node_modules/vite/dist/node/chunks/dep-BZMjGe_U.js:12773:28)
    at makeWorker (/../node_modules/vite/dist/node/chunks/dep-BZMjGe_U.js:12807:32)
    at <anonymous> (/../node_modules/vite/dist/node/chunks/dep-BZMjGe_U.js:12833:18)
    at renderChunk (/../node_modules/vite/dist/node/chunks/dep-BZMjGe_U.js:12825:23)
    at <anonymous> (/../node_modules/rollup/dist/es/shared/node-entry.js:20812:40)
    at processTicksAndRejections (native:7:39)
error: script "build" exited with code 1

Reproduction

bunx --bun vite build

Steps to reproduce

  • Update Vite to 6.0.4 or 6.0.5.
  • Try to run build command with minify: 'terser' in vite.config

System Info

System:
    OS: macOS 14.5
    CPU: (8) arm64 Apple M2
    Memory: 86.19 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Yarn: 1.22.21 - /usr/local/bin/yarn
    npm: 10.8.2 - ~/Library/Application Support/Herd/config/nvm/versions/node/v20.18.1/bin/npm
    pnpm: 8.12.1 - /usr/local/bin/pnpm
    bun: 1.1.40 - /usr/local/bin/bun
  Browsers:
    Chrome: 131.0.6778.205
    Chrome Canary: 133.0.6906.0
    Safari: 17.5
  npmPackages:
    @vitejs/plugin-legacy: ^6.0.0 => 6.0.0 
    vite: ^6.0.5 => 6.0.5

Used Package Manager

bun

Logs

No response

Validations

@hi-ogawa
Copy link
Collaborator

Can you provide a reproduction in Node? If it breaks only on Bun, please report an issue on Bun.
I haven't checked but the error looks similar to oven-sh/bun#15738

@hi-ogawa hi-ogawa closed this as not planned Won't fix, can't repro, duplicate, stale Dec 22, 2024
@Gotxiko
Copy link
Author

Gotxiko commented Dec 28, 2024

Using Node the issue doesn't happen, seems like it only happens under bun by forcing it as the engine to use and it looks like the same issue you linked. Guess this issue can stay closed :)

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

No branches or pull requests

2 participants