Skip to content
This repository has been archived by the owner on May 1, 2020. It is now read-only.
This repository has been archived by the owner on May 1, 2020. It is now read-only.

Proposal: import.meta.urlBase #16

Closed

Description

Many use cases around import.meta.url are based on relative loading of sibling paths to import.meta.url.

These naturally end up quite unwieldy, for example loading a worker in the same folder:

new Worker(import.meta.url + '/../worker.js', { type: 'module' });

or even:

new Worker(new URL('./worker.js', import.meta.url).href, { type: 'module' });

Just like Node.js supports both __filename and __dirname, if we had cross-platform support for import.meta.urlBase (name to be bikeshed further), then this could be simplified to:

new Worker(`import.meta.urlBase + '/worker.js', { type: 'module' });

This could help in simplifying conventions around these sibling fetch cases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions