-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Closed
Description
Feature Use Case
I'm writing a plugin that needs to make modifications to a file based on other files in the project. In vite I'm using the transform
hook with server._pendingRequests
to check if I'm the only module left, but there's nothing like this exposed in rollup.
Feature Proposal
Something similar to vite: https://github.com/vitejs/vite/blob/b625a2cf3730fda94d934b23bcec0c859bfa0b24/packages/vite/src/node/server/transformRequest.ts#L49-L52
ModuleLoader
:
+ public pendingRequests = new Map()
async fetchModule({ id, meta, moduleSideEffects, syntheticNamedExports }, importer, isEntry) {
...
this.graph.watchFiles[id] = true;
- await this.addModuleSource(id, importer, module);
+ const promise = this.addModuleSource(id, importer, module)
+ this.pendingRequests.set(id, promise.then(() => module))
+ await promise;
+ this.pendingRequests.delete(id)
const resolveStaticDependencyPromises = this.getResolveStaticDependencyPromises(module)
PluginContext
:
const context = {
+ pendingRequests: graph.moduleLoader.pendingRequests,
addWatchFile(id) {