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

Vite dev server is unable to import @babel/standalone #16435

Open
7 tasks done
Mad-Kat opened this issue Apr 16, 2024 · 1 comment · May be fixed by #16437
Open
7 tasks done

Vite dev server is unable to import @babel/standalone #16435

Mad-Kat opened this issue Apr 16, 2024 · 1 comment · May be fixed by #16437
Labels
feat: deps optimizer Esbuild Dependencies Optimization has workaround inconsistency Inconsistency between dev & build p2-edge-case Bug, but has workaround or limited in scope (priority)

Comments

@Mad-Kat
Copy link

Mad-Kat commented Apr 16, 2024

Describe the bug

I want to run @babel/standalone in the browser. When I tried it in dev mode, the error is always Uncaught TypeError: babel is undefined. When I build it @babel/standalone is correctly bundled into the application and everything works great.

My assumption would be that this should also work in dev mode.

Note: This happens with the latest vite@5.2.9 and latest @babel/standalone@7.24.4

Reproduction

https://github.com/Mad-Kat/vite-dev-babel-reproduction/tree/main

Steps to reproduce

  1. Clone this repository
  2. Run npm install
  3. Run npm run dev
  4. Open the browser console and you will see the following error:
Uncaught TypeError: babel is undefined
    setCounter counter.js:6
    setupCounter counter.js:11

System Info

System:
    OS: macOS 14.4.1
    CPU: (10) arm64 Apple M1 Pro
    Memory: 5.99 GB / 32.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 20.11.0 - ~/.nvm/versions/node/v20.11.0/bin/node
    Yarn: 1.22.21 - ~/.nvm/versions/node/v20.11.0/bin/yarn
    npm: 10.2.4 - ~/.nvm/versions/node/v20.11.0/bin/npm
    pnpm: 8.15.7 - /opt/homebrew/bin/pnpm
    bun: 1.1.0 - ~/.bun/bin/bun
    Watchman: 2024.04.08.00 - /opt/homebrew/bin/watchman
  Browsers:
    Brave Browser: 123.1.64.116
    Chrome: 123.0.6312.123
    Safari: 17.4.1
  npmPackages:
    vite: ^5.2.0 => 5.2.9

Used Package Manager

npm

Logs

No response

Validations

@sapphi-red
Copy link
Member

A workaround is to use import * as babel from '@babel/standalone'.

@sapphi-red sapphi-red added has workaround p2-edge-case Bug, but has workaround or limited in scope (priority) inconsistency Inconsistency between dev & build feat: deps optimizer Esbuild Dependencies Optimization labels Apr 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feat: deps optimizer Esbuild Dependencies Optimization has workaround inconsistency Inconsistency between dev & build p2-edge-case Bug, but has workaround or limited in scope (priority)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants