Skip to content

Commit

Permalink
Rename things
Browse files Browse the repository at this point in the history
  • Loading branch information
aklinker1 committed Nov 16, 2024
1 parent 7c693e8 commit 960ef39
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 174 deletions.
14 changes: 7 additions & 7 deletions docs/guide/essentials/config/browser-startup.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ outline: deep

# Browser Startup

> See the [API Reference](/api/reference/wxt/interfaces/ExtensionRunnerConfig) for a full list of config.
> See the [API Reference](/api/reference/wxt/interfaces/WebExtRunnerConfig) for a full list of config.
During development WXT uses [`web-ext` by Mozilla](https://www.npmjs.com/package/web-ext) to automatically open a browser window with your extension installed.

Expand All @@ -15,9 +15,9 @@ You can configure browser startup in 3 places:
1. `<rootDir>/web-ext.config.ts`: Ignored from version control, this file lets you configure your own options for a specific project without affecting other developers

```ts
import { defineRunnerConfig } from 'wxt';
import { defineWebExtConfig } from 'wxt';

export default defineRunnerConfig({
export default defineWebExtConfig({
// ...
});
```
Expand All @@ -32,7 +32,7 @@ You can configure browser startup in 3 places:
To set or customize the browser opened during development:

```ts
export default defineRunnerConfig({
export default defineWebExtConfig({
binaries: {
chrome: '/path/to/chrome-beta', // Use Chrome Beta instead of regular Chrome
firefox: 'firefoxdeveloperedition', // Use Firefox Developer Edition instead of regular Firefox
Expand All @@ -52,15 +52,15 @@ To persist data, set the `--user-data-dir` flag:
:::code-group

```ts [Mac/Linux]
export default defineRunnerConfig({
export default defineWebExtConfig({
chromiumArgs: ['--user-data-dir=./.wxt/chrome-data'],
});
```

```ts [Windows]
import { resolve } from 'node:path';
export default defineRunnerConfig({
export default defineWebExtConfig({
// On Windows, the path must be absolute
chromiumArgs: [`--user-data-dir="${resolve(".wxt/chrome-data")}"`
});
Expand All @@ -79,7 +79,7 @@ You can use any directory you'd like for `--user-data-dir`, the examples above c
If you prefer to load the extension into your browser manually, you can disable the auto-open behavior:

```ts
export default defineRunnerConfig({
export default defineWebExtConfig({
disabled: true,
});
```
2 changes: 1 addition & 1 deletion packages/wxt/e2e/tests/hooks.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ describe('Hooks', () => {

const server = await project.startServer({
hooks,
runner: {
webExtRunner: {
disabled: true,
},
});
Expand Down
4 changes: 0 additions & 4 deletions packages/wxt/src/builtin-modules/index.ts

This file was deleted.

150 changes: 0 additions & 150 deletions packages/wxt/src/builtin-modules/unimport.ts

This file was deleted.

22 changes: 19 additions & 3 deletions packages/wxt/src/core/define-runner-config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,23 @@
import { ExtensionRunnerConfig } from '../types';
import consola from 'consola';
import { WebExtRunnerConfig } from '../types';

/**
* @deprecated Use `defineWebExtConfig` instead. Same function, different name.
*/
export function defineRunnerConfig(
config: ExtensionRunnerConfig,
): ExtensionRunnerConfig {
config: WebExtRunnerConfig,
): WebExtRunnerConfig {
consola.warn(
'defineRunnerConfig is deprecated, replace it with defineWebExtConfig',
);
return config;
}

/**
* Configure how [`web-ext`](https://github.com/mozilla/web-ext) starts the browser during development.
*/
export function defineWebExtConfig(
config: WebExtRunnerConfig,
): WebExtRunnerConfig {
return config;
}
8 changes: 4 additions & 4 deletions packages/wxt/src/core/resolve-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
ConfigEnv,
UserManifestFn,
UserManifest,
ExtensionRunnerConfig,
WebExtRunnerConfig,
WxtResolvedUnimportOptions,
Logger,
WxtCommand,
Expand Down Expand Up @@ -115,13 +115,13 @@ export async function resolveConfig(
const outDir = path.resolve(outBaseDir, outDirTemplate);
const reloadCommand = mergedConfig.dev?.reloadCommand ?? 'Alt+R';

const runnerConfig = await loadConfig<ExtensionRunnerConfig>({
const runnerConfig = await loadConfig<WebExtRunnerConfig>({
name: 'web-ext',
cwd: root,
globalRc: true,
rcFile: '.webextrc',
overrides: inlineConfig.runner,
defaults: userConfig.runner,
overrides: inlineConfig.webExtRunner ?? inlineConfig.runner,
defaults: userConfig.webExtRunner ?? userConfig.runner,
});
// Make sure alias are absolute
const alias = Object.fromEntries(
Expand Down
14 changes: 9 additions & 5 deletions packages/wxt/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,13 @@ export interface InlineConfig {
*/
manifest?: UserManifest | Promise<UserManifest> | UserManifestFn;
/**
* Custom runner options. Options set here can be overridden in a `web-ext.config.ts` file.
* Configure browser startup. Option set here can be overridden in a `web-ext.config.ts` file.
*/
runner?: ExtensionRunnerConfig;
webExtRunner?: WebExtRunnerConfig;
/**
* @deprecated Use `webExtRunner` instead.
*/
runner?: WebExtRunnerConfig;
zip?: {
/**
* Configure the filename output when zipping files.
Expand Down Expand Up @@ -908,9 +912,9 @@ export interface ConfigEnv {
export type WxtCommand = 'build' | 'serve';

/**
* Configure how the browser starts up.
* Options for how [`web-ext`](https://github.com/mozilla/web-ext) starts the browser.
*/
export interface ExtensionRunnerConfig {
export interface WebExtRunnerConfig {
/**
* Whether or not to open the browser with the extension installed in dev mode.
*
Expand Down Expand Up @@ -1272,7 +1276,7 @@ export interface ResolvedConfig {
imports: false | WxtResolvedUnimportOptions;
manifest: UserManifest;
fsCache: FsCache;
runnerConfig: C12ResolvedConfig<ExtensionRunnerConfig>;
runnerConfig: C12ResolvedConfig<WebExtRunnerConfig>;
zip: {
name?: string;
artifactTemplate: string;
Expand Down

0 comments on commit 960ef39

Please sign in to comment.