rollup how to write a plugin that injects variables containing all imported IDs into the final source code?

64 views Asked by At

For example

// entry.js
import allModules from 'virtual:all-modules';
import a from './a.js';

console.log(a);
// a.js
import b from './b.js';
export default b;
// b.js
export default {};

After rollup the virtual:all-modules will be ['entry.js', 'a.js', 'b.js'].

I tried the buildEnd hooks, but it can't run this.load({id: 'virtual:all-modules'}) again, the source code doesn't changed.

0

There are 0 answers