diff --git a/package.json b/package.json index 7b857be24..182edbf89 100644 --- a/package.json +++ b/package.json @@ -125,6 +125,7 @@ "jiti": "^1.21.0", "json5": "^2.2.3", "linkedom": "^0.16.1", + "manage-path": "^2.0.0", "minimatch": "^9.0.3", "normalize-path": "^3.0.0", "ora": "^7.0.1", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 62fc427f8..229522eec 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -74,6 +74,9 @@ 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 @@ -3352,6 +3355,10 @@ 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 diff --git a/src/core/utils/building/internal-build.ts b/src/core/utils/building/internal-build.ts index 165f8128a..819030735 100644 --- a/src/core/utils/building/internal-build.ts +++ b/src/core/utils/building/internal-build.ts @@ -8,6 +8,8 @@ import { printBuildSummary } from '~/core/utils/log'; import glob from 'fast-glob'; import { unnormalizePath } from '~/core/utils/paths'; import { rebuild } from './rebuild'; +import managePath from 'manage-path'; +import { resolve } from 'node:path'; /** * Builds the extension based on an internal config. No more config discovery is performed, the @@ -75,6 +77,10 @@ async function combineAnalysisStats(config: InternalConfig): Promise { }); const absolutePaths = unixFiles.map(unnormalizePath); + const alterPath = managePath(process.env); + // Add subdependency path for PNPM shamefully-hoist=false + alterPath.push(resolve(config.root, 'node_modules/wxt/node_modules/.bin')); + await execaCommand( `rollup-plugin-visualizer ${absolutePaths.join(' ')} --template ${ config.analysis.template diff --git a/src/types/modules.d.ts b/src/types/modules.d.ts index 49fb40ff4..b931db5b4 100644 --- a/src/types/modules.d.ts +++ b/src/types/modules.d.ts @@ -50,6 +50,10 @@ declare module 'web-ext-run/util/logger' { export const consoleStream: IConsoleStream; } +declare module 'manage-path' { + export default function managePath(env: object): string[]; +} + declare module 'wxt/browser' { // Overridden when types are generated per project export type PublicPath = string;