Skip to content

Commit

Permalink
chore: separation of builds for v1 and v2 (#847)
Browse files Browse the repository at this point in the history
  • Loading branch information
PritishBudhiraja authored Dec 25, 2024
1 parent 4b740d0 commit 821f43d
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 5 deletions.
8 changes: 6 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,14 @@
},
"scripts": {
"build": "webpack --config webpack.common.js",
"build:v2": "cross-env SDK_VERSION=v2 webpack --config webpack.common.js",
"build:integ": "cross-env sdkEnv=integ webpack --config webpack.common.js",
"build:playground": "npm run setup:playground && npm run build",
"build:prod": "cross-env sdkEnv=prod webpack --config webpack.common.js",
"build:playground": "npm run setup:playground && webpack --config webpack.common.js",
"build:sandbox": "cross-env sdkEnv=sandbox webpack --config webpack.common.js",
"build:prod": "cross-env sdkEnv=prod webpack --config webpack.common.js",
"build:integ:v2": "cross-env sdkEnv=integ SDK_VERSION=v2 webpack --config webpack.common.js",
"build:sandbox:v2": "cross-env sdkEnv=sandbox SDK_VERSION=v2 webpack --config webpack.common.js",
"build:prod:v2": "cross-env sdkEnv=prod SDK_VERSION=v2 webpack --config webpack.common.js",
"deploy-to-s3": "node ./scripts/pushToS3.js",
"postinstall": "cd Hyperswitch-React-Demo-App && npm i",
"prepare": "husky install",
Expand Down
1 change: 1 addition & 0 deletions src/GlobalVars.res
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
@val external enableLogging: bool = "enableLogging"
@val external loggingLevelStr: string = "loggingLevel"
@val external maxLogsPushedPerEventName: int = "maxLogsPushedPerEventName"
@val external sdkVersion: string = "sdkVersion"
let targetOrigin: string = "*"
let isInteg = sdkUrl === "https://dev.hyperswitch.io"
let isSandbox = sdkUrl === "https://beta.hyperswitch.io" || sdkUrl === "http://localhost:9050"
Expand Down
17 changes: 14 additions & 3 deletions webpack.common.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,21 @@ const envSdkUrl = getEnvVariable("ENV_SDK_URL", "");
const envBackendUrl = getEnvVariable("ENV_BACKEND_URL", "");
const envLoggingUrl = getEnvVariable("ENV_LOGGING_URL", "");

/*
* SDK Version Compatibility:
* v0: Compatible with API v1
* v1: Compatible with API v1
* v2: Compatible with API v2
* The default SDK version is "v1".
*/
const sdkVersion = getEnvVariable("SDK_VERSION", "v1");

const repoVersion = require("./package.json").version;
const majorVersion = "v" + repoVersion.split(".")[0];
const repoName = require("./package.json").name;
const repoPublicPath =
sdkEnv === "local" ? "" : `/web/${repoVersion}/${majorVersion}`;
sdkEnv === "local" ? "" : `/web/${repoVersion}/${sdkVersion}`;

const getSdkUrl = (env, customUrl) => {
if (customUrl) return customUrl;
Expand Down Expand Up @@ -81,6 +91,7 @@ module.exports = (publicPath = "auto") => {
enableLogging: ENABLE_LOGGING,
loggingLevel: JSON.stringify(loggingLevel),
maxLogsPushedPerEventName: JSON.stringify(maxLogsPushedPerEventName),
sdkVersion: JSON.stringify(sdkVersion),
};

const plugins = [
Expand Down Expand Up @@ -137,7 +148,7 @@ module.exports = (publicPath = "auto") => {
output: {
path:
sdkEnv && sdkEnv !== "local"
? path.resolve(__dirname, "dist", sdkEnv)
? path.resolve(__dirname, "dist", sdkEnv, sdkVersion)
: path.resolve(__dirname, "dist"),
clean: true,
publicPath: `${repoPublicPath}/`,
Expand Down

0 comments on commit 821f43d

Please sign in to comment.