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

"import.meta" is not available in the configured target environment ("es6") and will be empty #10272

Closed
7 tasks done
philjones88 opened this issue Sep 28, 2022 · 1 comment
Closed
7 tasks done
Labels
duplicate This issue or pull request already exists

Comments

@philjones88
Copy link

philjones88 commented Sep 28, 2022

Describe the bug

We started to notice this issue recently after upgrading to Vite 3.1.x:

transforming (27) node_modules/react/cjs/react.production.min.js[plugin:vite:esbuild] "import.meta" is not available in the configured target environment ("es6") and will be empty
33 |      backend: {
34 |        loadPath: `${import.meta.env.BASE_URL}locales/{{lng}}/{{ns}}.json`,
   |                     ^
36 |      },
37 |    });

we have "target": "es6", and to fix it we had to change to "target": "es2020", but we're nervous about browser support changes that will be caused by this.

Reproduction

na

System Info

npx envinfo --system --npmPackages '{vite,@vitejs/*}' --binaries --browsers
Need to install the following packages:
  envinfo@7.8.1
Ok to proceed? (y) y

  System:
    OS: macOS 12.5
    CPU: (16) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
    Memory: 3.42 GB / 64.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 16.17.0 - /usr/local/bin/node
    Yarn: 1.22.18 - /usr/local/bin/yarn
    npm: 8.15.0 - /usr/local/bin/npm
  Browsers:
    Chrome: 105.0.5195.125
    Firefox: 105.0.1
    Safari: 15.6
  npmPackages:
    @vitejs/plugin-react: ^2.1.0 => 2.1.0
    vite: ^3.1.1 => 3.1.3


### Used Package Manager

yarn

### Logs

<details>
<summary>Click to expand!</summary>

```shell
yarn run v1.22.18
$ tsc --noEmit && vite build --debug
  vite:config bundled config file loaded in 125.57ms +0ms
  vite:esbuild init tsconfck (root: /Users/<redacted>) +0ms
  vite:esbuild init tsconfck (root: /Users/<redacted>) +0ms
  vite:esbuild init tsconfck (root: /Users/<redacted>) +1ms
  vite:esbuild init tsconfck (root: /Users/<redacted>) +0ms
  vite:esbuild init tsconfck end +23ms
  vite:esbuild init tsconfck end +0ms
  vite:esbuild init tsconfck end +0ms
  vite:esbuild init tsconfck end +0ms
  vite:config using resolved config: {
  vite:config   plugins: [
  vite:config     'vite:build-metadata',
  vite:config     'vite:pre-alias',
  vite:config     'alias',
  vite:config     'vite:react-babel',
  vite:config     'vite:react-refresh',
  vite:config     'vite:react-jsx',
  vite:config     'vite:modulepreload-polyfill',
  vite:config     'vite:resolve',
  vite:config     'vite:html-inline-proxy',
  vite:config     'vite:css',
  vite:config     'vite:esbuild',
  vite:config     'vite:json',
  vite:config     'vite:wasm-helper',
  vite:config     'vite:worker',
  vite:config     'vite:asset',
  vite:config     'vite:wasm-fallback',
  vite:config     'vite:define',
  vite:config     'vite:css-post',
  vite:config     'vite:build-html',
  vite:config     'vite:worker-import-meta-url',
  vite:config     'vite:force-systemjs-wrap-complete',
  vite:config     'vite:watch-package-data',
  vite:config     'commonjs',
  vite:config     'vite:data-uri',
  vite:config     'vite:asset-import-meta-url',
  vite:config     'vite:dynamic-import-vars',
  vite:config     'vite:import-glob',
  vite:config     'vite:build-import-analysis',
  vite:config     'vite:esbuild-transpile',
  vite:config     'vite:terser',
  vite:config     'vite:reporter',
  vite:config     'vite:load-fallback'
  vite:config   ],
  vite:config   define: { APP_VERSION: '"1.0.0-alpha.1"' },
  vite:config   base: '/app/',
  vite:config   server: {
  vite:config     preTransformRequests: true,
  vite:config     port: 4240,
  vite:config     open: false,
  vite:config     hmr: {
  vite:config       host: 'lab.local',
  vite:config       clientPort: 4443,
  vite:config       protocol: 'wss',
  vite:config       path: '/ws'
  vite:config     },
  vite:config     middlewareMode: false,
  vite:config     fs: { strict: true, allow: [Array], deny: [Array] }
  vite:config   },
  vite:config   resolve: {
  vite:config     alias: [ [Object], [Object], [Object] ],
  vite:config     dedupe: [ 'react', 'react-dom' ]
  vite:config   },
  vite:config   build: {
  vite:config     target: [ 'es2020', 'edge88', 'firefox78', 'chrome87', 'safari13' ],
  vite:config     polyfillModulePreload: true,
  vite:config     outDir: './build',
  vite:config     assetsDir: 'assets',
  vite:config     assetsInlineLimit: 4096,
  vite:config     cssCodeSplit: true,
  vite:config     cssTarget: [ 'es2020', 'edge88', 'firefox78', 'chrome87', 'safari13' ],
  vite:config     sourcemap: false,
  vite:config     rollupOptions: { output: [Object] },
  vite:config     minify: 'esbuild',
  vite:config     terserOptions: {},
  vite:config     write: true,
  vite:config     emptyOutDir: null,
  vite:config     manifest: false,
  vite:config     lib: false,
  vite:config     ssr: false,
  vite:config     ssrManifest: false,
  vite:config     reportCompressedSize: true,
  vite:config     chunkSizeWarningLimit: 600,
  vite:config     watch: null,
  vite:config     commonjsOptions: { include: [Array], extensions: [Array] },
  vite:config     dynamicImportVarsOptions: { warnOnError: true, exclude: [Array] }
  vite:config   },
  vite:config   preview: {
  vite:config     port: 4240,
  vite:config     strictPort: undefined,
  vite:config     host: 'lab.local',
  vite:config     https: undefined,
  vite:config     open: false,
  vite:config     proxy: undefined,
  vite:config     cors: false,
  vite:config     headers: undefined
  vite:config   },
  vite:config   optimizeDeps: {
  vite:config     disabled: 'build',
  vite:config     force: undefined,
  vite:config     include: [ 'react/jsx-runtime', 'react/jsx-dev-runtime', 'react' ],
  vite:config     esbuildOptions: { preserveSymlinks: undefined }
  vite:config   },
  vite:config   configFile: '/Users/<redacted>/vite.config.ts',
  vite:config   configFileDependencies: [ '/Users/<redacted>/vite.config.ts' ],
  vite:config   inlineConfig: {
  vite:config     root: undefined,
  vite:config     base: undefined,
  vite:config     mode: undefined,
  vite:config     configFile: undefined,
  vite:config     logLevel: undefined,
  vite:config     clearScreen: undefined,
  vite:config     optimizeDeps: { force: undefined },
  vite:config     build: {}
  vite:config   },
  vite:config   root: '/Users/<redacted>',
  vite:config   publicDir: '/Users/<redacted>/public',
  vite:config   cacheDir: '/Users/<redacted>/node_modules/.vite',
  vite:config   command: 'build',
  vite:config   mode: 'production',
  vite:config   ssr: {
  vite:config     format: 'esm',
  vite:config     target: 'node',
  vite:config     optimizeDeps: { disabled: true, esbuildOptions: [Object] }
  vite:config   },
  vite:config   isWorker: false,
  vite:config   mainConfig: null,
  vite:config   isProduction: true,
  vite:config   env: { BASE_URL: '/app/', MODE: 'production', DEV: false, PROD: true },
  vite:config   assetsInclude: [Function: assetsInclude],
  vite:config   logger: {
  vite:config     hasWarned: false,
  vite:config     info: [Function: info],
  vite:config     warn: [Function: warn],
  vite:config     warnOnce: [Function: warnOnce],
  vite:config     error: [Function: error],
  vite:config     clearScreen: [Function: clearScreen],
  vite:config     hasErrorLogged: [Function: hasErrorLogged]
  vite:config   },
  vite:config   packageCache: Map(0) { set: [Function (anonymous)] },
  vite:config   createResolver: [Function: createResolver],
  vite:config   worker: {
  vite:config     format: 'iife',
  vite:config     plugins: [
  vite:config       'vite:build-metadata',
  vite:config       'vite:pre-alias',
  vite:config       'alias',
  vite:config       'vite:modulepreload-polyfill',
  vite:config       'vite:resolve',
  vite:config       'vite:html-inline-proxy',
  vite:config       'vite:css',
  vite:config       'vite:esbuild',
  vite:config       'vite:json',
  vite:config       'vite:wasm-helper',
  vite:config       'vite:worker',
  vite:config       'vite:asset',
  vite:config       'vite:wasm-fallback',
  vite:config       'vite:define',
  vite:config       'vite:css-post',
  vite:config       'vite:build-html',
  vite:config       'vite:worker-import-meta-url',
  vite:config       'vite:force-systemjs-wrap-complete',
  vite:config       'vite:watch-package-data',
  vite:config       'commonjs',
  vite:config       'vite:data-uri',
  vite:config       'vite:asset-import-meta-url',
  vite:config       'vite:dynamic-import-vars',
  vite:config       'vite:import-glob',
  vite:config       'vite:build-import-analysis',
  vite:config       'vite:esbuild-transpile',
  vite:config       'vite:terser',
  vite:config       'vite:reporter',
  vite:config       'vite:load-fallback'
  vite:config     ],
  vite:config     rollupOptions: {},
  vite:config     getSortedPlugins: [Function: getSortedPlugins],
  vite:config     getSortedPluginHooks: [Function: getSortedPluginHooks]
  vite:config   },
  vite:config   appType: 'spa',
  vite:config   experimental: { importGlobRestoreExtension: false, hmrPartialAccept: false },
  vite:config   getSortedPlugins: [Function: getSortedPlugins],
  vite:config   getSortedPluginHooks: [Function: getSortedPluginHooks]
  vite:config } +31ms
vite v3.1.3 building for production...
transforming (5) node_modules/@capacitor/core/dist/index.js[plugin:vite:esbuild] "import.meta" is not available in the configured target environment ("es6") and will be empty
4  |  import { initReactI18next } from 'react-i18next';
5  |
6  |  const debug = import.meta.env.DEV;
   |                ^
7  |  const backendLoadPath = `${import.meta.env.BASE_URL}locales/{{lng}}/{{ns}}.json`;
8  |

[plugin:vite:esbuild] "import.meta" is not available in the configured target environment ("es6") and will be empty
5  |
6  |  const debug = import.meta.env.DEV;
7  |  const backendLoadPath = `${import.meta.env.BASE_URL}locales/{{lng}}/{{ns}}.json`;
   |                             ^
8  |
9  |  i18n

✓ 265 modules transformed.
build/index.html                            1.38 KiB
build/assets/vendor_capacitor.eeb3a963.js   8.23 KiB / gzip: 3.25 KiB
build/assets/index.0f401d36.css             5.95 KiB / gzip: 1.23 KiB
build/assets/vendor_ionic.ccf54ca9.css      21.37 KiB / gzip: 4.04 KiB
build/assets/index.a11c53bb.js              45.54 KiB / gzip: 17.91 KiB
build/assets/vendor_i18next.9bf52241.js     85.74 KiB / gzip: 24.62 KiB
build/assets/vendor_ionic.fc782944.js       487.37 KiB / gzip: 128.78 KiB
✨  Done in 13.87s.

Validations

@sapphi-red
Copy link
Member

Duplicate of #10167

@sapphi-red sapphi-red marked this as a duplicate of #10167 Sep 28, 2022
@sapphi-red sapphi-red closed this as not planned Won't fix, can't repro, duplicate, stale Sep 28, 2022
@sapphi-red sapphi-red added duplicate This issue or pull request already exists and removed pending triage labels Sep 28, 2022
@github-actions github-actions bot locked and limited conversation to collaborators Oct 13, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

2 participants