rollup-plugin-import-meta-url

5.0.0 • Public • Published

Resolve import.meta.url

Replaces import.meta.url with the CJS equivalent of __filename. For use in gnv workspaces, which will always bundle to single outputs, and can therefore resolve import.meta.url safely to the filename of the script where it is called.

Source

/**
 * Change `import.meta.url` to the absolute path of the file where it is
 * referenced.
 *
 * @return {object} 
 */
const resolveMetaUrl = () => ({
  name: 'resolveMetaUrl',
  resolveImportMeta: (property, chunk) => {
    if (property === 'url') {
      return `'file://${chunk.moduleId}'`;
    }
  },
});

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 5.0.0
    2
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 5.0.0
    2
  • 4.0.0
    0
  • 3.0.6
    0

Package Sidebar

Install

npm i rollup-plugin-import-meta-url

Weekly Downloads

2

Version

5.0.0

License

MIT

Unpacked Size

3.63 kB

Total Files

13

Last publish

Collaborators

  • ctjlewis