-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Description
Describe the bug
According to the docs https://main.vitejs.dev/config/build-options.html#build-target a valid esbuild target could be given to the build.target option. According to https://esbuild.github.io/content-types/#javascript 'es2019' build target should result in import.meta being transformed. This works as long as the base option is an absolute path, as soon as this is a relative path import.meta is still present in the js file generated by npm run build.
See https://github.com/derMart/example_vite_es2019/blob/0a3a35c00f15b84466e1bdd8be1e5eb1ce7b49ce/dist/assets/index.355a229a.js#L4649
and the used config https://github.com/derMart/example_vite_es2019/blob/0a3a35c00f15b84466e1bdd8be1e5eb1ce7b49ce/vite.config.ts
When changing to base: '/' the resulting js will not contain import.meta anymore
Reproduction
https://github.com/derMart/example_vite_es2019
System Info
System:
OS: Linux 5.15 Ubuntu 22.04.1 LTS 22.04.1 LTS (Jammy Jellyfish)
CPU: (8) x64 Intel(R) Core(TM) i7-10510U CPU @ 1.80GHz
Memory: 9.22 GB / 15.33 GB
Container: Yes
Shell: 5.1.16 - /bin/bash
Binaries:
Node: 16.15.0 - ~/.nvm/versions/node/v16.15.0/bin/node
Yarn: 1.22.19 - ~/.yarn/bin/yarn
npm: 8.5.5 - ~/.nvm/versions/node/v16.15.0/bin/npm
Browsers:
Chrome: 96.0.4664.45
Chromium: 104.0.5112.79
Firefox: 103.0.1
npmPackages:
@vitejs/plugin-vue: ^3.0.0 => 3.0.1
vite: ^3.0.0 => 3.0.4Used Package Manager
npm
Logs
No response
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- Make sure this is a Vite issue and not a framework-specific issue. For example, if it's a Vue SFC related bug, it should likely be reported to vuejs/core instead.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- The provided reproduction is a minimal reproducible example of the bug.