diff --git a/packages/wxt/package.json b/packages/wxt/package.json index 29f1ac72..b8f13fca 100644 --- a/packages/wxt/package.json +++ b/packages/wxt/package.json @@ -100,7 +100,7 @@ "fast-glob": "^3.3.2", "filesize": "^10.1.6", "fs-extra": "^11.2.0", - "get-port": "^7.1.0", + "get-port-please": "^3.1.2", "giget": "^1.2.3", "hookable": "^5.5.3", "is-wsl": "^3.1.0", diff --git a/packages/wxt/src/core/create-server.ts b/packages/wxt/src/core/create-server.ts index 190b1ccf..24f9258a 100644 --- a/packages/wxt/src/core/create-server.ts +++ b/packages/wxt/src/core/create-server.ts @@ -28,6 +28,7 @@ import { getContentScriptJs, mapWxtOptionsToRegisteredContentScript, } from './utils/content-scripts'; +import { sleep } from './utils/time'; /** * Creates a dev server and pre-builds all the files that need to exist before loading the extension. @@ -119,6 +120,7 @@ async function createServerInternal( }, async restart() { await server.stop(); + await sleep(5000); await server.start(); }, transformHtml(url, html, originalUrl) { diff --git a/packages/wxt/src/core/resolve-config.ts b/packages/wxt/src/core/resolve-config.ts index cb6f40cb..6fad0fa9 100644 --- a/packages/wxt/src/core/resolve-config.ts +++ b/packages/wxt/src/core/resolve-config.ts @@ -27,6 +27,7 @@ import { builtinModules } from '../builtin-modules'; import { getEslintVersion } from './utils/eslint'; import { safeStringToNumber } from './utils/number'; import { loadEnv } from './utils/env'; +import { getPort } from 'get-port-please'; /** * Given an inline config, discover the config file if necessary, merge the results, resolve any @@ -139,8 +140,7 @@ export async function resolveConfig( if (command === 'serve') { let port = mergedConfig.dev?.server?.port; if (port == null || !isFinite(port)) { - const { default: getPort, portNumbers } = await import('get-port'); - port = await getPort({ port: portNumbers(3000, 3010) }); + port = await getPort({ portRange: [3000, 3010] }); } devServerConfig = { port, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index c5884d35..dba7fa42 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -329,7 +329,7 @@ importers: dependencies: '@aklinker1/rollup-plugin-visualizer': specifier: 5.12.0 - version: 5.12.0(rollup@4.24.0) + version: 5.12.0(rollup@3.29.4) '@types/chrome': specifier: ^0.0.280 version: 0.0.280 @@ -384,9 +384,9 @@ importers: fs-extra: specifier: ^11.2.0 version: 11.2.0 - get-port: - specifier: ^7.1.0 - version: 7.1.0 + get-port-please: + specifier: ^3.1.2 + version: 3.1.2 giget: specifier: ^1.2.3 version: 1.2.3 @@ -449,7 +449,7 @@ importers: version: 1.3.0 unimport: specifier: ^3.13.1 - version: 3.13.1(rollup@4.24.0)(webpack-sources@3.2.3) + version: 3.13.1(rollup@3.29.4)(webpack-sources@3.2.3) vite: specifier: ^5.4.11 version: 5.4.11(@types/node@20.17.6)(sass@1.80.7) @@ -3006,9 +3006,8 @@ packages: get-func-name@2.0.2: resolution: {integrity: sha512-8vXOvuE167CtIc3OyItco7N/dpRtBbYOsPsXCz7X/PMnlGjYjSGuZJgM1Y7mmew7BKf9BqvLX2tnOVy1BBUsxQ==} - get-port@7.1.0: - resolution: {integrity: sha512-QB9NKEeDg3xxVwCCwJQ9+xycaz6pBB6iQ76wiWMl1927n0Kir6alPiP+yuiICLLU4jpMe08dXfpebuQppFA2zw==} - engines: {node: '>=16'} + get-port-please@3.1.2: + resolution: {integrity: sha512-Gxc29eLs1fbn6LQ4jSU4vXjlwyZhF5HsGuMAa7gqBP4Rw4yxxltyDUuF5MBclFzDTXO+ACchGQoeela4DSfzdQ==} get-stream@5.2.0: resolution: {integrity: sha512-nBF+F1rAZVCu/p7rjzgA+Yb4lfYXrpl7a6VmJrU8wF9I1CKvP/QwPNZHnOlwbTkY6dvtFIzFMSyQXbLoTQPRpA==} @@ -5125,14 +5124,14 @@ snapshots: citty: 0.1.6 typescript: 5.6.3 - '@aklinker1/rollup-plugin-visualizer@5.12.0(rollup@4.24.0)': + '@aklinker1/rollup-plugin-visualizer@5.12.0(rollup@3.29.4)': dependencies: open: 8.4.2 picomatch: 2.3.1 source-map: 0.7.4 yargs: 17.7.2 optionalDependencies: - rollup: 4.24.0 + rollup: 3.29.4 '@algolia/autocomplete-core@1.9.3(@algolia/client-search@4.20.0)(algoliasearch@4.20.0)(search-insights@2.15.0)': dependencies: @@ -6094,13 +6093,13 @@ snapshots: optionalDependencies: rollup: 3.29.4 - '@rollup/pluginutils@5.1.2(rollup@4.24.0)': + '@rollup/pluginutils@5.1.2(rollup@3.29.4)': dependencies: '@types/estree': 1.0.5 estree-walker: 2.0.2 picomatch: 2.3.1 optionalDependencies: - rollup: 4.24.0 + rollup: 3.29.4 '@rollup/pluginutils@5.1.3(rollup@4.24.0)': dependencies: @@ -7586,7 +7585,7 @@ snapshots: get-func-name@2.0.2: {} - get-port@7.1.0: {} + get-port-please@3.1.2: {} get-stream@5.2.0: dependencies: @@ -9364,9 +9363,9 @@ snapshots: undici-types@6.19.8: {} - unimport@3.13.1(rollup@4.24.0)(webpack-sources@3.2.3): + unimport@3.13.1(rollup@3.29.4)(webpack-sources@3.2.3): dependencies: - '@rollup/pluginutils': 5.1.2(rollup@4.24.0) + '@rollup/pluginutils': 5.1.2(rollup@3.29.4) acorn: 8.12.1 escape-string-regexp: 5.0.0 estree-walker: 3.0.3