question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Legacy build fails on babel step

See original GitHub issue

Describe the bug

The build with the legacy plugin active fails with an error from babel.

❯ npm run build

> vite-project@0.0.0 build
> tsc && vite build

vite v2.0.5 building for production...
✓ 21 modules transformed.
[legacy-post-process] [BABEL] unknown: .plugins[13][0] must be a string, object, function
error during build:
Error: [BABEL] unknown: .plugins[13][0] must be a string, object, function
    at assertPluginTarget (/Sites/vite-project/node_modules/@babel/standalone/babel.js:67416:12)
    at assertPluginItem (//Sites/vite-project/node_modules/@babel/standalone/babel.js:67390:6)
    at //Sites/vite-project/node_modules/@babel/standalone/babel.js:67373:15
    at Array.forEach (<anonymous>)
    at assertPluginList (/Sites/vite-project/node_modules/@babel/standalone/babel.js:67372:10)
    at /Sites/vite-project/node_modules/@babel/standalone/babel.js:67591:6
    at Array.forEach (<anonymous>)
    at validateNested (/Sites/vite-project/node_modules/@babel/standalone/babel.js:67567:22)
    at validate$3 (/Sites/vite-project/node_modules/@babel/standalone/babel.js:67558:11)
    at /Sites/vite-project/node_modules/@babel/standalone/babel.js:69754:15

Reproduction

Base config

import { defineConfig } from 'vite'
import legacy from '@vitejs/plugin-legacy'

export default defineConfig({
  plugins: [legacy({ targets: ['defaults', 'not IE 11'] })]
})

System Info

  • vite version: 2.0.5
  • Operating System: macOS Big Sur
  • Node version: 12.21.0
  • Package manager (npm/yarn/pnpm) and version: npm 7.6.0

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:4
  • Comments:17 (6 by maintainers)

github_iconTop GitHub Comments

5reactions
mengelbrechtcommented, Mar 10, 2021

As a temporary workaround you can pin the @babel/standalone version to 7.13.9 in package.json:

"@babel/standalone": "7.13.9"
3reactions
wgordon17commented, Mar 13, 2021

@mengelbrecht Where exactly are we supposed to pin @babel/standalone? Since it looks like plugin-legacy vendors it’s own version of @babel/standalone at ^7.12.12.

For those using yarn for their package manager, I got this working with

  "dependencies": {
    ...
  },
  "devDependencies": {
    ...
  },
  "resolutions": {
    "@vitejs/plugin-legacy/@babel/standalone": "7.13.9"
  }
Read more comments on GitHub >

github_iconTop Results From Across the Web

Webpack build failing with ERR_OSSL_EVP_UNSUPPORTED
I was able to fix it via: export NODE_OPTIONS=--openssl-legacy-provider. sachaw's comment to Node.js v17.0.0 - Error starting project in ...
Read more >
[Docker Course 4-13] Issue on npm install step
Hello there, I've facing an issue while installing the app dependencies, returning an user permission denied while accessing the /app ...
Read more >
Build Setup Recipes
The main strategy people adopt is having 2 builds: Modern JS build - transpile Svelte as is; Legacy browser build - add Babel...
Read more >
babel/polyfill
Babel includes a polyfill that includes a custom regenerator runtime and core-js. This will emulate a full ES2015+ environment (no < Stage 4...
Read more >
Troubleshooting | Stryker Mutator
Mutating fails: Cannot use the decorators and decorators-legacy plugin together​. Example: ERROR Stryker Unexpected error occurred while running Stryker Error: ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found