fix!: Move browser constants to import.meta.env (#380)
BREAKING CHANGE: Renamed undocumented constants: - `__BROWSER__` → `import.meta.env.BROWSER` - `__COMMAND__` → `import.meta.env.COMMAND` - `__MANIFEST_VERSION__` → `import.meta.env.MANIFEST_VERSION` - `__IS_CHROME__` → `import.meta.env.CHROME` - `__IS_FIREFOX__` → `import.meta.env.FIREFOX` - `__IS_SAFARI__` → `import.meta.env.SAFARI` - `__IS_EDGE__` → `import.meta.env.EDGE` - `__IS_OPERA__` → `import.meta.env.OPERA`
This commit is contained in:
@@ -15,10 +15,12 @@ export class WxtLocationChangeEvent extends Event {
|
||||
* Returns an event name unique to the extension and content script that's running.
|
||||
*/
|
||||
export function getUniqueEventName(eventName: string): string {
|
||||
// During the build process, __ENTRYPOINT__ is not defined when importing entrypoints to get their
|
||||
// metadata.
|
||||
// During the build process, import.meta.env is not defined when importing
|
||||
// entrypoints to get their metadata.
|
||||
const entrypointName =
|
||||
typeof __ENTRYPOINT__ === 'undefined' ? 'build' : __ENTRYPOINT__;
|
||||
typeof import.meta.env === 'undefined'
|
||||
? 'build'
|
||||
: import.meta.env.ENTRYPOINT;
|
||||
|
||||
return `${browser.runtime.id}:${entrypointName}:${eventName}`;
|
||||
}
|
||||
|
||||
@@ -236,7 +236,9 @@ function mountUi(
|
||||
* Load the CSS for the current entrypoint.
|
||||
*/
|
||||
async function loadCss(): Promise<string> {
|
||||
const url = browser.runtime.getURL(`/content-scripts/${__ENTRYPOINT__}.css`);
|
||||
const url = browser.runtime.getURL(
|
||||
`/content-scripts/${import.meta.env.ENTRYPOINT}.css`,
|
||||
);
|
||||
try {
|
||||
const res = await fetch(url);
|
||||
return await res.text();
|
||||
|
||||
Reference in New Issue
Block a user