AMD dependencies
See original GitHub issueBrowserify writes the following code to each output bundle to ensure compatibility with AMD, CommonJS and traditional globals:
if ("object" == typeof exports) module.exports = e();
else if ("function" == typeof define && define.amd) define(e);
else {
// global stuff...
}
My problem is that I exclude some external libraries from my bundle (like react for example). Since the target system for my bundle is an AMD application, what I want browserify to generate is the following: (note the extended define
clause)
if ("object" == typeof exports) module.exports = e();
else if ("function" == typeof define && define.amd) define(["react"], e);
else {
// global stuff...
}
This does not seem to be possible at the moment.
Issue Analytics
- State:
- Created 8 years ago
- Reactions:1
- Comments:17 (5 by maintainers)
Top Results From Across the Web
Fix CommonJS or AMD dependencies can cause optimization ...
When you use a dependency that is packaged with CommonJS, it can result in larger slower applications. Starting with version 10, Angular now ......
Read more >Angular warning: CommonJS or AMD dependencies ... - GitHub
Hi, I use this amazing library with the angular project. However the Angular warning displays with the following message: Warning: .
Read more >WARNING CommonJS or AMD dependencies can cause ...
Resolve WARNING CommonJS or AMD dependencies can cause optimization in build ANGULAR 10.
Read more >CommonJS or AMD dependencies can cause ... - YouTube
Angular.json CommonJS or AMD dependencies can cause optimization bailouts.
Read more >Adding custom AMD modules - IBM
On the Behaviorr page of the view, select AMD dependencies. · Click Add and then specify the following information: In the Module ID...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@zertosh
Ok, a little bit more explanation.
default AMD module definition with dependencies should looks like
this code will not work almost all the time since dependency most likely is not yet loaded (which is what we currenlty have with browserify):
But the following code will works as expected!!! (this is what we want browserify to do):
I see that changes should be done not only in browserify.js. UMD template is part of umd library and it looks like:
So in order to pass dependencies to
define([],f)
changes in this template should be done and UMD lib should allow to fill these dependencies.After these changes browserify should leverage them and pass dependencies which user specified by
--external
parameter to UMD so template will incorporate them and produce correct umd header.Hi, a simpler solution can be: before load our bundle, execute this simple snippet:
(function() { if (typeof define === "function" && define.amd) { define.amd= false; } })();
and then everything will work without problems. Although is a temporary solution.