import.meta.url stays original after compilation, how to get compiled file path

Open
#911 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Needs clarification
Activity status
Stale
Tech stack
javascript, nodejs
Domain
build-system

Research direction

Reproduce the reported behavior with a source file using import.meta.url and the two paths described in the issue. Then inspect ncc's handling of import.meta.url during compilation and establish whether the compiled output can resolve its deployed location; done means the behavior is fixed or the limitation and supported approach are clearly documented.

Written by the indexing model from the issue text.

Description

Let's suppose a file located at /<packagerootdir>/lib/xyz/someaction.js. After compilation I place the resulting file in e.g. /app/dist/index.js. The someaction.js used import.meta.url to find it's location. And it was working well in the uncompiled code. But for the compiled import.meta.url returns /app/lib/xyz/someaction.js. So:

  1. This is incorrect because /app/lib/xyz/someaction.js does not exist
  2. This is incorrect because the index.js is actually in /app/dist ... and dist part is missing in the resulting path anyway
  3. Finally it is not clear how to get compiled index.js path properly.
Dominant language
JavaScript
Stars
9.8k
Forks
326
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from vercel/ncc

All issues in vercel/ncc

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.