| 630 | : {}), |
| 631 | |
| 632 | generateBundle(opts, bundle) { |
| 633 | // to avoid emitting duplicate assets for modern build and legacy build |
| 634 | if ( |
| 635 | this.environment.config.isOutputOptionsForLegacyChunks?.(opts) || |
| 636 | isWorker |
| 637 | ) { |
| 638 | return |
| 639 | } |
| 640 | for (const asset of workerOutputCaches.get(config)!.getAssets()) { |
| 641 | if (emittedAssets.has(asset.fileName)) continue |
| 642 | emittedAssets.add(asset.fileName) |
| 643 | |
| 644 | const duplicateAsset = bundle[asset.fileName] |
| 645 | if (duplicateAsset) { |
| 646 | const content = |
| 647 | duplicateAsset.type === 'asset' |
| 648 | ? duplicateAsset.source |
| 649 | : duplicateAsset.code |
| 650 | // don't emit if the file name and the content is same |
| 651 | if (isSameContent(content, asset.source)) { |
| 652 | continue |
| 653 | } |
| 654 | } |
| 655 | |
| 656 | this.emitFile({ |
| 657 | type: 'asset', |
| 658 | fileName: asset.fileName, |
| 659 | source: asset.source, |
| 660 | // NOTE: fileName is already generated when bundling the worker |
| 661 | // so no need to pass originalFileNames/names |
| 662 | }) |
| 663 | } |
| 664 | }, |
| 665 | |
| 666 | watchChange(file) { |
| 667 | if (isWorker) return |