Plugin resolving of injected files has no way to detect that the file is injected
- Dominant language
- Go
- Stars
- 40.1k
- Forks
- 1.3k
- PR merge metrics
- No merged PRs in 30d
Description
6988145 introduced the ability to resolve paths for injected files. However, this was actually a breaking change for resolvers that are used to mark files as external, it was not marked as such and thus I suspect got missed by many implementing libraries.
One such library is tsup, which we (discord.js) use.
Unfortunately, we have found that on Windows filesystems, you cannot run build with `shims: true` (ref: https://github.com/egoist/tsup/issues/879), which injects shims for esm / cjs.
By sheer luck, it still works on all other filesystems that use `/` as the root due to it not being detected as a node module..
While the regex for that does need to be updated to properly support Windows, the underlying issue is that injected modules should (probably) never be marked as external.
To fix this, I suggest a few things:
1. When resolving an injected path, mark `external: false` after the onResolve callbacks are run.
2. In the arguments for the onResolve callbacks, provide `kind: 'injected'` or similar, so that injected modules can be identified.
3. Provide an option to disable calling onResolve for injected paths at all.
I don't sese a reason why external: false should be possible. However, there may be a good reason for it, and in that case the other two options provide satisfactory means to overcome this issue.
Contributor guide
No contributing guide indexed for this repository
Research direction
Review the injected-path resolution and onResolve callback behavior described in the issue, along with the linked tsup report. Determine whether injected paths should force external: false, expose kind: 'injected', or skip callbacks; done means Windows shim builds no longer misclassify injected modules and the resolver behavior is covered by tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100