The resolveImportMeta hook gives a way to allows to customize import.meta and import.meta.someProperty, see here
https://rollupjs.org/plugin-development/#resolveimportmeta. Here has a example for it.
function importMetaUrlCurrentModulePlugin() {
return {
name: 'import-meta-url-current-module',
resolveImportMeta(property, { moduleId }) {
if (property === 'url') {
return `'${pathToFileURL(moduleId).href}'`;
}
if (property == null) {
return `{url:'${pathToFileURL(moduleId).href}'}`;
}
return null;
}
};
}
The hook will return string code to replace original import.meta.xx. Because the rolldown using Ast to codegen. It is difficult to implement it, it need to the oxc has some ways create ast from string, we could using parse at now. If you has good ideas, please let me know.
The
resolveImportMetahook gives a way to allows to customizeimport.metaandimport.meta.someProperty, see herehttps://rollupjs.org/plugin-development/#resolveimportmeta. Here has a example for it.
The hook will return string code to replace original
import.meta.xx. Because the rolldown using Ast to codegen. It is difficult to implement it, it need to the oxc has some ways create ast from string, we could usingparseat now. If you has good ideas, please let me know.