feat!: Rename defineBackgroundScript to defineBackground

BREAKING CHANGE: Rename `defineBackgroundScript` to `defineBackground`. Update your background entrypoints
This commit is contained in:
Aaron Klinker
2023-07-14 20:03:12 -05:00
parent c1ea9ba4a3
commit 5b48ae99f4
10 changed files with 14 additions and 16 deletions
+1 -1
View File
@@ -1,4 +1,4 @@
export default defineBackgroundScript(() => {
export default defineBackground(() => {
console.log(browser.runtime.id);
logId();
console.log({
+2 -2
View File
@@ -6,7 +6,7 @@ describe('Auto Imports', () => {
const project = new TestProject();
project.addFile(
'entrypoints/background.ts',
'export default defineBackgroundScript(() => {})',
'export default defineBackground(() => {})',
);
project.addFile(
'entrypoints/overlay.content.ts',
@@ -43,7 +43,7 @@ describe('Auto Imports', () => {
export {}
declare global {
const browser: typeof import('webextension-polyfill')
const defineBackgroundScript: typeof import('wxt/client')['defineBackgroundScript']
const defineBackground: typeof import('wxt/client')['defineBackground']
const defineConfig: typeof import('wxt')['defineConfig']
const defineContentScript: typeof import('wxt/client')['defineContentScript']
const mountContentScriptUi: typeof import('wxt/client')['mountContentScriptUi']
+1 -1
View File
@@ -97,7 +97,7 @@ describe('Manifest Content', () => {
describe('background', () => {
const backgroundContent = `
export default defineBackgroundScript({
export default defineBackground({
persistent: true,
type: "module",
main: () => {},
+2 -2
View File
@@ -11,7 +11,7 @@ describe('User Config', () => {
});
project.addFile(
'src/entrypoints/background.ts',
`export default defineBackgroundScript(
`export default defineBackground(
() => console.log('Hello background'),
);`,
);
@@ -38,7 +38,7 @@ describe('User Config', () => {
});
project.addFile(
'entries/background.ts',
`export default defineBackgroundScript(() => console.log('Hello background'));`,
`export default defineBackground(() => console.log('Hello background'));`,
);
await project.build();
@@ -1,12 +1,10 @@
import { BackgroundScriptDefintition } from '..';
export function defineBackgroundScript(
main: () => void,
): BackgroundScriptDefintition;
export function defineBackgroundScript(
export function defineBackground(main: () => void): BackgroundScriptDefintition;
export function defineBackground(
definition: BackgroundScriptDefintition,
): BackgroundScriptDefintition;
export function defineBackgroundScript(
export function defineBackground(
arg: (() => void) | BackgroundScriptDefintition,
): BackgroundScriptDefintition {
if (typeof arg === 'function') return { main: arg };
+1 -1
View File
@@ -1,3 +1,3 @@
export * from './defineContentScript';
export * from './defineBackgroundScript';
export * from './defineBackground';
export * from './mountContentScriptUi';
+1 -1
View File
@@ -1,3 +1,3 @@
export default defineBackgroundScript(() => {
export default defineBackground(() => {
console.log('Hello background!', { id: browser.runtime.id });
});
@@ -1,3 +1,3 @@
export default defineBackgroundScript(() => {
export default defineBackground(() => {
console.log('Hello background!', { id: browser.runtime.id });
});
+1 -1
View File
@@ -1,3 +1,3 @@
export default defineBackgroundScript(() => {
export default defineBackground(() => {
console.log('Hello background!', { id: browser.runtime.id });
});
+1 -1
View File
@@ -1,3 +1,3 @@
export default defineBackgroundScript(() => {
export default defineBackground(() => {
console.log('Hello background!', { id: browser.runtime.id });
});