chore!: Remove deprecated APIs (#2488)
Co-authored-by: Gliches <nishumurmu017@gmail.com> Co-authored-by: Aaron <aaronklinker1@gmail.com>
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { defineProject } from 'vitest/config';
|
||||
import { WxtVitest } from 'wxt/testing';
|
||||
import { WxtVitest } from 'wxt/testing/vitest-plugin';
|
||||
|
||||
export default defineProject({
|
||||
test: {
|
||||
|
||||
@@ -28,7 +28,7 @@ describe('Auto Imports', () => {
|
||||
const defineContentScript: typeof import('wxt/utils/define-content-script').defineContentScript
|
||||
const defineUnlistedScript: typeof import('wxt/utils/define-unlisted-script').defineUnlistedScript
|
||||
const defineWxtPlugin: typeof import('wxt/utils/define-wxt-plugin').defineWxtPlugin
|
||||
const fakeBrowser: typeof import('wxt/testing').fakeBrowser
|
||||
const fakeBrowser: typeof import('wxt/testing/fake-browser').fakeBrowser
|
||||
const getAppConfig: typeof import('wxt/utils/app-config').getAppConfig
|
||||
const injectScript: typeof import('wxt/utils/inject-script').injectScript
|
||||
const storage: typeof import('wxt/utils/storage').storage
|
||||
@@ -124,7 +124,7 @@ describe('Auto Imports', () => {
|
||||
export { defineWxtPlugin } from 'wxt/utils/define-wxt-plugin';
|
||||
export { injectScript, ScriptPublicPath, InjectScriptOptions } from 'wxt/utils/inject-script';
|
||||
export { InvalidMatchPattern, MatchPattern } from 'wxt/utils/match-patterns';
|
||||
export { fakeBrowser } from 'wxt/testing';
|
||||
export { fakeBrowser } from 'wxt/testing/fake-browser';
|
||||
export { startOfDay } from '../utils/time';
|
||||
}
|
||||
"
|
||||
@@ -209,7 +209,7 @@ describe('Auto Imports', () => {
|
||||
export { defineWxtPlugin } from 'wxt/utils/define-wxt-plugin';
|
||||
export { injectScript, ScriptPublicPath, InjectScriptOptions } from 'wxt/utils/inject-script';
|
||||
export { InvalidMatchPattern, MatchPattern } from 'wxt/utils/match-patterns';
|
||||
export { fakeBrowser } from 'wxt/testing';
|
||||
export { fakeBrowser } from 'wxt/testing/fake-browser';
|
||||
}
|
||||
"
|
||||
`);
|
||||
|
||||
@@ -30,7 +30,7 @@ describe('Dev Mode', () => {
|
||||
);
|
||||
|
||||
const server = await project.startServer({
|
||||
runner: { disabled: true },
|
||||
webExt: { disabled: true },
|
||||
dev: { server: { port: 4400 } },
|
||||
});
|
||||
try {
|
||||
@@ -51,7 +51,7 @@ describe('Dev Mode', () => {
|
||||
);
|
||||
|
||||
const server = await project.startServer({
|
||||
runner: { disabled: true },
|
||||
webExt: { disabled: true },
|
||||
dev: { server: { port } },
|
||||
});
|
||||
try {
|
||||
@@ -76,7 +76,7 @@ describe('Dev Mode', () => {
|
||||
try {
|
||||
await expect(
|
||||
project.startServer({
|
||||
runner: { disabled: true },
|
||||
webExt: { disabled: true },
|
||||
dev: { server: { port, strictPort: true } },
|
||||
}),
|
||||
).rejects.toThrow();
|
||||
|
||||
@@ -196,10 +196,6 @@
|
||||
"types": "./dist/testing/wxt-vitest-plugin.d.mts",
|
||||
"default": "./dist/testing/wxt-vitest-plugin.mjs"
|
||||
},
|
||||
"./testing": {
|
||||
"types": "./dist/testing/index.d.mts",
|
||||
"default": "./dist/testing/index.mjs"
|
||||
},
|
||||
"./vite-builder-env": {
|
||||
"types": "./dist/vite-builder-env.d.ts"
|
||||
},
|
||||
|
||||
@@ -427,16 +427,16 @@ export function getRunnerProfileWatchIgnores(
|
||||
): string[] {
|
||||
const root = normalizePath(wxtConfig.root);
|
||||
const chromiumArgProfiles = extractPathArgs(
|
||||
wxtConfig.runnerConfig.config?.chromiumArgs,
|
||||
wxtConfig.webExt.config?.chromiumArgs,
|
||||
'--user-data-dir',
|
||||
);
|
||||
const firefoxArgProfiles = extractPathArgs(
|
||||
wxtConfig.runnerConfig.config?.firefoxArgs,
|
||||
wxtConfig.webExt.config?.firefoxArgs,
|
||||
'-profile',
|
||||
);
|
||||
const profiles = [
|
||||
wxtConfig.runnerConfig.config?.chromiumProfile,
|
||||
wxtConfig.runnerConfig.config?.firefoxProfile,
|
||||
wxtConfig.webExt.config?.chromiumProfile,
|
||||
wxtConfig.webExt.config?.firefoxProfile,
|
||||
...chromiumArgProfiles,
|
||||
...firefoxArgProfiles,
|
||||
].filter((profile): profile is string => typeof profile === 'string');
|
||||
|
||||
@@ -13,24 +13,7 @@ import { styleText } from 'node:util';
|
||||
*
|
||||
* @param config Optional config that will override your `<root>/wxt.config.ts`.
|
||||
*/
|
||||
export async function clean(config?: InlineConfig): Promise<void>;
|
||||
/**
|
||||
* Remove generated/temp files from the directory.
|
||||
*
|
||||
* @deprecated
|
||||
* @example
|
||||
* await clean();
|
||||
*
|
||||
* @param root The directory to look for generated/temp files in. Defaults to
|
||||
* `process.cwd()`. Can be relative to `process.cwd()` or absolute.
|
||||
*/
|
||||
export async function clean(root?: string): Promise<void>;
|
||||
|
||||
export async function clean(config?: string | InlineConfig) {
|
||||
if (typeof config === 'string') {
|
||||
config = { root: config };
|
||||
}
|
||||
|
||||
export async function clean(config?: InlineConfig): Promise<void> {
|
||||
await registerWxt('build', config);
|
||||
wxt.logger.info('Cleaning Project');
|
||||
|
||||
|
||||
@@ -125,8 +125,7 @@ async function createServerInternal(): Promise<WxtDevServer> {
|
||||
keyboardShortcuts.start();
|
||||
keyboardShortcuts.printHelp({
|
||||
canReopenBrowser:
|
||||
!wxt.config.runnerConfig.config.disabled &&
|
||||
!!wxt.config.runner.canOpen?.(),
|
||||
!wxt.config.webExt.config.disabled && !!wxt.config.runner.canOpen?.(),
|
||||
});
|
||||
},
|
||||
};
|
||||
@@ -169,8 +168,7 @@ async function createServerInternal(): Promise<WxtDevServer> {
|
||||
keyboardShortcuts.start();
|
||||
keyboardShortcuts.printHelp({
|
||||
canReopenBrowser:
|
||||
!wxt.config.runnerConfig.config.disabled &&
|
||||
!!wxt.config.runner.canOpen?.(),
|
||||
!wxt.config.webExt.config.disabled && !!wxt.config.runner.canOpen?.(),
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
@@ -1,14 +1,5 @@
|
||||
import consola from 'consola';
|
||||
import { WebExtConfig } from '../types';
|
||||
|
||||
/** @deprecated Use `defineWebExtConfig` instead. Same function, different name. */
|
||||
export function defineRunnerConfig(config: WebExtConfig): WebExtConfig {
|
||||
consola.warn(
|
||||
'`defineRunnerConfig` is deprecated, use `defineWebExtConfig` instead. See https://wxt.dev/guide/resources/upgrading.html#v0-19-0-rarr-v0-20-0',
|
||||
);
|
||||
return defineWebExtConfig(config);
|
||||
}
|
||||
|
||||
/**
|
||||
* Configure how [`web-ext`](https://github.com/mozilla/web-ext) starts the
|
||||
* browser during development.
|
||||
|
||||
@@ -124,19 +124,13 @@ export async function resolveConfig(
|
||||
|
||||
const outDir = path.resolve(outBaseDir, outDirTemplate);
|
||||
const reloadCommand = mergedConfig.dev?.reloadCommand ?? 'Alt+R';
|
||||
|
||||
if (inlineConfig.runner != null || userConfig.runner != null) {
|
||||
logger.warn(
|
||||
'`InlineConfig#runner` is deprecated, use `InlineConfig#webExt` instead. See https://wxt.dev/guide/resources/upgrading.html#v0-19-0-rarr-v0-20-0',
|
||||
);
|
||||
}
|
||||
const webExt = await loadConfig<WebExtConfig>({
|
||||
name: 'web-ext',
|
||||
cwd: root,
|
||||
globalRc: true,
|
||||
rcFile: '.webextrc',
|
||||
overrides: inlineConfig.webExt ?? inlineConfig.runner,
|
||||
defaults: userConfig.webExt ?? userConfig.runner,
|
||||
overrides: inlineConfig.webExt,
|
||||
defaults: userConfig.webExt,
|
||||
});
|
||||
// Make sure alias are absolute
|
||||
const alias = Object.fromEntries(
|
||||
@@ -151,20 +145,9 @@ export async function resolveConfig(
|
||||
|
||||
let devServerConfig: ResolvedConfig['dev']['server'];
|
||||
if (command === 'serve') {
|
||||
if (mergedConfig.dev?.server?.hostname)
|
||||
logger.warn(
|
||||
`The 'hostname' option is deprecated, please use 'host' or 'origin' depending on your circumstances.`,
|
||||
);
|
||||
|
||||
const host =
|
||||
mergedConfig.dev?.server?.host ??
|
||||
mergedConfig.dev?.server?.hostname ??
|
||||
'localhost';
|
||||
const host = mergedConfig.dev?.server?.host ?? 'localhost';
|
||||
let port = mergedConfig.dev?.server?.port;
|
||||
const origin =
|
||||
mergedConfig.dev?.server?.origin ??
|
||||
mergedConfig.dev?.server?.hostname ??
|
||||
'localhost';
|
||||
const origin = mergedConfig.dev?.server?.origin ?? 'localhost';
|
||||
const strictPort = mergedConfig.dev?.server?.strictPort ?? false;
|
||||
if (port == null || !isFinite(port)) {
|
||||
port = await getPort({
|
||||
@@ -230,7 +213,6 @@ export async function resolveConfig(
|
||||
publicDir,
|
||||
wxtModuleDir,
|
||||
root,
|
||||
runnerConfig: webExt,
|
||||
webExt,
|
||||
runner:
|
||||
command === 'serve'
|
||||
@@ -390,7 +372,7 @@ async function getUnimportOptions(
|
||||
];
|
||||
|
||||
const defaultOptions: WxtResolvedUnimportOptions = {
|
||||
imports: [{ name: 'fakeBrowser', from: 'wxt/testing' }],
|
||||
imports: [{ name: 'fakeBrowser', from: 'wxt/testing/fake-browser' }],
|
||||
presets: [
|
||||
{
|
||||
from: 'wxt/browser',
|
||||
|
||||
@@ -103,7 +103,7 @@ describe('Detect Dev Changes', () => {
|
||||
const runnerFile = '/root/web-ext.config.ts';
|
||||
setFakeWxt({
|
||||
config: {
|
||||
runnerConfig: {
|
||||
webExt: {
|
||||
configFile: runnerFile,
|
||||
},
|
||||
},
|
||||
|
||||
@@ -63,7 +63,7 @@ export function detectDevChanges(
|
||||
|
||||
const isRunnerChange = some(
|
||||
relevantChangedFiles,
|
||||
(file) => file === wxt.config.runnerConfig.configFile,
|
||||
(file) => file === wxt.config.webExt.configFile,
|
||||
);
|
||||
if (isRunnerChange) return { type: 'browser-restart' };
|
||||
|
||||
@@ -146,7 +146,7 @@ export function getRelevantDevChangedFiles(
|
||||
return Array.from(new Set(changedFiles)).filter((changedFile) => {
|
||||
if (changedFile === wxt.config.userConfigMetadata.configFile) return true;
|
||||
if (changedFile.startsWith(wxt.config.modulesDir)) return true;
|
||||
if (changedFile === wxt.config.runnerConfig.configFile) return true;
|
||||
if (changedFile === wxt.config.webExt.configFile) return true;
|
||||
if (changedFile.startsWith(wxt.config.publicDir)) return true;
|
||||
return findEffectedSteps(changedFile, currentOutput).length > 0;
|
||||
});
|
||||
|
||||
@@ -264,9 +264,6 @@ export const fakeResolvedConfig = fakeObjectCreator<ResolvedConfig>(() => {
|
||||
publicDir: fakeDir(),
|
||||
root: fakeDir(),
|
||||
wxtModuleDir: fakeDir(),
|
||||
runnerConfig: {
|
||||
config: {},
|
||||
},
|
||||
webExt: {
|
||||
config: {},
|
||||
},
|
||||
|
||||
@@ -22,7 +22,7 @@ export function withTimeout<T>(
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Don't use in production, just for testing and slowing things
|
||||
* @internal Don't use in production, just for testing and slowing things
|
||||
* down.
|
||||
*/
|
||||
export function sleep(ms: number): Promise<void> {
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
/**
|
||||
* Utilities for unit testing WXT extensions.
|
||||
*
|
||||
* @module wxt/testing
|
||||
* @deprecated Use `wxt/testing/*` instead to prevent issues with JSDOM or
|
||||
* HappyDOM environments. Will be removed in the next major version of WXT.
|
||||
*/
|
||||
export * from './fake-browser';
|
||||
export * from './wxt-vitest-plugin';
|
||||
@@ -2,7 +2,7 @@
|
||||
* Contains a Vitest plugin that configures your test environment to work with
|
||||
* WXT projects.
|
||||
*
|
||||
* @module wxt/testing/vitest
|
||||
* @module wxt/testing/vitest-plugin
|
||||
*/
|
||||
|
||||
import type * as vite from 'vite';
|
||||
|
||||
@@ -184,8 +184,6 @@ export interface InlineConfig {
|
||||
* `web-ext.config.ts` file.
|
||||
*/
|
||||
webExt?: WebExtConfig;
|
||||
/** @deprecated Use `webExt` instead. Same option, just renamed. */
|
||||
runner?: WebExtConfig;
|
||||
zip?: {
|
||||
/**
|
||||
* Configure the filename output when zipping files.
|
||||
@@ -416,13 +414,6 @@ export interface InlineConfig {
|
||||
* @default false
|
||||
*/
|
||||
strictPort?: boolean;
|
||||
/**
|
||||
* Hostname to run the dev server on.
|
||||
*
|
||||
* @deprecated Use `host` to specify the interface to bind to, or use
|
||||
* `origin` to specify the dev server hostname.
|
||||
*/
|
||||
hostname?: string;
|
||||
};
|
||||
/**
|
||||
* Controls whether a custom keyboard shortcut command, `Alt+R`, is added
|
||||
@@ -1142,9 +1133,6 @@ export interface ConfigEnv {
|
||||
|
||||
export type WxtCommand = 'build' | 'serve';
|
||||
|
||||
/** @deprecated Use `WebExtConfig` instead. */
|
||||
export type ExtensionRunnerConfig = WebExtConfig;
|
||||
|
||||
/**
|
||||
* Options for how [`web-ext`](https://github.com/mozilla/web-ext) starts the
|
||||
* browser.
|
||||
@@ -1537,8 +1525,6 @@ export interface ResolvedConfig {
|
||||
imports: WxtResolvedUnimportOptions;
|
||||
manifest: UserManifest;
|
||||
fsCache: FsCache;
|
||||
/** @deprecated - Use {@link webExt} instead. */
|
||||
runnerConfig: C12ResolvedConfig<WebExtConfig>;
|
||||
webExt: C12ResolvedConfig<WebExtConfig>;
|
||||
runner: ExtensionRunner;
|
||||
zip: {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { fakeBrowser } from 'wxt/testing';
|
||||
import { fakeBrowser } from 'wxt/testing/fake-browser';
|
||||
|
||||
export const browser = fakeBrowser;
|
||||
export default fakeBrowser;
|
||||
|
||||
@@ -22,7 +22,10 @@ export default defineConfig({
|
||||
plugins: [RandomSeed({ define: 'import.meta.env.TEST_SEED' })],
|
||||
resolve: {
|
||||
alias: {
|
||||
'wxt/testing': path.resolve('src/testing'),
|
||||
'wxt/testing/fake-browser': path.resolve('src/testing/fake-browser.ts'),
|
||||
'wxt/testing/vitest-plugin': path.resolve(
|
||||
'src/testing/wxt-vitest-plugin.ts',
|
||||
),
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user