-
Notifications
You must be signed in to change notification settings - Fork 12.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Suggestion: Module code generation UMD #2036
Comments
We would need a better understanding of how many people are using this module style before doing the work to support it. Do you have any examples of large projects using this? |
Yes, many large projects are having there own style of umd. |
|
note that emitting true umd is quite problematic not only you have to grasp the names of modules for the global case (aka |
Eh? Are you meaning that in order to output a global object you normally need to specify a different variable name for it?
Not 100% sure what you are talking about here. There was a bug in a very old version of the example UMD wrapper code, but there is nothing that requires a UMD module to do factory scanning. [edits: sorry, it’s way too late for me to be posting things on github 😴 ] |
Some AMD loader scans your file for
Yup exactly UMD also manages global objects so you'll have to provide the module with 2 names. |
Maybe TS can get away with outputting a UMD lite format that is just CJS-or-AMD, since the compiler already will not let you export external modules if you don’t specify a module format? I think that’s really what people want anyway, just something that works with a browser module loader and works with the built-in Node.js loader, so we can get away from the stupidity of having to either load an AMD loader into Node.js to load AMD-format modules, or run Browserify to mostly-load CJS-format modules in a browser, or double compilation for each platform. |
nice timing. I'm having to create a manual header and footer on the compiled .js file that wraps the UMD header and the factory function at the bottom. (and add a module.exports hack, setting module to commonjs) |
Thanks @csnover |
Will this be available in 1.5? |
This is going to be available in |
When is 1.6 alpha/beta coming? I'd really like this feature for the redevelopment of RxJS 3... |
Correction it should be available in the next public release for 1.5; you can use the latest from master or release-1.5 as well. |
@mhegazy ... so just |
yup. |
Wow I just realized I can use UMD now 😄 |
Add a third variant
umd
(Universal Module Definition) in module flag on compiler.This way you can reuse your JS code in both Nodejs and Browser without needing to compile twice (amd and commonjs) and still be able to code modular style (import/export) in TS.
The text was updated successfully, but these errors were encountered: