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
{{ message }}
This repository was archived by the owner on Mar 19, 2026. It is now read-only.
Repository navigation
This repository was archived by the owner on Mar 19, 2026. It is now read-only.
import.meta.glob expansion cannot be observed from user land plugin since 7.1.2 #373
My use case is to use "post" transform to strip away all the code but import so that it can traverse the entire module graph faster during rsc scan build.
To be honest, I think I should fix this on rsc plugin side by keeping import.meta.glob during scan build, but if anyone has an idea, it's very welcome. Also I'm not sure if other plugins in the wild rely on the previous behavior.
In the long run, rsc scan should be somehow reworked to not require extra dedicated build and that's partly the reason I don't mind adding a workaround on my end.
This might be because we enabled native plugins by default in version 7.1.2, and the native import-glob plugin runs via the transform_ast hook, which is a built-in hook in Rolldown. Since transform_ast always runs later than transform, its execution happens afterward.
My use case specifically is a bit weird one (and I have a workaround so not blocking vitejs/vite-plugin-react#721), but I think it was a nice property that user land post transform can observe all imports simply by es-module-lexer. It's possible that new behavior might confuse some other plugins.
Since import.meta.glob shouldn't appear many times in the whole build, isn't it possible to change builtin implementation to use "regex code filter + extra parse/codegen" inside rust transform hook without performance hit?
Not sure if it's the same issue, but this import is ignored with rolldown-vite: import.meta.glob(['../assets/**', '../svgsprite/**/*.svg', '../icons/**/*.svg']), assets are missing in the manifest.json (using https://github.com/laravel/vite-plugin)
I do have small repro here, I’m trying to debug import glob issue with native modules as well. Details and what I found already in README. but in which I think might related to vitejs#21947
Can't reproduce on a small project and can't publish the large one... import.meta.glob(['../assets/**', '../svgsprite/**/*.svg', '../icons/**/*.svg']) fails, but wrapping it in console.log makes it work (in a broken way):
this code result different when i build the app since 7.1.2 the file from node_modules can't be get
Do you mean the differences between enableNativePlugins: false and true, or the differences between different versions after enabling enableNativePlugins?
@Razunter@hi-ogawa I have the same problem, but I'm not sure if it's the same bug.
What happens is that laravel-vite-plugin defines build.assetsInlineLimit to 0 so it can force all assets to be published no matter the size, but it seems that rolldown do not differentiate between assets and modules from import.meta.glob, so they get treeshaken.
I got an workaround for this, but it generates a few unneeded JS files:
Activity
hi-ogawa commentedon Aug 15, 2025
To be honest, I think I should fix this on rsc plugin side by keeping
import.meta.globduring scan build, but if anyone has an idea, it's very welcome. Also I'm not sure if other plugins in the wild rely on the previous behavior.In the long run, rsc scan should be somehow reworked to not require extra dedicated build and that's partly the reason I don't mind adding a workaround on my end.
shulaoda commentedon Aug 15, 2025
This might be because we enabled native plugins by default in version 7.1.2, and the native import-glob plugin runs via the
transform_asthook, which is a built-in hook in Rolldown. Sincetransform_astalways runs later thantransform, its execution happens afterward.hi-ogawa commentedon Aug 15, 2025
My use case specifically is a bit weird one (and I have a workaround so not blocking vitejs/vite-plugin-react#721), but I think it was a nice property that user land post transform can observe all imports simply by
es-module-lexer. It's possible that new behavior might confuse some other plugins.Since
import.meta.globshouldn't appear many times in the whole build, isn't it possible to change builtin implementation to use "regex code filter + extra parse/codegen" inside rusttransformhook without performance hit?Razunter commentedon Aug 19, 2025
Not sure if it's the same issue, but this import is ignored with rolldown-vite:
import.meta.glob(['../assets/**', '../svgsprite/**/*.svg', '../icons/**/*.svg']), assets are missing in the manifest.json (using https://github.com/laravel/vite-plugin)hi-ogawa commentedon Aug 20, 2025
@Razunter Can you provide a reproduction?
rayriffy commentedon Aug 20, 2025
I do have small repro here, I’m trying to debug import glob issue with native modules as well. Details and what I found already in README. but in which I think might related to vitejs#21947
https://github.com/rayriffy/generouted-native-module-reproduction
hi-ogawa commentedon Aug 20, 2025
generoutedhas this pattern https://github.com/oedotme/generouted/blob/ec147f5d21f2b249b14697f8f308bed23a045932/packages/react-router/src/plugin/options.ts#L8. Indeed, this looks like glob compatibility issue vitejs#21947.Razunter commentedon Aug 20, 2025
Can't reproduce on a small project and can't publish the large one...
import.meta.glob(['../assets/**', '../svgsprite/**/*.svg', '../icons/**/*.svg'])fails, but wrapping it inconsole.logmakes it work (in a broken way):But *.svg gets transformed to *.js:
Previous manifest entry was
TLDR: something weird, but probably unrelated to this issue.
timotejroiko commentedon Aug 28, 2025
I have a sveltekit project, and since updating a few packages my images no longer load, managed to narrow it down to this issue.
Versions 7.1.1 and below work correctly, but 7.1.2 and above all fail to load my images.
Relevant import.meta.glob call, i have tried multiple variations including removing everything except eager true, they all return an empty object.
Relevant packages:
Is there anything i can do on my end to help troubleshoot this?
shulaoda commentedon Aug 28, 2025
@timotejroiko You could try
rolldown-vite@7.1.5or setenableNativePluginstofalse.ppjjzz commentedon Sep 15, 2025
const modules = import.meta.glob<{ default: { view: LazyExoticComponent<() => JSX.Element> } }>(
['@@@/node_modules/xxx/*/app/web/router/.{js,jsx}', '@@@/plugin//app/web/router/*.{ts,tsx}'],
{ eager: true, exhaustive: true },
);
this code result different when i build the app since 7.1.2
the file from node_modules can't be get
shulaoda commentedon Sep 15, 2025
Do you mean the differences between
enableNativePlugins: falseandtrue, or the differences between different versions after enablingenableNativePlugins?DNA commentedon Sep 26, 2025
@Razunter @hi-ogawa I have the same problem, but I'm not sure if it's the same bug.
What happens is that
laravel-vite-plugindefinesbuild.assetsInlineLimitto0so it can force all assets to be published no matter the size, but it seems that rolldown do not differentiate between assets and modules fromimport.meta.glob, so they get treeshaken.I got an workaround for this, but it generates a few unneeded JS files:
I have also been able to reproduce it on stackblits:
https://stackblitz.com/edit/vitejs-vite-mvgpmagk?file=README
feat(rolldown_plugin_vite_import_glob): add transform-based v2 implem…
feat(rolldown_plugin_vite_dynamic_import_vars): add transform-based v…
feat(rolldown_plugin_vite_dynamic_import_vars): add transform-based v…