Babel plugin (v0.3.2, last updated 2020) that rewrites import.meta.url expressions to static file paths or runtime-resolved URLs for use in bundled JavaScript output. It allows developers to define mappings between local source directories and server URLs, and supports multiple import styles (amd, cjs, esm, iife, umd, system). Unlike alternatives like @rollup/plugin-replace or webpack's DefinePlugin, this plugin is specifically designed for bundlers like Rollup or custom Babel pipelines that need to preserve import.meta semantics in bundles. Requires @babel/core as a peer dependency. Active but low maintenance cadence.
npm install babel-plugin-bundled-import-metaVerified import paths — ran on the pinned version, not inferred.
Configures the plugin with mappings and bundleDir, showing how import.meta.url is rewritten for bundled output.
Only use import.meta.url in your code; for other properties, use a different solution.
Choose a different importStyle (e.g., 'cjs' or 'amd') that resolves the bundle URL via a different global or mechanism.
Consider migrating to @rollup/plugin-replace or manual import.meta transformation for active support.
Ensure all source files with import.meta.url are covered by mappings or reside under bundleDir.
Use absolute URLs in mappings when possible, or ensure bundle URL is known and static.
Run 'npm install babel-plugin-bundled-import-meta --save-dev' and use string 'bundled-import-meta' (without 'babel-plugin-' prefix).
Set 'importStyle' to a non-'esm' value like 'cjs' to avoid relying on import.meta at runtime.
Ensure the plugin is listed in 'plugins' array, and check Babel version >= 7.7.0.
Add a mapping for the file's directory or set bundleDir to cover it.