-
-
Notifications
You must be signed in to change notification settings - Fork 93
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix main world extension not working
- Loading branch information
1 parent
65b64c8
commit f273416
Showing
14 changed files
with
107 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 0 additions & 63 deletions
63
programs/develop/webpack/plugin-extension/feature-scripts/steps/add-dynamic-public-path.ts
This file was deleted.
Oops, something went wrong.
44 changes: 44 additions & 0 deletions
44
.../develop/webpack/plugin-extension/feature-scripts/steps/add-public-path-for-main-world.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import type webpack from 'webpack' | ||
import { | ||
type FilepathList, | ||
type PluginInterface, | ||
type Manifest | ||
} from '../../../webpack-types' | ||
import * as messages from '../../../lib/messages' | ||
import {DevOptions} from '../../../../module' | ||
|
||
export class AddPublicPathForMainWorld { | ||
public readonly manifestPath: string | ||
public readonly browser: DevOptions['browser'] | ||
public readonly includeList: FilepathList | ||
public readonly excludeList: FilepathList | ||
|
||
constructor(options: PluginInterface) { | ||
this.manifestPath = options.manifestPath | ||
this.browser = options.browser || 'chrome' | ||
this.includeList = options.includeList || {} | ||
this.excludeList = options.excludeList || {} | ||
} | ||
|
||
public apply(compiler: webpack.Compiler): void { | ||
const manifest: Manifest = require(this.manifestPath) | ||
if ( | ||
manifest.content_scripts?.some( | ||
// @ts-expect-error - TS doesn't know about content_scripts | ||
(cs) => cs.world && cs.world.toLowerCase() === 'main' | ||
) | ||
) { | ||
if (!manifest.id) { | ||
console.error(messages.noExtensionIdError(manifest.name || '')) | ||
process.exit(1) | ||
} | ||
|
||
if (this.browser === 'firefox') { | ||
compiler.options.output.publicPath = `moz-extension://${manifest.id}/` | ||
return | ||
} | ||
|
||
compiler.options.output.publicPath = `${this.browser}-extension://${manifest.id}/` | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters