Skip to content

Commit 40a512e

Browse files
authored
feat(web-global-build): impl (#1225)
<!-- Please use this template for your pull request. --> <!-- Please use the sections that you need and delete other sections --> ## This PR - Implements a global (IIFE) build for the web. - Adds support for global distribution via CDN by including `unpkg` and `jsdelivr` fields in `package.json`. ### Notes - The global build outputs to `dist/global/index.js`. - The global bundle is exposed under the global name `OpenFeature`. ### Follow-up Tasks - Consider adding automated tests or validation for the global bundle. - If this bundle should be included in a release checklist or CI, link the appropriate issue here. ### How to test 1. Run `npm run build` and ensure `dist/global/index.js` is generated. 2. Serve the file locally or upload to a CDN and verify that `window.OpenFeature` is available in the browser console. ### Motivation Trying to load OpenFeature as a first dependency before browser will resolve any modules. --------- Signed-off-by: Patryk Zdunowski <[email protected]>
1 parent 28850b7 commit 40a512e

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

packages/web/package.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
"version": "1.5.0",
44
"description": "OpenFeature SDK for Web",
55
"main": "./dist/cjs/index.js",
6+
"unpkg": "dist/global/index.min.js",
7+
"jsdelivr": "dist/global/index.min.js",
68
"files": [
79
"dist/"
810
],
@@ -20,8 +22,10 @@
2022
"clean": "shx rm -rf ./dist",
2123
"build:web-esm": "esbuild src/index.ts --bundle --external:@openfeature/core --sourcemap --target=es2015 --platform=browser --format=esm --outfile=./dist/esm/index.js --analyze",
2224
"build:web-cjs": "esbuild src/index.ts --bundle --external:@openfeature/core --sourcemap --target=es2015 --platform=browser --format=cjs --outfile=./dist/cjs/index.js --analyze",
25+
"build:web-global": "esbuild src/index.ts --bundle --sourcemap --target=es2015 --platform=browser --format=iife --outfile=./dist/global/index.js --global-name=OpenFeature --analyze",
26+
"build:web-global:min": "esbuild src/index.ts --bundle --sourcemap --target=es2015 --platform=browser --format=iife --outfile=./dist/global/index.min.js --global-name=OpenFeature --minify --analyze",
2327
"build:rollup-types": "rollup -c ../../rollup.config.mjs",
24-
"build": "npm run clean && npm run build:web-esm && npm run build:web-cjs && npm run build:rollup-types",
28+
"build": "npm run clean && npm run build:web-esm && npm run build:web-cjs && npm run build:web-global && npm run build:web-global:min && npm run build:rollup-types",
2529
"postbuild": "shx cp ./../../package.esm.json ./dist/esm/package.json",
2630
"current-version": "echo $npm_package_version",
2731
"prepack": "shx cp ./../../LICENSE ./LICENSE",

0 commit comments

Comments
 (0)