From d847d2b46ddd2615190dee83201ab05497b1bece Mon Sep 17 00:00:00 2001 From: Jared Perreault Date: Wed, 3 Jun 2026 10:20:10 -0400 Subject: [PATCH 1/2] adds cjs export to sdks --- packages/auth-foundation/package.json | 22 ++++++++++++--------- packages/auth-foundation/tsconfig.json | 1 - packages/oauth2-flows/package.json | 10 +++++----- packages/oauth2-flows/tsconfig.json | 3 +-- packages/spa-platform/package.json | 16 ++++++++------- packages/spa-platform/tsconfig.json | 1 - tooling/rollup-config/sdk.mjs | 27 +++++++++++++++++--------- 7 files changed, 46 insertions(+), 34 deletions(-) diff --git a/packages/auth-foundation/package.json b/packages/auth-foundation/package.json index 0735a81..f1a8c81 100644 --- a/packages/auth-foundation/package.json +++ b/packages/auth-foundation/package.json @@ -2,7 +2,7 @@ "name": "@okta/auth-foundation", "version": "0.7.2", "type": "module", - "main": "dist/esm/index.js", + "main": "dist/cjs/index.js", "module": "dist/esm/index.js", "types": "dist/types/index.d.ts", "author": "jared.perreault@okta.com", @@ -20,27 +20,31 @@ "exports": { ".": { "types": "./dist/types/index.d.ts", - "import": "./dist/esm/index.js" + "import": "./dist/esm/index.js", + "require": "./dist/cjs/index.js" }, "./core" : { "types": "./dist/types/core.d.ts", - "import": "./dist/esm/core.js" + "import": "./dist/esm/core.js", + "require": "./dist/cjs/core.js" }, "./internal": { "types": "./dist/types/internal.d.ts", - "import": "./dist/esm/internal.js" + "import": "./dist/esm/internal.js", + "require": "./dist/cjs/internal.js" }, "./package.json": "./package.json" }, "sideEffects": [ - "./src/oktaUserAgent.ts" + "./dist/cjs/oktaUserAgent.js", + "./dist/esm/oktaUserAgent.js" ], "scripts": { "lint": "eslint --ext .js,.ts,.jsx .", - "build": "yarn build:esm && yarn build:types", - "build:watch": "rollup -c --watch & tsc --watch", - "build:esm": "rollup -c", - "build:types": "tsc", + "build": "yarn build:lib && yarn build:types", + "build:watch": "yarn build:lib --watch & yarn build:types --watch", + "build:lib": "rollup -c", + "build:types": "tsc --outDir ./dist/types", "test": "yarn test:unit", "test:unit": "jest", "test:watch": "jest --watchAll", diff --git a/packages/auth-foundation/tsconfig.json b/packages/auth-foundation/tsconfig.json index 8126bc1..04a08d9 100644 --- a/packages/auth-foundation/tsconfig.json +++ b/packages/auth-foundation/tsconfig.json @@ -3,7 +3,6 @@ "compilerOptions": { "rootDir": "./src", "baseUrl": "./", - "outDir": "./dist/types", }, "lib": [ "dom" diff --git a/packages/oauth2-flows/package.json b/packages/oauth2-flows/package.json index 72b47f3..5e467c9 100644 --- a/packages/oauth2-flows/package.json +++ b/packages/oauth2-flows/package.json @@ -2,7 +2,7 @@ "name": "@okta/oauth2-flows", "version": "0.7.2", "type": "module", - "main": "dist/esm/index.js", + "main": "dist/cjs/index.js", "module": "dist/esm/index.js", "types": "dist/types/index.d.ts", "author": "jared.perreault@okta.com", @@ -19,10 +19,10 @@ }, "scripts": { "lint": "eslint --ext .js,.ts,.jsx .", - "build": "yarn build:esm && yarn build:types", - "build:watch": "rollup -c --watch & tsc --watch", - "build:esm": "rollup -c", - "build:types": "tsc", + "build": "yarn build:lib && yarn build:types", + "build:watch": "yarn build:lib --watch & yarn build:types --watch", + "build:lib": "rollup -c", + "build:types": "tsc --outDir ./dist/types", "test": "yarn test:unit", "test:unit": "jest", "test:watch": "jest --watchAll", diff --git a/packages/oauth2-flows/tsconfig.json b/packages/oauth2-flows/tsconfig.json index e8fd525..f0d9c64 100644 --- a/packages/oauth2-flows/tsconfig.json +++ b/packages/oauth2-flows/tsconfig.json @@ -2,8 +2,7 @@ "extends": "@repo/typescript-config/base.json", "compilerOptions": { "rootDir": "./src", - "baseUrl": "./", - "outDir": "./dist/types" + "baseUrl": "./" }, "lib": [ "dom" diff --git a/packages/spa-platform/package.json b/packages/spa-platform/package.json index 1af964c..bf10b18 100644 --- a/packages/spa-platform/package.json +++ b/packages/spa-platform/package.json @@ -2,7 +2,7 @@ "name": "@okta/spa-platform", "version": "0.7.2", "type": "module", - "main": "dist/esm/index.js", + "main": "dist/cjs/index.js", "module": "dist/esm/index.js", "types": "dist/types/index.d.ts", "license": "Apache-2.0", @@ -16,20 +16,22 @@ "exports": { ".": { "types": "./dist/types/index.d.ts", - "import": "./dist/esm/index.js" + "import": "./dist/esm/index.js", + "require": "./dist/cjs/index.js" }, "./flows" : { "types": "./dist/types/flows.d.ts", - "import": "./dist/esm/flows.js" + "import": "./dist/esm/flows.js", + "require": "./dist/cjs/index.js" }, "./package.json": "./package.json" }, "scripts": { "lint": "eslint --ext .js,.ts,.jsx .", - "build": "yarn build:esm && yarn build:types", - "build:watch": "yarn build:esm --watch & yarn build:types --watch", - "build:esm": "rollup -c", - "build:types": "tsc", + "build": "yarn build:lib && yarn build:types", + "build:watch": "yarn build:lib --watch & yarn build:types --watch", + "build:lib": "rollup -c", + "build:types": "tsc --outDir ./dist/types", "test": "yarn test:unit", "test:watch": "jest --watchAll", "test:unit": "jest" diff --git a/packages/spa-platform/tsconfig.json b/packages/spa-platform/tsconfig.json index 571abdb..28129d5 100644 --- a/packages/spa-platform/tsconfig.json +++ b/packages/spa-platform/tsconfig.json @@ -3,7 +3,6 @@ "compilerOptions": { "rootDir": "./src", "baseUrl": "./", - "outDir": "./dist/types" }, "lib": [ "dom" diff --git a/tooling/rollup-config/sdk.mjs b/tooling/rollup-config/sdk.mjs index 70b071e..e34d782 100644 --- a/tooling/rollup-config/sdk.mjs +++ b/tooling/rollup-config/sdk.mjs @@ -13,14 +13,24 @@ const __dirname = path.dirname(__filename); export default function (tsModule, packageJson) { return { input: 'src/index.ts', - output: { - dir: 'dist/esm', - format: 'es', - exports: 'named', - sourcemap: true, - preserveModules: true, - preserveModulesRoot: 'src', - }, + output: [ + { + dir: 'dist/esm', + format: 'es', + exports: 'named', + sourcemap: true, + preserveModules: true, + preserveModulesRoot: 'src', + }, + { + dir: 'dist/cjs', + format: 'cjs', + exports: 'named', + sourcemap: true, + preserveModules: true, + preserveModulesRoot: 'src', + }, + ], plugins: [ replace({ __PKG_NAME__: JSON.stringify(packageJson.name), @@ -35,7 +45,6 @@ export default function (tsModule, packageJson) { emitDeclarationOnly: false, module: 'nodenext', moduleResolution: 'nodenext', - outDir: 'dist/esm', } }), cleanup({ From 21b9afc3e09c4eeb5b413900195fcce6e77c4252 Mon Sep 17 00:00:00 2001 From: Jared Perreault Date: Wed, 3 Jun 2026 11:36:08 -0400 Subject: [PATCH 2/2] fixes tests --- packages/oauth2-flows/package.json | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/packages/oauth2-flows/package.json b/packages/oauth2-flows/package.json index 5e467c9..d3ed8df 100644 --- a/packages/oauth2-flows/package.json +++ b/packages/oauth2-flows/package.json @@ -17,6 +17,14 @@ "engines": { "node": ">=20.11.0" }, + "exports": { + ".": { + "types": "./dist/types/index.d.ts", + "import": "./dist/esm/index.js", + "require": "./dist/cjs/index.js" + }, + "./package.json": "./package.json" + }, "scripts": { "lint": "eslint --ext .js,.ts,.jsx .", "build": "yarn build:lib && yarn build:types",