Externalizing Common Libraries
To externalize a library from ALL widget bundles, add the library metadata to cdn.libraries.managed
of your Live Configurations.
After adding the library information, 1fe/cli will automatically externalize the library from all widget bundles, and will be provided by the 1fe runtime to all widgets.
cdn.libraries.managed
example
Type
type ExternalLibConfig = { id: string; name: string; version: string; path: string; isPreloaded: boolean; type: 'external';};
Live Configurations
{ "cdn": { "libraries": { "basePrefix": "https://your-cdn.net/libs/", "managed": [ { "id": "lodash", "name": "lodash", "version": "4.17.21", "isPreloaded": true, "path": "lodash.js", "type": "external" } ] } }}
This snippet will empower 1fe to do the following:
-
1fe/cli will externalize lodash when building widget bundles
-
1fe/shell will preload lodash from
https://your-cdn.net/libs/lodash/4.17.21/lodash.js
at runtime.