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.

@vitejs/plugin-legacy does not use browserslistrc

See original GitHub issue

⚠️ IMPORTANT ⚠️ Please do not ignore this template. If you do, your issue will be closed immediately.

Describe the bug

@vitejs/plugin-legacy does not use browserlist config files. When the targets option is not specified, it is defaulted to defaults, which means @babel/present-env will use that target rather than .browserslistrc.

Reproduction

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

export default defineConfig({
  plugins: [legacy()]
})

System Info

  • vite version: 2.0.5
  • Operating System: macOS 11.2.2
  • Node version: 14.16.0
  • Package manager (npm/yarn/pnpm) and version: yarn 1.22.10

Logs (Optional if provided reproduction)

With no targets option
[@vitejs/plugin-legacy] legacy polyfills: Set(95) {
  'core-js/modules/es.symbol.js',
  'core-js/modules/es.symbol.description.js',
  'core-js/modules/es.object.to-string.js',
  'core-js/modules/es.symbol.iterator.js',
  'core-js/modules/es.string.iterator.js',
  'core-js/modules/es.array.iterator.js',
  'core-js/modules/web.dom-collections.iterator.js',
  'core-js/modules/es.symbol.async-iterator.js',
  'core-js/modules/es.symbol.to-string-tag.js',
  'core-js/modules/es.math.to-string-tag.js',
  'core-js/modules/es.json.to-string-tag.js',
  'core-js/modules/es.object.get-prototype-of.js',
  'core-js/modules/es.function.name.js',
  'core-js/modules/es.promise.js',
  'core-js/modules/es.regexp.to-string.js',
  'core-js/modules/web.dom-collections.for-each.js',
  'core-js/modules/es.array.slice.js',
  'core-js/modules/es.number.constructor.js',
  'core-js/modules/es.number.to-fixed.js',
  'core-js/modules/es.array.join.js',
  'core-js/modules/es.array.map.js',
  'core-js/modules/es.array.filter.js',
  'core-js/modules/es.string.split.js',
  'core-js/modules/es.regexp.exec.js',
  'core-js/modules/es.array.splice.js',
  'core-js/modules/es.object.assign.js',
  'core-js/modules/es.object.get-own-property-descriptor.js',
  'core-js/modules/es.array.concat.js',
  'core-js/modules/es.weak-set.js',
  'core-js/modules/es.string.replace.js',
  'core-js/modules/web.url.to-json.js',
  'core-js/modules/es.object.keys.js',
  'core-js/modules/esnext.global-this.js',
  'core-js/modules/es.regexp.constructor.js',
  'core-js/modules/es.array.includes.js',
  'core-js/modules/es.string.includes.js',
  'regenerator-runtime/runtime.js',
  'core-js/modules/es.object.get-own-property-descriptors.js',
  'core-js/modules/web.url.js',
  'core-js/modules/es.string.search.js',
  'core-js/modules/es.string.match.js',
  'core-js/modules/es.string.trim.js',
  'core-js/modules/es.array.find.js',
  'core-js/modules/es.array.reduce.js',
  'core-js/modules/es.set.js',
  'core-js/modules/es.string.sub.js',
  'core-js/modules/es.array.from.js',
  'core-js/modules/es.map.js',
  'core-js/modules/es.string.starts-with.js',
  'core-js/modules/es.string.ends-with.js',
  'core-js/modules/es.weak-map.js',
  'core-js/modules/es.string.pad-start.js',
  'core-js/modules/es.object.values.js',
  'core-js/modules/es.array.find-index.js',
  'core-js/modules/es.number.epsilon.js',
  'core-js/modules/es.object.get-own-property-names.js',
  'core-js/modules/es.object.is.js',
  'core-js/modules/es.object.freeze.js',
  'core-js/modules/es.typed-array.uint32-array.js',
  'core-js/modules/es.typed-array.copy-within.js',
  'core-js/modules/es.typed-array.every.js',
  'core-js/modules/es.typed-array.fill.js',
  'core-js/modules/es.typed-array.filter.js',
  'core-js/modules/es.typed-array.find.js',
  'core-js/modules/es.typed-array.find-index.js',
  'core-js/modules/es.typed-array.for-each.js',
  'core-js/modules/es.typed-array.includes.js',
  'core-js/modules/es.typed-array.index-of.js',
  'core-js/modules/es.typed-array.iterator.js',
  'core-js/modules/es.typed-array.join.js',
  'core-js/modules/es.typed-array.last-index-of.js',
  'core-js/modules/es.typed-array.map.js',
  'core-js/modules/es.typed-array.reduce.js',
  'core-js/modules/es.typed-array.reduce-right.js',
  'core-js/modules/es.typed-array.reverse.js',
  'core-js/modules/es.typed-array.set.js',
  'core-js/modules/es.typed-array.slice.js',
  'core-js/modules/es.typed-array.some.js',
  'core-js/modules/es.typed-array.sort.js',
  'core-js/modules/es.typed-array.subarray.js',
  'core-js/modules/es.typed-array.to-locale-string.js',
  'core-js/modules/es.typed-array.to-string.js',
  'core-js/modules/es.object.is-frozen.js',
  'core-js/modules/es.reflect.own-keys.js',
  'core-js/modules/es.reflect.get-own-property-descriptor.js',
  'core-js/modules/es.string.link.js',
  'core-js/modules/es.array-buffer.constructor.js',
  'core-js/modules/es.reflect.construct.js',
  'core-js/modules/es.promise.finally.js',
  'core-js/modules/es.array.flat-map.js',
  'core-js/modules/es.array.unscopables.flat-map.js',
  'core-js/modules/es.math.sinh.js',
  'core-js/modules/es.math.cosh.js',
  'core-js/modules/es.string.repeat.js',
  'core-js/modules/es.typed-array.float32-array.js'
}
With targets set to same value as in my .browserslistrc (>0.2%, not dead, not op_mini all)
[@vitejs/plugin-legacy] legacy polyfills: Set(101) {
  'core-js/modules/es.symbol.js',
  'core-js/modules/es.symbol.description.js',
  'core-js/modules/es.object.to-string.js',
  'core-js/modules/es.symbol.iterator.js',
  'core-js/modules/es.string.iterator.js',
  'core-js/modules/es.array.iterator.js',
  'core-js/modules/web.dom-collections.iterator.js',
  'core-js/modules/es.symbol.async-iterator.js',
  'core-js/modules/es.symbol.to-string-tag.js',
  'core-js/modules/es.math.to-string-tag.js',
  'core-js/modules/es.json.to-string-tag.js',
  'core-js/modules/es.object.get-prototype-of.js',
  'core-js/modules/es.function.name.js',
  'core-js/modules/es.promise.js',
  'core-js/modules/es.regexp.to-string.js',
  'core-js/modules/web.dom-collections.for-each.js',
  'core-js/modules/es.array.reverse.js',
  'core-js/modules/es.array.slice.js',
  'core-js/modules/es.number.constructor.js',
  'core-js/modules/es.number.to-fixed.js',
  'core-js/modules/es.array.join.js',
  'core-js/modules/es.array.map.js',
  'core-js/modules/es.array.filter.js',
  'core-js/modules/es.array.sort.js',
  'core-js/modules/es.string.split.js',
  'core-js/modules/es.regexp.exec.js',
  'core-js/modules/es.array.index-of.js',
  'core-js/modules/es.array.splice.js',
  'core-js/modules/es.object.assign.js',
  'core-js/modules/es.object.get-own-property-descriptor.js',
  'core-js/modules/es.array.concat.js',
  'core-js/modules/es.weak-set.js',
  'core-js/modules/es.string.replace.js',
  'core-js/modules/es.date.to-json.js',
  'core-js/modules/web.url.to-json.js',
  'core-js/modules/es.object.keys.js',
  'core-js/modules/esnext.global-this.js',
  'core-js/modules/es.regexp.constructor.js',
  'core-js/modules/es.array.includes.js',
  'core-js/modules/es.string.includes.js',
  'regenerator-runtime/runtime.js',
  'core-js/modules/es.object.get-own-property-descriptors.js',
  'core-js/modules/web.url.js',
  'core-js/modules/es.string.search.js',
  'core-js/modules/es.string.match.js',
  'core-js/modules/es.string.trim.js',
  'core-js/modules/es.array.find.js',
  'core-js/modules/es.array.reduce.js',
  'core-js/modules/es.set.js',
  'core-js/modules/es.string.sub.js',
  'core-js/modules/es.array.from.js',
  'core-js/modules/es.map.js',
  'core-js/modules/es.string.starts-with.js',
  'core-js/modules/es.string.ends-with.js',
  'core-js/modules/es.array.last-index-of.js',
  'core-js/modules/es.weak-map.js',
  'core-js/modules/es.string.pad-start.js',
  'core-js/modules/es.object.values.js',
  'core-js/modules/es.array.find-index.js',
  'core-js/modules/es.number.epsilon.js',
  'core-js/modules/es.object.get-own-property-names.js',
  'core-js/modules/es.object.is.js',
  'core-js/modules/es.object.freeze.js',
  'core-js/modules/es.typed-array.uint32-array.js',
  'core-js/modules/es.typed-array.copy-within.js',
  'core-js/modules/es.typed-array.every.js',
  'core-js/modules/es.typed-array.fill.js',
  'core-js/modules/es.typed-array.filter.js',
  'core-js/modules/es.typed-array.find.js',
  'core-js/modules/es.typed-array.find-index.js',
  'core-js/modules/es.typed-array.for-each.js',
  'core-js/modules/es.typed-array.includes.js',
  'core-js/modules/es.typed-array.index-of.js',
  'core-js/modules/es.typed-array.iterator.js',
  'core-js/modules/es.typed-array.join.js',
  'core-js/modules/es.typed-array.last-index-of.js',
  'core-js/modules/es.typed-array.map.js',
  'core-js/modules/es.typed-array.reduce.js',
  'core-js/modules/es.typed-array.reduce-right.js',
  'core-js/modules/es.typed-array.reverse.js',
  'core-js/modules/es.typed-array.set.js',
  'core-js/modules/es.typed-array.slice.js',
  'core-js/modules/es.typed-array.some.js',
  'core-js/modules/es.typed-array.sort.js',
  'core-js/modules/es.typed-array.subarray.js',
  'core-js/modules/es.typed-array.to-locale-string.js',
  'core-js/modules/es.typed-array.to-string.js',
  'core-js/modules/es.array-buffer.slice.js',
  'core-js/modules/es.object.is-frozen.js',
  'core-js/modules/es.reflect.own-keys.js',
  'core-js/modules/es.reflect.get-own-property-descriptor.js',
  'core-js/modules/es.string.link.js',
  'core-js/modules/es.array-buffer.constructor.js',
  'core-js/modules/es.reflect.construct.js',
  'core-js/modules/es.promise.finally.js',
  'core-js/modules/es.array.flat-map.js',
  'core-js/modules/es.array.unscopables.flat-map.js',
  'core-js/modules/es.math.sinh.js',
  'core-js/modules/es.math.cosh.js',
  'core-js/modules/es.string.repeat.js',
  'core-js/modules/es.typed-array.float32-array.js'
}

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:9
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
sapphi-redcommented, Nov 14, 2022

browserslist is not working because plugin-legacy uses @babel/standalone that uses browser build of browserslist. (https://github.com/vitejs/vite/issues/10502#issue-1411682303)

Switching to @babel/core + @babel/preset-env will make it work. But will bloat the dependencies that needs to be installed.

Handling browserslist on plugin-legacy or bundling babel on our side might increase maintenance burden.

0reactions
guntacommented, Dec 21, 2022

Since babel/preset-env defaults to looking for browserlistrc, I was expecting the same here. Looking forward to this being merged.

Read more comments on GitHub >

github_iconTop Results From Across the Web

@vitejs/plugin-legacy - npm
Start using @vitejs/plugin-legacy in your project by running `npm i ... This plugin provides support for legacy browsers that do not support ...
Read more >
About @vitejs/plugin-legacy does not support library mode
As a developer who has to support IE11, Vite and its out-of-the-box speed and ease of use has been a blessing until I...
Read more >
Vitejs/plugin Legacy: Legacy Browser Support For Vite - Morioh
vitejs/plugin-legacyVite's default browser support baseline is Native ESM. This plugin provides support for legacy browsers that do not support native ESM.
Read more >
Highest scored 'babel-preset-env' questions - Stack Overflow
I am using babel-preset-env version - 1.6.1 for my react app, i am getting a error on IE :- Object doesn't support property...
Read more >
Migration from v3 | Vite (main branch)
If you need to support older browsers, you can add @vitejs/plugin-legacy as ... to be used in this case, as that doesn't emit...
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