Skip to content

fix: use target from webExtConfig if browser option is undefined#232

Merged
aklinker1 merged 4 commits into
aklinker1:mainfrom
aleclarson:fix/webextconfig-target
Dec 31, 2024
Merged

fix: use target from webExtConfig if browser option is undefined#232
aklinker1 merged 4 commits into
aklinker1:mainfrom
aleclarson:fix/webextconfig-target

Conversation

@aleclarson
Copy link
Copy Markdown
Contributor

Based on #231 so merge that first.

If the browser plugin option is undefined, check the webExtConfig.target option before defaulting to chromium.

: "chromium";
pluginOptions.browser === "chrome"
? "chromium"
: pluginOptions.browser === null ||
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I wonder if we should deprecate the browser: null setting. It's a bit cryptic 😅

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Huh, yeah, wonder what I was thinking lol. Let's leave it for now.

* @default "chrome"
*/
browser?: string;
browser?: 'chrome' | 'firefox' | null;
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

This should remain a string. You can target more than just chrome or firefox. Safari, opera, etc.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Oops! That's strictly for the manifest templating? I don't see any handling for Safari and others in createWebExtRunner, hence the assumption. 😄

Comment thread packages/vite-plugin-web-extension/src/options.ts Outdated
* @default "chrome"
*/
browser?: string;
browser?: 'chrome' | 'firefox' | (string & {}) | null;
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

this is a TypeScript trick that provides auto-completion for some values while still allowing any string

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Interesting, didn't know this worked... I've only used branded types with a property inside the {}. I've always had to use a function overload to get this behavior before, very good to know!

@aklinker1 aklinker1 merged commit 6623b0c into aklinker1:main Dec 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants