UMD is a library that can be used in both the browser and Node.js environments. It is a combination of CommonJS and AMD.
output.format
to umd
in the Rslib configuration file.output.umdName
to the name of the UMD library.output.externals
to specify the external dependencies that the UMD library depends on, lib.autoExtension
is enabled by default for UMD.The following Rslib config is an example to build a UMD library.
output.format: 'umd'
: instruct Rslib to build in UMD format.output.umdName: 'RslibUmdExample'
: set the export name of the UMD library.output.externals.react: 'React'
: specify the external dependency react
could be accessed by window.React
.runtime: 'classic'
: use the classic runtime of React to support applications that using React version under 18.