diff --git a/bin/wxt-publish-extension.cjs b/bin/wxt-publish-extension.cjs new file mode 100755 index 000000000..265200caa --- /dev/null +++ b/bin/wxt-publish-extension.cjs @@ -0,0 +1,7 @@ +#!/usr/bin/env node +/** + * A alias around `publish-extension` that is always installed on the path without having to install + * `publish-browser-extension` as a direct dependency (like for PNPM, which doesn't link + * sub-dependency binaries to "node_modules/.bin") + */ +require('publish-browser-extension/cli'); diff --git a/package.json b/package.json index 5851ccfd5..a2c12e6c0 100644 --- a/package.json +++ b/package.json @@ -30,7 +30,10 @@ "bin", "dist" ], - "bin": "./bin/wxt.mjs", + "bin": { + "wxt": "./bin/wxt.mjs", + "wxt-publish-extension": "./bin/wxt-publish-extension.cjs" + }, "main": "./dist/index.cjs", "module": "./dist/index.js", "types": "./dist/index.d.ts", @@ -103,6 +106,7 @@ "sync-releases": "pnpx changelogen@latest gh release" }, "dependencies": { + "@aklinker1/rollup-plugin-visualizer": "5.12.0", "@types/webextension-polyfill": "^0.10.5", "@webext-core/fake-browser": "^1.3.1", "@webext-core/isolated-element": "^1.1.1", @@ -125,15 +129,13 @@ "jiti": "^1.21.0", "json5": "^2.2.3", "linkedom": "^0.16.1", - "manage-path": "^2.0.0", "minimatch": "^9.0.3", "natural-compare": "^1.4.0", "normalize-path": "^3.0.0", "ora": "^7.0.1", "picocolors": "^1.0.0", "prompts": "^2.4.2", - "publish-browser-extension": "^2.1.2", - "rollup-plugin-visualizer": "^5.9.2", + "publish-browser-extension": "^2.1.3", "unimport": "^3.4.0", "vite": "^5.1.3", "web-ext-run": "^0.2.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 2c3eacf9e..92d69cc11 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -8,6 +8,9 @@ importers: .: dependencies: + '@aklinker1/rollup-plugin-visualizer': + specifier: 5.12.0 + version: 5.12.0 '@types/webextension-polyfill': specifier: ^0.10.5 version: 0.10.7 @@ -74,9 +77,6 @@ importers: linkedom: specifier: ^0.16.1 version: 0.16.1 - manage-path: - specifier: ^2.0.0 - version: 2.0.0 minimatch: specifier: ^9.0.3 version: 9.0.3 @@ -96,11 +96,8 @@ importers: specifier: ^2.4.2 version: 2.4.2 publish-browser-extension: - specifier: ^2.1.2 - version: 2.1.2 - rollup-plugin-visualizer: - specifier: ^5.9.2 - version: 5.12.0 + specifier: ^2.1.3 + version: 2.1.3 unimport: specifier: ^3.4.0 version: 3.4.0 @@ -226,6 +223,22 @@ importers: packages: + /@aklinker1/rollup-plugin-visualizer@5.12.0: + resolution: {integrity: sha512-X24LvEGw6UFmy0lpGJDmXsMyBD58XmX1bbwsaMLhNoM+UMQfQ3b2RtC+nz4b/NoRK5r6QJSKJHBNVeUdwqybaQ==} + engines: {node: '>=14'} + hasBin: true + peerDependencies: + rollup: 2.x || 3.x || 4.x + peerDependenciesMeta: + rollup: + optional: true + dependencies: + open: 8.4.2 + picomatch: 2.3.1 + source-map: 0.7.4 + yargs: 17.7.2 + dev: false + /@algolia/autocomplete-core@1.9.3(algoliasearch@4.20.0): resolution: {integrity: sha512-009HdfugtGCdC4JdXUbVJClA0q0zh24yyePn+KUGk3rP7j8FEe/m5Yo/z65gn6nP/cM39PxpzqKrL7A6fP6PPw==} dependencies: @@ -3544,10 +3557,6 @@ packages: resolution: {integrity: sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==} dev: false - /manage-path@2.0.0: - resolution: {integrity: sha512-NJhyB+PJYTpxhxZJ3lecIGgh4kwIY2RAh44XvAz9UlqthlQwtPBf62uBVR8XaD8CRuSjQ6TnZH2lNJkbLPZM2A==} - dev: false - /mark.js@8.11.1: resolution: {integrity: sha512-1I+1qpDt4idfgLQG+BNWmrqku+7/2bi5nLf4YwF8y8zXvmfiTBY3PV3ZibfrjBueCByROpuBjLLFCajqkgYoLQ==} dev: true @@ -4175,8 +4184,8 @@ packages: sade: 1.8.1 dev: true - /publish-browser-extension@2.1.2: - resolution: {integrity: sha512-g6+mtdR4Z+GYHPIrfaAwC7Kbt1oQlpJ8r0x1PAytScy33OFdK+HVUeDDYorBpPAiQlmYJRQga7rY9QVTyTw34g==} + /publish-browser-extension@2.1.3: + resolution: {integrity: sha512-qisnXUUwjvu5kMvObfG7UQ9rPU3t0XfbKdCdCrwAXaLUySdC25nlM4gxi+CBvL7LiwvK494GJyEK/weQBhIyTQ==} engines: {node: ^18.0.0 || >=20.0.0} hasBin: true dependencies: @@ -4391,22 +4400,6 @@ packages: glob: 7.1.6 dev: false - /rollup-plugin-visualizer@5.12.0: - resolution: {integrity: sha512-8/NU9jXcHRs7Nnj07PF2o4gjxmm9lXIrZ8r175bT9dK8qoLlvKTwRMArRCMgpMGlq8CTLugRvEmyMeMXIU2pNQ==} - engines: {node: '>=14'} - hasBin: true - peerDependencies: - rollup: 2.x || 3.x || 4.x - peerDependenciesMeta: - rollup: - optional: true - dependencies: - open: 8.4.2 - picomatch: 2.3.1 - source-map: 0.7.4 - yargs: 17.7.2 - dev: false - /rollup@4.6.1: resolution: {integrity: sha512-jZHaZotEHQaHLgKr8JnQiDT1rmatjgKlMekyksz+yk9jt/8z9quNjnKNRoaM0wd9DC2QKXjmWWuDYtM3jfF8pQ==} engines: {node: '>=18.0.0', npm: '>=8.0.0'} diff --git a/src/cli/cli-utils.ts b/src/cli/cli-utils.ts index b48241fc4..539b61162 100644 --- a/src/cli/cli-utils.ts +++ b/src/cli/cli-utils.ts @@ -1,6 +1,5 @@ import { CAC, Command } from 'cac'; import consola, { LogLevels } from 'consola'; -import { exec } from '~/core/utils/exec'; import { printHeader } from '~/core/utils/log'; import { formatDuration } from '~/core/utils/time'; import { ValidationError } from '~/core/utils/validation'; @@ -63,10 +62,18 @@ export function getArrayFromFlags( } const aliasCommandNames = new Set(); +/** + * @param base Command to add this one to + * @param name The command name to add + * @param alias The CLI tool being aliased + * @param bin The CLI tool binary name. Usually the same as the alias + * @param docsUrl URL to the docs for the aliased CLI tool + */ export function createAliasedCommand( base: CAC, name: string, alias: string, + bin: string, docsUrl: string, ) { const aliasedCommand = base @@ -79,7 +86,8 @@ export function createAliasedCommand( const args = process.argv.slice( process.argv.indexOf(aliasedCommand.name) + 1, ); - await exec(alias, args, { + const { execa } = await import('execa'); + await execa(bin, args, { stdio: 'inherit', }); } catch { diff --git a/src/cli/commands.ts b/src/cli/commands.ts index 57e5a9306..b8133c100 100644 --- a/src/cli/commands.ts +++ b/src/cli/commands.ts @@ -140,6 +140,7 @@ createAliasedCommand( cli, 'submit', 'publish-extension', + 'wxt-publish-extension', 'https://www.npmjs.com/publish-browser-extension', ); diff --git a/src/core/builders/vite/plugins/bundleAnalysis.ts b/src/core/builders/vite/plugins/bundleAnalysis.ts index 150beb6b8..2468628b6 100644 --- a/src/core/builders/vite/plugins/bundleAnalysis.ts +++ b/src/core/builders/vite/plugins/bundleAnalysis.ts @@ -1,5 +1,5 @@ import type * as vite from 'vite'; -import { visualizer } from 'rollup-plugin-visualizer'; +import { visualizer } from '@aklinker1/rollup-plugin-visualizer'; import { ResolvedConfig } from '~/types'; import path from 'node:path'; diff --git a/src/core/utils/building/internal-build.ts b/src/core/utils/building/internal-build.ts index ce8816a10..412694f13 100644 --- a/src/core/utils/building/internal-build.ts +++ b/src/core/utils/building/internal-build.ts @@ -16,8 +16,8 @@ import { validateEntrypoints, } from '../validation'; import consola from 'consola'; -import { exec } from '../exec'; import { wxt } from '../../wxt'; +import { mergeJsonOutputs } from '@aklinker1/rollup-plugin-visualizer'; /** * Builds the extension based on an internal config. No more config discovery is performed, the @@ -93,17 +93,11 @@ async function combineAnalysisStats(): Promise { }); const absolutePaths = unixFiles.map(unnormalizePath); - await exec( - 'rollup-plugin-visualizer', - [ - ...absolutePaths, - '--template', - wxt.config.analysis.template, - '--filename', - wxt.config.analysis.outputFile, - ], - { cwd: wxt.config.root, stdio: 'inherit' }, - ); + await mergeJsonOutputs({ + inputs: absolutePaths, + template: wxt.config.analysis.template, + filename: wxt.config.analysis.outputFile, + }); if (!wxt.config.analysis.keepArtifacts) { await Promise.all(absolutePaths.map((statsFile) => fs.remove(statsFile))); diff --git a/src/core/utils/exec.ts b/src/core/utils/exec.ts deleted file mode 100644 index 8574cb437..000000000 --- a/src/core/utils/exec.ts +++ /dev/null @@ -1,26 +0,0 @@ -import type { Options } from 'execa'; -import managePath from 'manage-path'; -import { resolve } from 'node:path'; -import { wxt } from '../wxt'; - -const managedPath = managePath(process.env); - -/** - * Wrapper around `execa` with a modified `PATH` variable containing CLI tools from WXT's dependencies. - */ -export const exec = async ( - file: string, - args?: readonly string[], - options?: Options, -) => { - // Reset so the same path isn't added multiple times - managedPath.restore(); - - // Add subdependency path for PNPM shamefully-hoist=false - managedPath.push( - resolve(wxt.config.root, 'node_modules/wxt/node_modules/.bin'), - ); - - const { execa } = await import('execa'); - return await execa(file, args, options); -}; diff --git a/src/types/index.ts b/src/types/index.ts index c292e0ff4..8a0fef42b 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -3,7 +3,7 @@ import type { Manifest, Scripting } from '~/browser'; import { UnimportOptions } from 'unimport'; import { LogLevel } from 'consola'; import { ContentScriptContext } from '../client/content-scripts/content-script-context'; -import type { PluginVisualizerOptions } from 'rollup-plugin-visualizer'; +import type { PluginVisualizerOptions } from '@aklinker1/rollup-plugin-visualizer'; import type { FSWatcher } from 'chokidar'; import { ResolvedConfig as C12ResolvedConfig } from 'c12'; import { Hookable, NestedHooks } from 'hookable'; diff --git a/src/types/modules.d.ts b/src/types/modules.d.ts index c424b5323..49fb40ff4 100644 --- a/src/types/modules.d.ts +++ b/src/types/modules.d.ts @@ -50,18 +50,6 @@ declare module 'web-ext-run/util/logger' { export const consoleStream: IConsoleStream; } -declare module 'manage-path' { - export interface ManagedPath { - push(...paths: string[]); - push(paths: string[]); - shift(...paths: string[]); - shift(paths: string[]); - get(): string; - restore(): void; - } - export default function managePath(env: object): ManagedPath; -} - declare module 'wxt/browser' { // Overridden when types are generated per project export type PublicPath = string;