Skip to content

Commit

Permalink
Set bundle config as internal env vars so they're also accessible by …
Browse files Browse the repository at this point in the history
…any other parcel plugins.
  • Loading branch information
tbrockman committed Sep 18, 2024
1 parent 62e4c39 commit 5a83cd1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
6 changes: 6 additions & 0 deletions cli/plasmo/src/features/env/env-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,12 @@ function maybeParseJSON(value: string): any {
return match ? JSON.parse(match[1]) : value
}

export const setInternalEnv = (env: Record<string, string>) => {
for (const [key, value] of Object.entries(env)) {
process.env[`${INTERNAL_ENV_PREFIX}${constantCase(key)}`] = value
}
}

export const getEnvFileNames = () => {
const nodeEnv = process.env.NODE_ENV
const flagMap = getFlagMap()
Expand Down
3 changes: 3 additions & 0 deletions cli/plasmo/src/features/helpers/create-parcel-bundler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { Parcel, type ParcelOptions } from "@plasmohq/parcel-core"
import type { PlasmoManifest } from "~features/manifest-factory/base"

import { getPackageManager } from "./package-manager"
import { setInternalEnv } from "~features/env/env-config"

const PackageInstallerMap = {
npm: ParcelPM.Npm,
Expand Down Expand Up @@ -104,6 +105,8 @@ export const createParcelBuilder = async (
: ["last 1 Chrome version"]
}

setInternalEnv(bundleConfig)

const bundler = new Parcel({
inputFS,
packageManager,
Expand Down

0 comments on commit 5a83cd1

Please sign in to comment.