Open stormslowly opened 3 months ago
https://github.com/umijs/mako/blob/45f9278b76b5c820a7ab98a41ab52ddf041be991/crates/mako/src/plugins/ignore.rs#L14-L24
simple_ignore 的实现太 simple 了。 一旦在 resolve 阶段 ignore 了这个模块,那么在后面的阶段都“看不见“它,module graph 也没有它。 我们无法管理一个不存在的模块;所有后继的 concatenate 优化中也无法判定他是一个 inner 还是 external,也无法统计 ignore 模块如何被引用过,因此也无法得出如何 interop 它。
不能有看不见的 module ,那么就造一个虚拟的来替代它
举例如果配置 ignores: ['worker_thread']
ignores: ['worker_thread']
virtual::worker_thread?ignored
// module id virual::worker_thtread?ignored module.exports = require('worker_thread')
后继的处理 virtual::worker_thread?ignored 就作为原来的 worker_thread 的"替身"
需要考虑 minifish 场景下, 引入 virtual 文件,导致中间产物不同。
https://github.com/umijs/mako/blob/45f9278b76b5c820a7ab98a41ab52ddf041be991/crates/mako/src/plugins/ignore.rs#L14-L24
simple_ignore 的实现太 simple 了。 一旦在 resolve 阶段 ignore 了这个模块,那么在后面的阶段都“看不见“它,module graph 也没有它。 我们无法管理一个不存在的模块;所有后继的 concatenate 优化中也无法判定他是一个 inner 还是 external,也无法统计 ignore 模块如何被引用过,因此也无法得出如何 interop 它。
解
不能有看不见的 module ,那么就造一个虚拟的来替代它
举例如果配置
ignores: ['worker_thread']
virtual::worker_thread?ignored
virtual::worker_thread?ignored
加载为后继的处理 virtual::worker_thread?ignored 就作为原来的 worker_thread 的"替身"