When you upgrade your yarn.lock by yarn upgrade, the esbuild is upgraded to latest version: 0.5.19.
That introduces a bug where you are not anymore able to use import.meta.
The object import.meta is empty, even when .env is set and loaded properly.
My solution was to find esbuild in yarn.lock and replace it for older version:
esbuild@^0.5.3:
version "0.5.9"
resolved "https://registry.yarnpkg.com/esbuild/-/esbuild-0.5.9.tgz#122446c4db6cd24f128332e1872f41896ce1aa76"
integrity sha512-ZCA8DRDroE4qDnT2eqtaAA4zsgSzS5H4gCAYUMcELn/ytIjkWud+l+363BHKohXfo5rZfl3DMynEWD4/XFA00w==
When developer uses the latest:
esbuild@^0.5.11:
version "0.5.19"
resolved "https://registry.yarnpkg.com/esbuild/-/esbuild-0.5.19.tgz#00daed3290407e87347266ed285ef4ce86040f13"
integrity sha512-QiK0BCLPemNO9zziNOFudQbtNnEax/x8faBfbtEtfhb53gNk0H5J10uFrzmJef1P379VrP66BZpc02iqBuM/+g==
He will start getting warnings:
[vite] warnings while transforming /src/testScript.ts with esbuild:
"import.meta" is from ES2020 and will be empty when targeting ES2019
50 | if(import.meta.env.DEV) {
| ^
51 | throw new Error("Not implemented yet")
52 | }
Even when tsconfig.json doesn't exist or module and target are set to ESNext.
It must be related to this issue: evanw/esbuild#208
Is there any way how to support import.meta from esbuild?
it took me few hours to find why the import.meta is not working, so I believe opening this issue will help other developers to find this issue too.
When you upgrade your yarn.lock by
yarn upgrade, the esbuild is upgraded to latest version:0.5.19.That introduces a bug where you are not anymore able to use
import.meta.The object
import.metais empty, even when .env is set and loaded properly.My solution was to find
esbuildinyarn.lockand replace it for older version:When developer uses the latest:
He will start getting warnings:
Even when
tsconfig.jsondoesn't exist ormoduleandtargetare set toESNext.It must be related to this issue: evanw/esbuild#208
Is there any way how to support import.meta from esbuild?
it took me few hours to find why the import.meta is not working, so I believe opening this issue will help other developers to find this issue too.