-
-
Notifications
You must be signed in to change notification settings - Fork 256
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat!: ESM background support (#398)
BREAKING CHANGE: The build output has changed slightly. This isn't a huge deal, and no steps are required for users unless you're doing something weird with the output files after a build. Before: ``` .output/ <target>/ chunks/ popup-<hash>.js popup.html ``` After: ``` .output/ <target>/ popup.html popup.js ``` This applies for all HTML files, not just the popup.
- Loading branch information
Showing
8 changed files
with
340 additions
and
81 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,41 @@ | ||
import messages from 'public/_locales/en/messages.json'; | ||
|
||
export default defineBackground(() => { | ||
console.log(browser.runtime.id); | ||
logId(); | ||
console.log({ | ||
browser: import.meta.env.BROWSER, | ||
chrome: import.meta.env.CHROME, | ||
firefox: import.meta.env.FIREFOX, | ||
manifestVersion: import.meta.env.MANIFEST_VERSION, | ||
messages, | ||
}); | ||
export default defineBackground({ | ||
// type: 'module', | ||
|
||
// @ts-expect-error: should only accept entrypoints or public assets | ||
browser.runtime.getURL('/'); | ||
browser.runtime.getURL('/background.js'); | ||
browser.runtime.getURL('/icon/128.png'); | ||
browser.runtime.getURL('/example.html#hash'); | ||
browser.runtime.getURL('/example.html?query=param'); | ||
// @ts-expect-error: should only allow hashes/query params on HTML files | ||
browser.runtime.getURL('/icon-128.png?query=param'); | ||
main() { | ||
console.log(browser.runtime.id); | ||
logId(); | ||
console.log({ | ||
browser: import.meta.env.BROWSER, | ||
chrome: import.meta.env.CHROME, | ||
firefox: import.meta.env.FIREFOX, | ||
manifestVersion: import.meta.env.MANIFEST_VERSION, | ||
messages, | ||
}); | ||
|
||
// @ts-expect-error: should only accept known message names | ||
browser.i18n.getMessage('test'); | ||
browser.i18n.getMessage('prompt_for_name'); | ||
browser.i18n.getMessage('hello', 'Aaron'); | ||
browser.i18n.getMessage('bye', ['Aaron']); | ||
browser.i18n.getMessage('@@extension_id'); | ||
// @ts-expect-error: should only accept entrypoints or public assets | ||
browser.runtime.getURL('/'); | ||
browser.runtime.getURL('/background.js'); | ||
browser.runtime.getURL('/icon/128.png'); | ||
browser.runtime.getURL('/example.html#hash'); | ||
browser.runtime.getURL('/example.html?query=param'); | ||
// @ts-expect-error: should only allow hashes/query params on HTML files | ||
browser.runtime.getURL('/icon-128.png?query=param'); | ||
|
||
console.log('WXT MODE:', { | ||
MODE: import.meta.env.MODE, | ||
DEV: import.meta.env.DEV, | ||
PROD: import.meta.env.PROD, | ||
}); | ||
// @ts-expect-error: should only accept known message names | ||
browser.i18n.getMessage('test'); | ||
browser.i18n.getMessage('prompt_for_name'); | ||
browser.i18n.getMessage('hello', 'Aaron'); | ||
browser.i18n.getMessage('bye', ['Aaron']); | ||
browser.i18n.getMessage('@@extension_id'); | ||
|
||
storage.setItem('session:startTime', Date.now()); | ||
console.log('WXT MODE:', { | ||
MODE: import.meta.env.MODE, | ||
DEV: import.meta.env.DEV, | ||
PROD: import.meta.env.PROD, | ||
}); | ||
|
||
storage.setItem('session:startTime', Date.now()); | ||
}, | ||
}); |
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
Oops, something went wrong.