Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/browser/src/gen/index.d.ts
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Revert this file, it will be overwritten next time the @types/chrome package changes. Make the change to that package instead of here.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

85 changes: 85 additions & 0 deletions packages/wxt/src/core/utils/__tests__/manifest.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1625,6 +1625,91 @@ describe('Manifest Utils', () => {
);
});
});

describe('author field handling', () => {
it('should convert author object with email to string', async () => {
setFakeWxt({
config: {
outDir,
manifestVersion: 3,
manifest: {
author: { email: '[email protected]' },
},
},
});
const buildOutput = fakeBuildOutput();

const { manifest: actual } = await generateManifest([], buildOutput);

expect(actual.author).toBe('[email protected]');
});

it('should handle author object without email property', async () => {
setFakeWxt({
config: {
outDir,
manifestVersion: 3,
manifest: {
author: {} as any,
},
},
});
const buildOutput = fakeBuildOutput();

const { manifest: actual } = await generateManifest([], buildOutput);

expect(actual.author).toBe('');
});

it('should preserve author when already a string', async () => {
setFakeWxt({
config: {
outDir,
manifestVersion: 3,
manifest: {
author: 'John Doe',
},
},
});
const buildOutput = fakeBuildOutput();

const { manifest: actual } = await generateManifest([], buildOutput);

expect(actual.author).toBe('John Doe');
});

it('should handle undefined author', async () => {
setFakeWxt({
config: {
outDir,
manifestVersion: 3,
manifest: {},
},
});
const buildOutput = fakeBuildOutput();

const { manifest: actual } = await generateManifest([], buildOutput);

expect(actual.author).toBeUndefined();
});

it('should handle null author', async () => {
setFakeWxt({
config: {
outDir,
manifestVersion: 3,
manifest: {
author: null as any,
},
},
});
const buildOutput = fakeBuildOutput();

const { manifest: actual } = await generateManifest([], buildOutput);

expect(actual.author).toBeUndefined();
});
});
});

describe('stripPathFromMatchPattern', () => {
Expand Down
10 changes: 9 additions & 1 deletion packages/wxt/src/core/utils/manifest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,15 @@ export async function generateManifest(
short_name: pkg?.shortName,
icons: discoverIcons(buildOutput),
};
const userManifest = wxt.config.manifest;
const userManifest = { ...wxt.config.manifest };

if (typeof userManifest.author === 'object' && userManifest.author !== null) {
wxt.logger.warn(
'manifest.author should be a string, not an object. Chromium browsers ignore this field, and Gecko-based (firefox based) only uses it for display.\nUpdate your config to: author: "Your Name"',
);
userManifest.author = userManifest.author.email ?? '';
}

if (userManifest.manifest_version) {
delete userManifest.manifest_version;
wxt.logger.warn(
Expand Down