Skip to content

Commit

Permalink
Set bundle config as internal environment variables (#1077)
Browse files Browse the repository at this point in the history
Set bundle config as internal env vars so they're also accessible by any other parcel plugins.

Co-authored-by: L <[email protected]>
  • Loading branch information
tbrockman and louisgv authored Sep 27, 2024
1 parent e7ccd95 commit 2885b2e
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 2885b2e

Please sign in to comment.