-
-
Notifications
You must be signed in to change notification settings - Fork 6.2k
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
Disable dynamic import detection for one line or for whole project #16241
Comments
bump |
I still have problem with
|
But after build everything works great, thank you guys ❤ |
Hmm we should be injecting the vite/packages/vite/src/node/plugins/importAnalysis.ts Lines 720 to 728 in c3b3d3c
Can you open a new issue if you can share a repro of it? |
@bluwy hi, all the necessary code was written above The The problem gone in the builded version, but still appears on development mode |
Description
Hi, I'm using vite to build mine chrome extension with reactjs, it's not a big deal, but I have problem with dynamic import;
Due to chrome manifest v3 security and stuff when I'm injecting function by
chrome.scripting.executeScript({injectImmediately: true, world: 'ISOLATED', target: {tabId}, func: FUNCNAME});
And the function
FUNCNAME
is placed right above in background module (service worker), which vite should handle, butFUNCNAME
should be independent due to:Thus when vite compile the ready files, it uses
__vitePreload
on build, and__vite__injectQuery
on dev run; Which func will be lost because of text aboveAnd if, for example I do:
npm run build
__vitePreload
(know it by error whenFUNCNAME
is running once), it's:const contentMain = await __vitePreload(() => import(file), true ? __vite__mapDeps([]) : void 0);
const contentMain = await import(file);
then, it going as it should, without any problem..
so, How can I prevent this compilation into vite functions?
Suggested solution
/* @vite-ignore */
should prevent thisAlternative
or
/* @vite-prevent-next-line */
Additional context
this problem (and the 3rd step) available only(?) on
vite v5.1.6
and not onvite v5.2.2
/* @vite-ignore */
is just replacing:this:
to:
Validations
The text was updated successfully, but these errors were encountered: