From 7ef1a5bcc0d17a8ead1898a56c02e8d6d0cdb6c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=E2=9D=A4=EF=B8=8F=20=E2=98=AE=EF=B8=8F=20=E2=9C=8B?= <6723574+louisgv@users.noreply.github.com> Date: Fri, 10 Nov 2023 03:25:02 -0400 Subject: [PATCH] patch parcel-core --- cli/plasmo/package.json | 2 +- core/parcel-config/package.json | 1 - core/parcel-core/package.json | 5 +- core/parcel-core/src/index.ts | 440 +----------------------- core/parcel-core/src/resolve-options.ts | 223 ------------ core/parcel-core/src/types.ts | 3 - core/parcel-core/src/worker.ts | 1 + core/parcel-core/tsup.config.ts | 3 +- core/parcel-packager/package.json | 2 +- package.json | 3 +- patches/@parcel__core@2.10.2.patch | 17 + pnpm-lock.yaml | 75 ++-- 12 files changed, 70 insertions(+), 705 deletions(-) delete mode 100644 core/parcel-core/src/resolve-options.ts delete mode 100644 core/parcel-core/src/types.ts create mode 100644 core/parcel-core/src/worker.ts create mode 100644 patches/@parcel__core@2.10.2.patch diff --git a/cli/plasmo/package.json b/cli/plasmo/package.json index 4d37fb94e..9c5204e7d 100644 --- a/cli/plasmo/package.json +++ b/cli/plasmo/package.json @@ -38,8 +38,8 @@ "framework" ], "dependencies": { + "@parcel/rust": "2.10.2", "@expo/spawn-async": "1.7.2", - "@parcel/core": "2.10.2", "@parcel/fs": "2.10.2", "@parcel/package-manager": "2.10.2", "@parcel/watcher": "2.3.0", diff --git a/core/parcel-config/package.json b/core/parcel-config/package.json index 5c98c4056..c536f5ea2 100644 --- a/core/parcel-config/package.json +++ b/core/parcel-config/package.json @@ -10,7 +10,6 @@ "dependencies": { "@parcel/compressor-raw": "2.10.2", "@parcel/config-default": "2.10.2", - "@parcel/core": "2.10.2", "@parcel/optimizer-data-url": "2.10.2", "@parcel/reporter-bundle-buddy": "2.10.2", "@parcel/resolver-default": "2.10.2", diff --git a/core/parcel-core/package.json b/core/parcel-core/package.json index d5757f194..36a570cb6 100644 --- a/core/parcel-core/package.json +++ b/core/parcel-core/package.json @@ -6,7 +6,7 @@ "dist" ], "main": "dist/index.js", - "types": "src/types.ts", + "types": "src/index.ts", "scripts": { "prepublishOnly": "pnpm build", "build": "tsup --minify --clean", @@ -23,14 +23,15 @@ "url": "https://github.com/PlasmoHQ/plasmo.git" }, "devDependencies": { + "@parcel/core": "2.10.2", "@parcel/types": "2.8.3", "@plasmo/config": "workspace:*", "@plasmo/utils": "workspace:*", "tsup": "7.2.0" }, "dependencies": { + "@parcel/rust": "2.10.2", "@parcel/cache": "2.10.2", - "@parcel/core": "2.10.2", "@parcel/diagnostic": "2.10.2", "@parcel/events": "2.10.2", "@parcel/fs": "2.10.2", diff --git a/core/parcel-core/src/index.ts b/core/parcel-core/src/index.ts index 6200125b7..b62255956 100644 --- a/core/parcel-core/src/index.ts +++ b/core/parcel-core/src/index.ts @@ -3,442 +3,6 @@ * MIT License */ -import invariant from "assert" -import { createWorkerFarm } from "@parcel/core" -import dumpGraphToGraphViz from "@parcel/core/lib/dumpGraphToGraphViz" -import ParcelConfig from "@parcel/core/lib/ParcelConfig" -import { toProjectPath } from "@parcel/core/lib/projectPath" -import { assetFromValue } from "@parcel/core/lib/public/Asset" -import { PackagedBundle } from "@parcel/core/lib/public/Bundle" -import BundleGraph from "@parcel/core/lib/public/BundleGraph" -import ReporterRunner from "@parcel/core/lib/ReporterRunner" -import createParcelBuildRequest from "@parcel/core/lib/requests/ParcelBuildRequest" -import { loadParcelConfig } from "@parcel/core/lib/requests/ParcelConfigRequest" -import createValidationRequest from "@parcel/core/lib/requests/ValidationRequest" -import RequestTracker, { - getWatcherOptions, - requestGraphEdgeTypes -} from "@parcel/core/lib/RequestTracker" -import { - BuildAbortError, - registerCoreWithSerializer -} from "@parcel/core/lib/utils" -import ThrowableDiagnostic, { - anyToDiagnostic, - type Diagnostic -} from "@parcel/diagnostic" -import { Disposable, ValueEmitter } from "@parcel/events" -import { init as initHash } from "@parcel/hash" -import logger from "@parcel/logger" -import { init as initSourcemaps } from "@parcel/source-map" -import type { - AsyncSubscription, - BuildEvent, - BuildSuccessEvent, - InitialParcelOptions, - PackagedBundle as IPackagedBundle -} from "@parcel/types" -import { PromiseQueue } from "@parcel/utils" -import { type Options as ParcelWatcherOptions } from "@parcel/watcher" -// eslint-disable-next-line no-unused-vars -import { AbortController } from "abortcontroller-polyfill/dist/cjs-ponyfill" -import nullthrows from "nullthrows" +export type { InitialParcelOptions as ParcelOptions } from "@parcel/types" -import { resolveOptions, type ResolvedOptions } from "./resolve-options" - -registerCoreWithSerializer() - -export const INTERNAL_TRANSFORM: symbol = Symbol("internal_transform") -export const INTERNAL_RESOLVE: symbol = Symbol("internal_resolve") - -type SharedReference = number - -export class Parcel { - #requestTracker: RequestTracker - #config: ParcelConfig - #farm - #initialized = false - #disposable: Disposable - #initialOptions: InitialParcelOptions - #reporterRunner: ReporterRunner - #resolvedOptions: ResolvedOptions = null - #optionsRef: SharedReference - #watchAbortController /*: AbortController*/ - #watchQueue = new PromiseQueue({ - maxConcurrent: 1 - }) - - #watchEvents: ValueEmitter< - | { - error: Error - buildEvent?: void - } - | { - buildEvent: BuildEvent - error?: void - } - > - - #watcherSubscription: AsyncSubscription - #watcherCount = 0 - #requestedAssetIds: Set = new Set() - - isProfiling /*: boolean */ - - constructor(options: InitialParcelOptions) { - this.#initialOptions = options - } - - async _init(): Promise { - if (this.#initialized) { - return - } - - await initSourcemaps - await initHash - - let resolvedOptions = await resolveOptions(this.#initialOptions) - this.#resolvedOptions = resolvedOptions - let { config } = await loadParcelConfig(resolvedOptions) - this.#config = new ParcelConfig(config, resolvedOptions) - - if (this.#initialOptions.workerFarm) { - if (this.#initialOptions.workerFarm["ending"]) { - throw new Error("Supplied WorkerFarm is ending") - } - this.#farm = this.#initialOptions.workerFarm - } else { - this.#farm = createWorkerFarm({ - shouldPatchConsole: resolvedOptions.shouldPatchConsole - }) - } - - // @ts-ignore QUIRK: upstream def is outdated: - await resolvedOptions.cache.ensure() - - let { dispose: disposeOptions, ref: optionsRef } = - await this.#farm.createSharedReference(resolvedOptions, false) - this.#optionsRef = optionsRef - - this.#disposable = new Disposable() - if (this.#initialOptions.workerFarm) { - // If we don't own the farm, dispose of only these references when - // Parcel ends. - this.#disposable.add(disposeOptions) - } else { - // Otherwise, when shutting down, end the entire farm we created. - this.#disposable.add(() => this.#farm.end()) - } - - this.#watchEvents = new ValueEmitter() - this.#disposable.add(() => this.#watchEvents.dispose()) - - this.#requestTracker = await RequestTracker.init({ - farm: this.#farm, - options: resolvedOptions - }) - - this.#reporterRunner = new ReporterRunner({ - config: this.#config, - options: resolvedOptions, - workerFarm: this.#farm - }) - this.#disposable.add(this.#reporterRunner) - - this.#initialized = true - } - - async run(): Promise { - let startTime = Date.now() - if (!this.#initialized) { - await this._init() - } - - let result = await this._build({ startTime }) - await this._end() - - if (result.type === "buildFailure") { - throw new BuildError(result.diagnostics) - } - - return result - } - - async _end(): Promise { - this.#initialized = false - - await Promise.all([ - this.#disposable.dispose(), - await this.#requestTracker.writeToCache() - ]) - } - - async _startNextBuild() { - this.#watchAbortController = new AbortController() - await this.#farm.callAllWorkers("clearConfigCache", []) - - try { - let buildEvent = await this._build({ - signal: this.#watchAbortController.signal - }) - - this.#watchEvents.emit({ - buildEvent - }) - - return buildEvent - } catch (err) { - // Ignore BuildAbortErrors and only emit critical errors. - if (!(err instanceof BuildAbortError)) { - throw err - } - } - } - - async watch( - cb?: (err: Error, buildEvent?: BuildEvent) => any - ): Promise { - if (!this.#initialized) { - await this._init() - } - - let watchEventsDisposable - if (cb) { - watchEventsDisposable = this.#watchEvents.addListener( - ({ error, buildEvent }) => cb(error, buildEvent) - ) - } - - if (this.#watcherCount === 0) { - this.#watcherSubscription = await this._getWatcherSubscription() - await this.#reporterRunner.report({ type: "watchStart" }) - - // Kick off a first build, but don't await its results. Its results will - // be provided to the callback. - this.#watchQueue.add(() => this._startNextBuild()) - this.#watchQueue.run() - } - - this.#watcherCount++ - - let unsubscribePromise - const unsubscribe = async () => { - if (watchEventsDisposable) { - watchEventsDisposable.dispose() - } - - this.#watcherCount-- - if (this.#watcherCount === 0) { - await nullthrows(this.#watcherSubscription).unsubscribe() - this.#watcherSubscription = null - await this.#reporterRunner.report({ type: "watchEnd" }) - this.#watchAbortController.abort() - await this.#watchQueue.run() - await this._end() - } - } - - return { - unsubscribe() { - if (unsubscribePromise == null) { - unsubscribePromise = unsubscribe() - } - - return unsubscribePromise - } - } - } - - async _build({ - signal = null, - startTime = Date.now() - } = {}): Promise { - this.#requestTracker.setSignal(signal) - let options = nullthrows(this.#resolvedOptions) - try { - if (options.shouldProfile) { - await this.startProfiling() - } - this.#reporterRunner.report({ - type: "buildStart" - }) - - this.#requestTracker.graph.invalidateOnBuildNodes() - - let request = createParcelBuildRequest({ - optionsRef: this.#optionsRef, - requestedAssetIds: this.#requestedAssetIds, - signal - }) - - let { bundleGraph, bundleInfo, changedAssets, assetRequests } = - await this.#requestTracker.runRequest(request, { force: true }) - - this.#requestedAssetIds.clear() - - await dumpGraphToGraphViz( - // $FlowFixMe - this.#requestTracker.graph, - "RequestGraph", - requestGraphEdgeTypes - ) - - let event = { - type: "buildSuccess" as const, - changedAssets: new Map( - Array.from(changedAssets).map(([id, asset]) => [ - id, - assetFromValue(asset, options) - ]) - ), - bundleGraph: new BundleGraph( - bundleGraph, - (bundle, bundleGraph, options) => - PackagedBundle.getWithInfo( - bundle, - bundleGraph, - options, - bundleInfo.get(bundle.id) - ), - options - ), - buildTime: Date.now() - startTime, - requestBundle: async (bundle) => { - let bundleNode = bundleGraph._graph.getNodeByContentKey(bundle.id) - invariant(bundleNode?.type === "bundle", "Bundle does not exist") - - if (!bundleNode.value.isPlaceholder) { - // Nothing to do. - return { - type: "buildSuccess", - changedAssets: new Map(), - bundleGraph: event.bundleGraph, - buildTime: 0, - requestBundle: event.requestBundle - } - } - - for (let assetId of bundleNode.value.entryAssetIds) { - this.#requestedAssetIds.add(assetId) - } - - if (this.#watchQueue.getNumWaiting() === 0) { - if (this.#watchAbortController) { - this.#watchAbortController.abort() - } - - this.#watchQueue.add(() => this._startNextBuild()) - } - - let results = await this.#watchQueue.run() - let result = results.filter(Boolean).pop() - if (result.type === "buildFailure") { - throw new BuildError(result.diagnostics) - } - - return result - } - } - - await this.#reporterRunner.report(event) - await this.#requestTracker.runRequest( - createValidationRequest({ - optionsRef: this.#optionsRef, - assetRequests - }), - { force: assetRequests.length > 0 } - ) - return event - } catch (e) { - if (e instanceof BuildAbortError) { - throw e - } - - let diagnostic = anyToDiagnostic(e) - let event = { - type: "buildFailure" as const, - diagnostics: Array.isArray(diagnostic) ? diagnostic : [diagnostic] - } - - await this.#reporterRunner.report(event) - - return event - } finally { - if (this.isProfiling) { - await this.stopProfiling() - } - - await this.#farm.callAllWorkers("clearConfigCache", []) - } - } - - async _getWatcherSubscription(): Promise { - invariant(this.#watcherSubscription == null) - - // TODO: This is where the resolvedOptions - the watch project root, need to be fixed - - let resolvedOptions = nullthrows(this.#resolvedOptions) - let opts: ParcelWatcherOptions = getWatcherOptions(resolvedOptions) - - opts.ignore.push(process.env.PLASMO_BUILD_DIR) - - let sub = await resolvedOptions.inputFS.watch( - resolvedOptions.projectRoot, - (err, events) => { - if (err) { - this.#watchEvents.emit({ error: err }) - return - } - - let isInvalid = this.#requestTracker.respondToFSEvents( - events.map((e) => ({ - type: e.type, - path: toProjectPath(resolvedOptions.projectRoot, e.path) - })) - ) - if (isInvalid && this.#watchQueue.getNumWaiting() === 0) { - if (this.#watchAbortController) { - this.#watchAbortController.abort() - } - - this.#watchQueue.add(() => this._startNextBuild()) - this.#watchQueue.run() - } - }, - opts - ) - return { unsubscribe: () => sub.unsubscribe() } - } - - async startProfiling(): Promise { - if (this.isProfiling) { - throw new Error("Parcel is already profiling") - } - - logger.info({ origin: "@parcel/core", message: "Starting profiling..." }) - this.isProfiling = true - await this.#farm.startProfile() - } - - stopProfiling(): Promise { - if (!this.isProfiling) { - throw new Error("Parcel is not profiling") - } - - logger.info({ origin: "@parcel/core", message: "Stopping profiling..." }) - this.isProfiling = false - return this.#farm.endProfile() - } - - takeHeapSnapshot(): Promise { - logger.info({ origin: "@parcel/core", message: "Taking heap snapshot..." }) - return this.#farm.takeHeapSnapshot() - } -} - -class BuildError extends ThrowableDiagnostic { - constructor(diagnostic: Array | Diagnostic) { - super({ diagnostic }) - this.name = "BuildError" - } -} +export { Parcel } from "@parcel/core" diff --git a/core/parcel-core/src/resolve-options.ts b/core/parcel-core/src/resolve-options.ts deleted file mode 100644 index 7d858bef2..000000000 --- a/core/parcel-core/src/resolve-options.ts +++ /dev/null @@ -1,223 +0,0 @@ -/** - * Based on https://github.com/parcel-bundler/parcel/blob/v2/packages/core/core/src/resolveOptions.js - * MIT License - */ - -import path from "path" -import { FSCache, LMDBCache } from "@parcel/cache" -import { toProjectPath } from "@parcel/core/lib/projectPath" -import { getResolveFrom } from "@parcel/core/lib/requests/ParcelConfigRequest" -import { NodeFS, type FileSystem } from "@parcel/fs" -import { hashString } from "@parcel/hash" -import { NodePackageManager } from "@parcel/package-manager" -import type { - DependencySpecifier, - FilePath, - InitialParcelOptions, - InitialServerOptions -} from "@parcel/types" -import { getRootDir, isGlob, relativePath, resolveConfig } from "@parcel/utils" - -// Default cache directory name -const LOCK_FILE_NAMES = ["yarn.lock", "package-lock.json", "pnpm-lock.yaml"] - -// Generate a unique instanceId, will change on every run of parcel -function generateInstanceId(entries: Array): string { - return hashString( - `${entries.join(",")}-${Date.now()}-${Math.round(Math.random() * 100)}` - ) -} - -export async function resolveOptions(initialOptions: InitialParcelOptions) { - let inputFS = initialOptions.inputFS || new NodeFS() - let outputFS = initialOptions.outputFS || new NodeFS() - let inputCwd = inputFS.cwd() - let outputCwd = outputFS.cwd() - let entries: Array - - if (initialOptions.entries == null || initialOptions.entries === "") { - entries = [] - } else if (Array.isArray(initialOptions.entries)) { - entries = initialOptions.entries.map((entry) => - path.resolve(inputCwd, entry) - ) - } else { - entries = [path.resolve(inputCwd, initialOptions.entries)] - } - - let shouldMakeEntryReferFolder = false - - if (entries.length === 1 && !isGlob(entries[0])) { - let [entry] = entries - - try { - shouldMakeEntryReferFolder = (await inputFS.stat(entry)).isDirectory() - } catch { - // ignore failing stat call - } - } - - // getRootDir treats the input as files, so getRootDir(["/home/user/myproject"]) returns "/home/user". - // Instead we need to make the the entry refer to some file inside the specified folders if entries refers to the directory. - let entryRoot = getRootDir( - shouldMakeEntryReferFolder ? [path.join(entries[0], "index")] : entries - ) - let projectRootFile = - (await resolveConfig( - inputFS, - path.join(entryRoot, "index"), - [...LOCK_FILE_NAMES], - path.parse(entryRoot).root - )) || path.join(inputCwd, "index") - - // ? Should this just be rootDir - let projectRoot = path.dirname(projectRootFile) - let packageManager = - initialOptions.packageManager || - new NodePackageManager(inputFS, projectRoot) - - let cacheDir = path.resolve(outputCwd, initialOptions.cacheDir) - - let cache = - initialOptions.cache ?? - (outputFS instanceof NodeFS - ? new LMDBCache(cacheDir) - : // @ts-ignore QUIRK: upstream def is outdated - new FSCache(outputFS, cacheDir)) - - let mode = initialOptions.mode ?? "development" - let shouldOptimize = - initialOptions?.defaultTargetOptions?.shouldOptimize ?? - mode === "production" - let publicUrl = initialOptions?.defaultTargetOptions?.publicUrl ?? "/" - let distDir = - initialOptions?.defaultTargetOptions?.distDir != null - ? path.resolve(inputCwd, initialOptions?.defaultTargetOptions?.distDir) - : undefined - let shouldBuildLazily = initialOptions.shouldBuildLazily ?? false - let shouldContentHash = - initialOptions.shouldContentHash ?? initialOptions.mode === "production" - - if (shouldBuildLazily && shouldContentHash) { - throw new Error("Lazy bundling does not work with content hashing") - } - - let env = initialOptions.env - let port = determinePort(initialOptions.serveOptions, process.env.PORT) - - return { - config: getRelativeConfigSpecifier( - inputFS, - projectRoot, - initialOptions.config - ), - defaultConfig: getRelativeConfigSpecifier( - inputFS, - projectRoot, - initialOptions.defaultConfig - ), - shouldPatchConsole: initialOptions.shouldPatchConsole ?? false, - env, - mode, - shouldAutoInstall: initialOptions.shouldAutoInstall ?? false, - hmrOptions: initialOptions.hmrOptions ?? null, - shouldBuildLazily, - shouldBundleIncrementally: initialOptions.shouldBundleIncrementally ?? true, - shouldContentHash, - serveOptions: initialOptions.serveOptions - ? { - ...initialOptions.serveOptions, - distDir: distDir ?? path.join(outputCwd, "dist"), - port - } - : false, - shouldDisableCache: initialOptions.shouldDisableCache ?? false, - shouldProfile: initialOptions.shouldProfile ?? false, - cacheDir, - entries: entries.map((e) => toProjectPath(projectRoot, e)), - targets: initialOptions.targets, - logLevel: initialOptions.logLevel ?? "info", - projectRoot, - inputFS, - outputFS, - cache, - packageManager, - additionalReporters: - initialOptions.additionalReporters?.map( - ({ packageName, resolveFrom }) => ({ - packageName, - resolveFrom: toProjectPath(projectRoot, resolveFrom) - }) - ) ?? [], - instanceId: generateInstanceId(entries), - detailedReport: initialOptions.detailedReport, - defaultTargetOptions: { - shouldOptimize, - shouldScopeHoist: initialOptions?.defaultTargetOptions?.shouldScopeHoist, - sourceMaps: initialOptions?.defaultTargetOptions?.sourceMaps ?? true, - publicUrl, - ...(distDir != null - ? { - distDir: toProjectPath(projectRoot, distDir) - } - : { - /*::...null*/ - }), - engines: initialOptions?.defaultTargetOptions?.engines, - outputFormat: initialOptions?.defaultTargetOptions?.outputFormat, - isLibrary: initialOptions?.defaultTargetOptions?.isLibrary - } - } -} - -export type ResolvedOptions = Awaited> - -function getRelativeConfigSpecifier( - fs: FileSystem, - projectRoot: FilePath, - specifier: DependencySpecifier | null | undefined -) { - if (specifier == null) { - return undefined - } else if (path.isAbsolute(specifier)) { - let resolveFrom = getResolveFrom(fs, projectRoot) - let relative = relativePath(path.dirname(resolveFrom), specifier) - // If the config is outside the project root, use an absolute path so that if the project root - // moves the path still works. Otherwise, use a relative path so that the cache is portable. - return relative.startsWith("..") ? specifier : relative - } else { - return specifier - } -} - -function determinePort( - initialServerOptions: InitialServerOptions | false | void, - portInEnv: string | void, - defaultPort: number = 1234 -): number { - function parsePort(port: string) { - let parsedPort = Number(port) - - // return undefined if port number defined in .env is not valid integer - if (!Number.isInteger(parsedPort)) { - return undefined - } - - return parsedPort - } - - if (!initialServerOptions) { - return typeof portInEnv !== "undefined" - ? parsePort(portInEnv) ?? defaultPort - : defaultPort - } - - // if initialServerOptions.port is equal to defaultPort, then this means that port number is provided via PORT=~~~~ on cli. In this case, we should ignore port number defined in .env. - if (initialServerOptions.port !== defaultPort) { - return initialServerOptions.port - } - - return typeof portInEnv !== "undefined" - ? parsePort(portInEnv) ?? defaultPort - : defaultPort -} diff --git a/core/parcel-core/src/types.ts b/core/parcel-core/src/types.ts deleted file mode 100644 index f1ac5093d..000000000 --- a/core/parcel-core/src/types.ts +++ /dev/null @@ -1,3 +0,0 @@ -export type { InitialParcelOptions as ParcelOptions } from "@parcel/types" - -export { Parcel } from "./index" diff --git a/core/parcel-core/src/worker.ts b/core/parcel-core/src/worker.ts new file mode 100644 index 000000000..9066c908d --- /dev/null +++ b/core/parcel-core/src/worker.ts @@ -0,0 +1 @@ +export * from "@parcel/core/lib/worker" diff --git a/core/parcel-core/tsup.config.ts b/core/parcel-core/tsup.config.ts index 0a09924ec..9aa48e4ec 100644 --- a/core/parcel-core/tsup.config.ts +++ b/core/parcel-core/tsup.config.ts @@ -1,5 +1,6 @@ import { defineConfig } from "tsup" export default defineConfig({ - entry: ["src/index.ts"] + entry: ["src/index.ts", "src/worker.ts"], + external: ["./worker"] }) diff --git a/core/parcel-packager/package.json b/core/parcel-packager/package.json index 89a359b06..6060edcc8 100644 --- a/core/parcel-packager/package.json +++ b/core/parcel-packager/package.json @@ -1,6 +1,6 @@ { "name": "@plasmohq/parcel-packager", - "version": "0.7.0", + "version": "0.8.0", "description": "Plasmo Parcel Packager for Web Extension Manifest", "files": [ "dist" diff --git a/package.json b/package.json index 741bd0469..358e27ad5 100644 --- a/package.json +++ b/package.json @@ -35,7 +35,8 @@ "react-refresh": "0.14.0" }, "patchedDependencies": { - "@parcel/bundler-default@2.10.2": "patches/@parcel__bundler-default@2.10.2.patch" + "@parcel/bundler-default@2.10.2": "patches/@parcel__bundler-default@2.10.2.patch", + "@parcel/core@2.10.2": "patches/@parcel__core@2.10.2.patch" } }, "devDependencies": { diff --git a/patches/@parcel__core@2.10.2.patch b/patches/@parcel__core@2.10.2.patch new file mode 100644 index 000000000..b001fb0f5 --- /dev/null +++ b/patches/@parcel__core@2.10.2.patch @@ -0,0 +1,17 @@ +diff --git a/lib/resolveOptions.js b/lib/resolveOptions.js +index 0bf28331b54c99e807367efc296d6ff1d595d873..e42d034c1f3ae08eeb524f76873ac9f518b7f42b 100644 +--- a/lib/resolveOptions.js ++++ b/lib/resolveOptions.js +@@ -116,11 +116,7 @@ async function resolveOptions(initialOptions) { + if (shouldBuildLazily && shouldContentHash) { + throw new Error('Lazy bundling does not work with content hashing'); + } +- let env = { +- ...(await (0, _loadDotEnv.default)((_initialOptions$env = initialOptions.env) !== null && _initialOptions$env !== void 0 ? _initialOptions$env : {}, inputFS, _path().default.join(projectRoot, 'index'), projectRoot)), +- ...process.env, +- ...initialOptions.env +- }; ++ let env = initialOptions.env; + let port = determinePort(initialOptions.serveOptions, env.PORT); + return { + config: getRelativeConfigSpecifier(inputFS, projectRoot, initialOptions.config), diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 780a065e5..ef01dc1ff 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -12,6 +12,9 @@ patchedDependencies: '@parcel/bundler-default@2.10.2': hash: g5vra6dvyjgmh75x3ewfdh7vle path: patches/@parcel__bundler-default@2.10.2.patch + '@parcel/core@2.10.2': + hash: ev7lrsvt5tolou43wvizj5pkc4 + path: patches/@parcel__core@2.10.2.patch importers: @@ -299,15 +302,15 @@ importers: '@expo/spawn-async': specifier: 1.7.2 version: 1.7.2 - '@parcel/core': - specifier: 2.10.2 - version: 2.10.2 '@parcel/fs': specifier: 2.10.2 version: 2.10.2(@parcel/core@2.10.2) '@parcel/package-manager': specifier: 2.10.2 version: 2.10.2(@parcel/core@2.10.2) + '@parcel/rust': + specifier: 2.10.2 + version: 2.10.2 '@parcel/watcher': specifier: 2.3.0 version: 2.3.0 @@ -421,7 +424,7 @@ importers: specifier: 2.10.2 version: 2.10.2 nullthrows: - specifier: ^1.1.1 + specifier: 1.1.1 version: 1.1.1 devDependencies: '@parcel/bundler-default': @@ -466,7 +469,7 @@ importers: version: 2.10.2(@parcel/core@2.10.2) '@parcel/core': specifier: 2.10.2 - version: 2.10.2 + version: 2.10.2(patch_hash=ev7lrsvt5tolou43wvizj5pkc4) '@parcel/optimizer-data-url': specifier: 2.10.2 version: 2.10.2(@parcel/core@2.10.2) @@ -569,9 +572,6 @@ importers: '@parcel/cache': specifier: 2.10.2 version: 2.10.2(@parcel/core@2.10.2) - '@parcel/core': - specifier: 2.10.2 - version: 2.10.2 '@parcel/diagnostic': specifier: 2.10.2 version: 2.10.2 @@ -596,6 +596,9 @@ importers: '@parcel/plugin': specifier: 2.10.2 version: 2.10.2(@parcel/core@2.10.2) + '@parcel/rust': + specifier: 2.10.2 + version: 2.10.2 '@parcel/source-map': specifier: 2.1.1 version: 2.1.1 @@ -618,6 +621,9 @@ importers: specifier: 1.1.1 version: 1.1.1 devDependencies: + '@parcel/core': + specifier: 2.10.2 + version: 2.10.2(patch_hash=ev7lrsvt5tolou43wvizj5pkc4) '@plasmo/config': specifier: workspace:* version: link:../../packages/config @@ -632,7 +638,7 @@ importers: dependencies: '@parcel/core': specifier: 2.10.2 - version: 2.10.2 + version: 2.10.2(patch_hash=ev7lrsvt5tolou43wvizj5pkc4) '@parcel/plugin': specifier: 2.10.2 version: 2.10.2(@parcel/core@2.10.2) @@ -654,7 +660,7 @@ importers: dependencies: '@parcel/core': specifier: 2.10.2 - version: 2.10.2 + version: 2.10.2(patch_hash=ev7lrsvt5tolou43wvizj5pkc4) '@parcel/plugin': specifier: 2.10.2 version: 2.10.2(@parcel/core@2.10.2) @@ -679,7 +685,7 @@ importers: dependencies: '@parcel/core': specifier: 2.10.2 - version: 2.10.2 + version: 2.10.2(patch_hash=ev7lrsvt5tolou43wvizj5pkc4) '@parcel/plugin': specifier: 2.10.2 version: 2.10.2(@parcel/core@2.10.2) @@ -710,7 +716,7 @@ importers: dependencies: '@parcel/core': specifier: 2.10.2 - version: 2.10.2 + version: 2.10.2(patch_hash=ev7lrsvt5tolou43wvizj5pkc4) '@parcel/plugin': specifier: 2.10.2 version: 2.10.2(@parcel/core@2.10.2) @@ -741,7 +747,7 @@ importers: dependencies: '@parcel/core': specifier: 2.10.2 - version: 2.10.2 + version: 2.10.2(patch_hash=ev7lrsvt5tolou43wvizj5pkc4) '@parcel/hash': specifier: 2.9.3 version: 2.9.3 @@ -853,7 +859,7 @@ importers: dependencies: '@parcel/core': specifier: 2.10.2 - version: 2.10.2 + version: 2.10.2(patch_hash=ev7lrsvt5tolou43wvizj5pkc4) '@parcel/hash': specifier: 2.9.3 version: 2.9.3 @@ -884,7 +890,7 @@ importers: dependencies: '@parcel/core': specifier: 2.10.2 - version: 2.10.2 + version: 2.10.2(patch_hash=ev7lrsvt5tolou43wvizj5pkc4) '@parcel/plugin': specifier: 2.10.2 version: 2.10.2(@parcel/core@2.10.2) @@ -918,7 +924,7 @@ importers: dependencies: '@parcel/core': specifier: 2.10.2 - version: 2.10.2 + version: 2.10.2(patch_hash=ev7lrsvt5tolou43wvizj5pkc4) '@parcel/plugin': specifier: 2.10.2 version: 2.10.2(@parcel/core@2.10.2) @@ -940,7 +946,7 @@ importers: dependencies: '@parcel/core': specifier: 2.10.2 - version: 2.10.2 + version: 2.10.2(patch_hash=ev7lrsvt5tolou43wvizj5pkc4) '@parcel/plugin': specifier: 2.10.2 version: 2.10.2(@parcel/core@2.10.2) @@ -965,7 +971,7 @@ importers: dependencies: '@parcel/core': specifier: 2.10.2 - version: 2.10.2 + version: 2.10.2(patch_hash=ev7lrsvt5tolou43wvizj5pkc4) '@parcel/diagnostic': specifier: 2.10.2 version: 2.10.2 @@ -999,7 +1005,7 @@ importers: version: 0.1.1 '@parcel/core': specifier: 2.10.2 - version: 2.10.2 + version: 2.10.2(patch_hash=ev7lrsvt5tolou43wvizj5pkc4) '@parcel/diagnostic': specifier: 2.10.2 version: 2.10.2 @@ -1039,7 +1045,7 @@ importers: dependencies: '@parcel/core': specifier: 2.10.2 - version: 2.10.2 + version: 2.10.2(patch_hash=ev7lrsvt5tolou43wvizj5pkc4) '@parcel/diagnostic': specifier: 2.10.2 version: 2.10.2 @@ -1067,7 +1073,7 @@ importers: dependencies: '@parcel/core': specifier: 2.10.2 - version: 2.10.2 + version: 2.10.2(patch_hash=ev7lrsvt5tolou43wvizj5pkc4) '@parcel/diagnostic': specifier: 2.10.2 version: 2.10.2 @@ -6775,7 +6781,7 @@ packages: peerDependencies: '@parcel/core': ^2.10.2 dependencies: - '@parcel/core': 2.10.2 + '@parcel/core': 2.10.2(patch_hash=ev7lrsvt5tolou43wvizj5pkc4) '@parcel/fs': 2.10.2(@parcel/core@2.10.2) '@parcel/logger': 2.10.2 '@parcel/utils': 2.10.2 @@ -6787,7 +6793,7 @@ packages: peerDependencies: '@parcel/core': ^2.8.3 dependencies: - '@parcel/core': 2.10.2 + '@parcel/core': 2.10.2(patch_hash=ev7lrsvt5tolou43wvizj5pkc4) '@parcel/fs': 2.8.3(@parcel/core@2.10.2) '@parcel/logger': 2.8.3 '@parcel/utils': 2.8.3 @@ -6823,7 +6829,7 @@ packages: dependencies: '@parcel/bundler-default': 2.10.2(patch_hash=g5vra6dvyjgmh75x3ewfdh7vle)(@parcel/core@2.10.2) '@parcel/compressor-raw': 2.10.2(@parcel/core@2.10.2) - '@parcel/core': 2.10.2 + '@parcel/core': 2.10.2(patch_hash=ev7lrsvt5tolou43wvizj5pkc4) '@parcel/namer-default': 2.10.2(@parcel/core@2.10.2) '@parcel/optimizer-css': 2.10.2(@parcel/core@2.10.2) '@parcel/optimizer-htmlnano': 2.10.2(@parcel/core@2.10.2) @@ -6865,7 +6871,7 @@ packages: - uncss dev: false - /@parcel/core@2.10.2: + /@parcel/core@2.10.2(patch_hash=ev7lrsvt5tolou43wvizj5pkc4): resolution: {integrity: sha512-c6hh13oYk9w5creiQ9yCz9GLQ17ZRMonULhJ46J0yoFArynVhNTJ9B5xVst7rS/chOTY8jU0jSdJuxQCR4fjkg==} engines: {node: '>= 12.0.0'} dependencies: @@ -6894,6 +6900,7 @@ packages: msgpackr: 1.9.9 nullthrows: 1.1.1 semver: 7.5.4 + patched: true /@parcel/diagnostic@2.10.2: resolution: {integrity: sha512-FwtphyiV/TJEiYIRYXBOloXp7XhTW37ifRSLr7RdLbDVyn/P9q/7l0+ORlnOL+WuKwbDQtY+dXYLh/ijTsq7qQ==} @@ -6932,7 +6939,7 @@ packages: peerDependencies: '@parcel/core': ^2.10.2 dependencies: - '@parcel/core': 2.10.2 + '@parcel/core': 2.10.2(patch_hash=ev7lrsvt5tolou43wvizj5pkc4) '@parcel/rust': 2.10.2 '@parcel/types': 2.10.2(@parcel/core@2.10.2) '@parcel/utils': 2.10.2 @@ -6945,7 +6952,7 @@ packages: peerDependencies: '@parcel/core': ^2.8.3 dependencies: - '@parcel/core': 2.10.2 + '@parcel/core': 2.10.2(patch_hash=ev7lrsvt5tolou43wvizj5pkc4) '@parcel/fs-search': 2.8.3 '@parcel/types': 2.8.3(@parcel/core@2.10.2) '@parcel/utils': 2.8.3 @@ -7081,7 +7088,7 @@ packages: peerDependencies: '@parcel/core': ^2.10.2 dependencies: - '@parcel/core': 2.10.2 + '@parcel/core': 2.10.2(patch_hash=ev7lrsvt5tolou43wvizj5pkc4) '@parcel/diagnostic': 2.10.2 '@parcel/plugin': 2.10.2(@parcel/core@2.10.2) '@parcel/rust': 2.10.2 @@ -7122,7 +7129,7 @@ packages: peerDependencies: '@parcel/core': ^2.10.2 dependencies: - '@parcel/core': 2.10.2 + '@parcel/core': 2.10.2(patch_hash=ev7lrsvt5tolou43wvizj5pkc4) '@parcel/diagnostic': 2.10.2 '@parcel/fs': 2.10.2(@parcel/core@2.10.2) '@parcel/logger': 2.10.2 @@ -7138,7 +7145,7 @@ packages: peerDependencies: '@parcel/core': ^2.8.3 dependencies: - '@parcel/core': 2.10.2 + '@parcel/core': 2.10.2(patch_hash=ev7lrsvt5tolou43wvizj5pkc4) '@parcel/diagnostic': 2.8.3 '@parcel/fs': 2.8.3(@parcel/core@2.10.2) '@parcel/logger': 2.8.3 @@ -7405,7 +7412,7 @@ packages: peerDependencies: '@parcel/core': ^2.10.2 dependencies: - '@parcel/core': 2.10.2 + '@parcel/core': 2.10.2(patch_hash=ev7lrsvt5tolou43wvizj5pkc4) '@parcel/plugin': 2.10.2(@parcel/core@2.10.2) '@parcel/utils': 2.10.2 '@parcel/workers': 2.10.2(@parcel/core@2.10.2) @@ -7427,7 +7434,7 @@ packages: peerDependencies: '@parcel/core': ^2.10.2 dependencies: - '@parcel/core': 2.10.2 + '@parcel/core': 2.10.2(patch_hash=ev7lrsvt5tolou43wvizj5pkc4) '@parcel/diagnostic': 2.10.2 '@parcel/plugin': 2.10.2(@parcel/core@2.10.2) '@parcel/rust': 2.10.2 @@ -7740,7 +7747,7 @@ packages: peerDependencies: '@parcel/core': ^2.10.2 dependencies: - '@parcel/core': 2.10.2 + '@parcel/core': 2.10.2(patch_hash=ev7lrsvt5tolou43wvizj5pkc4) '@parcel/diagnostic': 2.10.2 '@parcel/logger': 2.10.2 '@parcel/profiler': 2.10.2 @@ -7754,7 +7761,7 @@ packages: peerDependencies: '@parcel/core': ^2.8.3 dependencies: - '@parcel/core': 2.10.2 + '@parcel/core': 2.10.2(patch_hash=ev7lrsvt5tolou43wvizj5pkc4) '@parcel/diagnostic': 2.8.3 '@parcel/logger': 2.8.3 '@parcel/types': 2.8.3(@parcel/core@2.10.2)