I am trying to call import.meta.glob() in an Astro/Vite project inside a utility function. A Vite plugin too calls it. And when a Vite plugin runs, Vite hasn't yet started resolving imports. As a result, the import.meta.glob function is getting called by Node.js and not Vite. And it's not present in the Node runtime.
But why is Node.js throwing the error (intermediate value).glob is not a function instead of import.meta.glob is not a function?
But if I run the following code, then I get the error importMeta.glob is not a function correctly.
const importMeta = import.meta;
importMeta.glob();
So, why is it happening for import.meta only? Typically it happens when we forget to place a semicolon between a function declaration and an immediately invoked function expression. But this is definitely not the case here.