Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support import.meta.url and require.resolve #1153

Open
2 tasks
naugtur opened this issue Apr 12, 2022 · 2 comments
Open
2 tasks

Support import.meta.url and require.resolve #1153

naugtur opened this issue Apr 12, 2022 · 2 comments
Labels
endo kriskowal-review-2024-01 Issues that kriskowal wants to bring to the attention of the team for review as of January, 2024

Comments

@naugtur
Copy link
Member

naugtur commented Apr 12, 2022

Use-cases

The goal of this is to collect requirements for the feature

import.meta.url

  • resolving relative paths to non-code files of the same package (data or reading version from package.json)
  • creating a require function and shimming paths
const require = createRequire(import.meta.url);
__dirname = fileURLToPath(import.meta.url);
  • workers, loaders etc. - situations where code files URLs need to be known
const LOADER = new URL('shared-worker-loader.js', import.meta.url);

require.resolve

  • resetting require cache
delete require.cache[require.resolve('../src/sha3.js')];

Requirements

import.meta

running from live filesystem (loadLocation)

running form bundle/archive

require.resolve require.cache

running from live filesystem (loadLocation)

running form bundle/archive

Work

@kriskowal
Copy link
Member

See: #291

@Tartuffo Tartuffo added the endo label May 9, 2022
@kriskowal
Copy link
Member

I’ll note that import.meta.resolve is now specified to be synchronous, which we can support because we know where all the dependency packages are before we run JS.

@kriskowal kriskowal added the kriskowal-review-2024-01 Issues that kriskowal wants to bring to the attention of the team for review as of January, 2024 label Jan 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
endo kriskowal-review-2024-01 Issues that kriskowal wants to bring to the attention of the team for review as of January, 2024
Projects
None yet
Development

No branches or pull requests

3 participants