Last month, ECMAScript modules (ESM) support was shipped in Kosko 1.1. Today, you can use ESM not only in Node.js, but also in browsers. Currently only the following packages are browser-ready. Please make sure to update these packages before using Kosko in a browser.
Kosko can be used in browsers via the programmatic API. In the following example, first we use dynamic import to load environment variables. Then, use the
resolve function to resolve and validate components. And finally, print the resolved manifests with the
See using in browser for more details.
You can try Kosko in the playground, or check the following examples.
- Webpack 5 - GitHub / CodeSandbox
- Parcel 1 - GitHub / CodeSandbox
- Static - GitHub / CodeSandbox
- Sync Environment - GitHub / CodeSandbox
The following APIs were changed in this release.
You don't have to change anything, unless you initialize these classes manually.