1fb1b75216
* Ensure all modules are identified * Extend a webpack Plugin Co-Authored-By: Timer <timer150@gmail.com>
22 lines
594 B
TypeScript
22 lines
594 B
TypeScript
import { Compiler, Plugin } from 'webpack'
|
|
|
|
export class AllModulesIdentifiedPlugin implements Plugin {
|
|
apply(compiler: Compiler) {
|
|
compiler.hooks.compilation.tap(
|
|
'AllModulesIdentifiedPlugin',
|
|
compilation => {
|
|
compilation.hooks.beforeModuleIds.tap(
|
|
'AllModulesIdentifiedPlugin',
|
|
modules => {
|
|
;(modules as any[]).forEach(module => {
|
|
if (module.id != null || !module.identifier) {
|
|
return
|
|
}
|
|
module.id = module.identifier()
|
|
})
|
|
}
|
|
)
|
|
}
|
|
)
|
|
}
|
|
}
|