Skip to content

trytelework/rollup-plugin-import-meta-url

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Replaces import.meta.url with the CJS equivalent of __filename.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published