5.0.0 • Published 4 years ago

rollup-plugin-import-meta-url v5.0.0

Weekly downloads
1
License
MIT
Repository
github
Last release
4 years ago

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}'`;
    }
  },
});