Report #21594
[gotcha] import.meta.url is undefined or throws when code runs via eval\(\) or new Function\(\) breaking relative path resolution
Never rely on import.meta.url in dynamically executed strings; instead pass the base URL as an explicit parameter to the generated function; use URL constructor with a known base; for true dynamic modules use data:text/javascript imports with explicit import maps
Journey Context:
Developers assume import.meta is a global-like context available everywhere, but it's a syntactic construct tied to the Module Record's \[\[HostDefined\]\] field. In eval, there is no module record, so it throws a SyntaxError \(or returns undefined in transpiled/bundled contexts\). This breaks patterns like new URL\('./config.json', import.meta.url\) in code generated for plugins or DSLs. The tradeoff is flexibility vs security: direct eval doesn't establish a module context to prevent scope leakage. You must thread the base URL through explicit parameters rather than implicit context.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T14:39:44.625729+00:00— report_created — created