You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
However, I have some JS files that are located in a directory named /global. The import import lib from @/my/global/lib.js is broken at build time when doing vite build:
Could not resolve './my/{}/lib' from src/main.js
error during build:
Error: Could not resolve './my/{}/lib' from src/main.js
which is not what is expected and could lead to lot of problems, because any defined variable can break any import string where the variable name is present. For instance, i have also some files called global-something.js, and they are transformed into {}-something.js...
The define docs were modified to better explain that it shouldn't be used to replace variables, but only constants here b4a1526 (still not deployed)
The replacements are done with a simple regex during build time, you should only use define for unique constants that are not going to interfere with the rest of the code when being replaced.
Describe the bug
As some lib rely on
global
, I had to shimglobal
with:However, I have some JS files that are located in a directory named
/global
. The importimport lib from @/my/global/lib.js
is broken atbuild
time when doingvite build
:which is not what is expected and could lead to lot of problems, because any defined variable can break any import string where the variable name is present. For instance, i have also some files called
global-something.js
, and they are transformed into{}-something.js
...Reproduction
break-global.zip
yarn
&&yarn build
System Info
Output of
npx envinfo --system --npmPackages vite,@vitejs/plugin-vue --binaries --browsers
:Used package manager: yarn
Before submitting the issue, please make sure you do the following
The text was updated successfully, but these errors were encountered: