-
-
Notifications
You must be signed in to change notification settings - Fork 7.2k
Closed
Labels
documentationImprovements or additions to documentationImprovements or additions to documentationrollup plugin compat
Description
Describe the bug
If using the resolveId(importee, importer, opts)
hook with enforce: "pre"
, the importer
will be different in dev mode vs in build mode.
Specifically in dev mode the importer
will always be the top level .html
file.
For my specific use case this makes it impossible to determine what the top level scripts are without other work arounds.
I was thinking ideally I'd be able to do:
resolveId(importee, importer) {
if (importer) {
if (this.getModuleInfo(importer).isEntry) {
// This tells me that the parent of importee` is the top level file, the `.html` file.
}
}
}
However using isEntry
on getModuleInfo
also only works in build mode.
Reproduction
See https://github.com/DylanPiercey/vite-issue-resolve-id-repro
System Info
System:
OS: macOS 10.15.7
CPU: (4) x64 Intel(R) Core(TM) i7-7567U CPU @ 3.50GHz
Memory: 3.43 GB / 16.00 GB
Shell: 5.7.1 - /bin/zsh
Binaries:
Node: 16.6.2 - ~/.nvm/versions/node/v16.6.2/bin/node
Yarn: 1.22.5 - ~/.yarn/bin/yarn
npm: 7.20.3 - ~/.nvm/versions/node/v16.6.2/bin/npm
Browsers:
Chrome: 95.0.4638.69
Edge: 96.0.1054.43
Firefox: 91.0
Safari: 15.1
Used Package Manager
npm
Logs
No response
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- Make sure this is a Vite issue and not a framework-specific issue. For example, if it's a Vue SFC related bug, it should likely be reported to https://github.com/vuejs/vue-next instead.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- The provided reproduction is a minimal reproducible example of the bug.
Metadata
Metadata
Assignees
Labels
documentationImprovements or additions to documentationImprovements or additions to documentationrollup plugin compat