I know browserify can consume UMD modules by means of transforms, but when I want to build a lib using browserify, how can I build an UMD module? Is there any transform I can use?
How does browserify bundle a universal module
Asked Answered
If you want to build a UMD module with browserify use the standalone
option. Like:
browserify('./entry.js', {
standalone: 'moduleName',
})
isn't it that
standalone
exposes the module to global namespace? –
Rustle standalone
creates a UMD module. If the code doesn't detect that it's in an AMD or CommonJS environment, it sets a global variable. –
Hardtack From the CLI: browserify -s NameOfModule
This creates a standalone module exposed under the name of your choosing.
Utilize by loading the output file in a browser and access via window.NameOfModule
, or see RequireJS docs on how to use it that way.
Also, JMM's comment is also correct, and is a way you'd configure it in a build script. –
Nomarchy
© 2022 - 2024 — McMap. All rights reserved.
deamdify
like this transform allows you to use AMD module with browserify – RustlenoParse
it. – Hardtack