@@ -15,25 +15,26 @@ module.exports = class WebExtensionServiceWorkerEntryPlugin {
1515 const { javascript, sources } = compiler . webpack
1616 const entry = this . options . serviceWorkerEntry
1717 if ( entry === undefined ) return
18- const hook = compiler . hooks . entryOption
19- // Set chunkLoading to import-scripts
20- // @ts -ignore DO NOT add return boolean to this function, this is a BailHook and we don't want to bail.
21- hook . tap ( WebExtensionServiceWorkerEntryPlugin . name , ( context , entries ) => {
22- if ( typeof entries === 'function' ) {
23- if ( this . options . noDynamicEntryWarning ) return
24- console . warn ( `[webpack-extension-target] Dynamic entry points not supported yet.
18+ if ( ! ( compiler . options . output . module || compiler . options . experiments . outputModule ) ) {
19+ const hook = compiler . hooks . entryOption
20+ // Set chunkLoading to import-scripts
21+ hook . tap ( WebExtensionServiceWorkerEntryPlugin . name , ( context , entries ) => {
22+ if ( typeof entries === 'function' ) {
23+ if ( this . options . noDynamicEntryWarning ) return
24+ console . warn ( `[webpack-extension-target] Dynamic entry points not supported yet.
2525You must manually set the chuck loading of entry point ${ entry } to "import-scripts".
2626
2727See https://webpack.js.org/configuration/entry-context/#entry-descriptor
2828
2929Set background.noDynamicEntryWarning to true to disable this warning.
3030` )
31- }
32- /** @type {import('@rspack/core').EntryDescriptionNormalized } */
33- const selectedEntry = /** @type {any } */ ( entries ) [ entry ]
34- if ( ! selectedEntry ) throw new Error ( `[webpack-extension-target] There is no entry called ${ entry } .` )
35- selectedEntry . chunkLoading = 'import-scripts'
36- } )
31+ }
32+ /** @type {import('@rspack/core').EntryDescriptionNormalized } */
33+ const selectedEntry = /** @type {any } */ ( entries ) [ entry ]
34+ if ( ! selectedEntry ) throw new Error ( `[webpack-extension-target] There is no entry called ${ entry } .` )
35+ selectedEntry . chunkLoading = 'import-scripts'
36+ } )
37+ }
3738
3839 // Set all lazy chunks to eagerly loaded
3940 // See https://bugs.chromium.org/p/chromium/issues/detail?id=1198822
0 commit comments