Skip to content

Commit cb9a15b

Browse files
committed
Remove process.env refs from the browser artifact
Both the Node.js and the browser artifacts that we generate contain dynamic references to entries in `process.env`. This does not play nicely when bundling apps intended for the browser. As of now, the only function that does this is `getBaseUrl`, which is a function intended for internal development only. This change makes sure that this function is defined for the browser in such a way that does not reference `process.env` anymore and just returns the Production base URL.
1 parent 42a6515 commit cb9a15b

File tree

6 files changed

+27
-13
lines changed

6 files changed

+27
-13
lines changed

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/sdk",
3-
"version": "2.0.12",
3+
"version": "2.0.13",
44
"private": false,
55
"repository": "github:PipedreamHQ/pipedream-sdk-typescript",
66
"type": "commonjs",
@@ -93,6 +93,8 @@
9393
"webpack": "^5.97.1"
9494
},
9595
"browser": {
96+
"./dist/cjs/wrapper/utils/getBaseUrl.js": "./dist/cjs/wrapper/utils/getBaseUrl.browser.js",
97+
"./dist/esm/wrapper/utils/getBaseUrl.mjs": "./dist/esm/wrapper/utils/getBaseUrl.browser.mjs",
9698
"fs": false,
9799
"os": false,
98100
"path": false,

src/version.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export const SDK_VERSION = "2.0.12";
1+
export const SDK_VERSION = "2.0.13";

src/wrapper/Pipedream.ts

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { ProjectEnvironment } from "../api/index.js";
33
import { Workflows } from "../api/resources/workflows/client/Client.js";
44
import { PipedreamClient } from "../Client.js";
55
import { PipedreamEnvironment } from "../environments.js";
6+
import { getBaseUrl } from "./utils/getBaseUrl.js";
67

78
export type PipedreamClientOpts = {
89
/**
@@ -43,17 +44,6 @@ export type PipedreamClientOpts = {
4344
workflowDomain?: string;
4445
};
4546

46-
/**
47-
* Returns the base URL for the Pipedream API based on the provided environment.
48-
* It replaces any placeholders in the environment string with corresponding
49-
* environment variables.
50-
*
51-
* @param environment - The Pipedream environment string.
52-
* @returns The base URL for the Pipedream API.
53-
*/
54-
const getBaseUrl = (environment: PipedreamEnvironment) =>
55-
environment.replace(/\$\{(\w+)\}/g, (_, name) => process.env[name] ?? "");
56-
5747
export class Pipedream extends PipedreamClient {
5848
private _workflowDomain?: string;
5949
private _workflows: Workflows | undefined;
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { PipedreamEnvironment } from "../../environments.js";
2+
3+
/**
4+
* Returns the base URL for the Pipedream API based on the provided environment.
5+
* Browser-optimized version that returns the production environment directly.
6+
*
7+
* @returns The base URL for the Pipedream API.
8+
*/
9+
export const getBaseUrl = () => PipedreamEnvironment.Prod;

src/wrapper/utils/getBaseUrl.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { PipedreamEnvironment } from "../../environments.js";
2+
3+
/**
4+
* Returns the base URL for the Pipedream API based on the provided environment.
5+
* It replaces any placeholders in the environment string with corresponding
6+
* environment variables.
7+
*
8+
* @param environment - The Pipedream environment string.
9+
* @returns The base URL for the Pipedream API.
10+
*/
11+
export const getBaseUrl = (environment: PipedreamEnvironment) =>
12+
environment.replace(/\$\{(\w+)\}/g, (_, name) => process.env[name] ?? "");

src/wrapper/utils/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { getBaseUrl } from "./getBaseUrl.js";

0 commit comments

Comments
 (0)