Provide build process for standalone bundle
See original GitHub issueA library can easily be imported using import
statements.
But how can we bundle a library as a standalone file that we can e.g. include from a CDN using a <script>
element?
E.g. Angular publishes: https://code.angularjs.org/2.0.0-alpha.46/angular2.js
When looking at the source code, the last few lines in the file automatically register the library:
System.register("angular2/angular2", ["angular2/common", "angular2/core", "angular2/profile", "angular2/lifecycle_hooks", "angular2/bootstrap", "angular2/upgrade"], true, function(require, exports, module) {
var global = System.global,
__define = global.define;
global.define = undefined;
function __export(m) {
for (var p in m)
if (!exports.hasOwnProperty(p))
exports[p] = m[p];
}
__export(require("angular2/common"));
__export(require("angular2/core"));
__export(require("angular2/profile"));
__export(require("angular2/lifecycle_hooks"));
__export(require("angular2/bootstrap"));
__export(require("angular2/upgrade"));
global.define = __define;
return module.exports;
});
What is the best way to publish such a distributable library file?
Issue Analytics
- State:
- Created 8 years ago
- Comments:9 (6 by maintainers)
Top Results From Across the Web
Standalone Builds - SurviveJS
To make a bundle for your own library, you need to use a bundler, such as webpack, Rollup, or Parcel. How Bundlers Work#....
Read more >Build and test your Android App Bundle
Android App Bundles are the recommended way to build, publish, and distribute your app across multiple device configurations.
Read more >Standalone JS bundle | Botonic Docs
A standalone JS bundle allows you to encapsulate all your botonic app in a single static file that you can host anywhere and...
Read more >Building Standalone Apps - Expo Documentation
Classic Build service allows you to create standalone binaries for the Expo app using the Expo CLI. You can use that binary to...
Read more >How to deploy bundled applications - Bundler
Start your application servers as usual, and your application will use your bundled environment with the exact same gems you use in development....
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
Should a library provide such a file?
In my experience, when a library provides such a file, it has to either a) bundle all dependencies in such a file b) have no dependencies or c) provide instructions for including dependencies in the page as well.
It seems to me this is one of the exact problems that AMD, SystemJS, webpack and associated technologies are solving. Enabling a consumer to create a single file, or multiple files, as fits their needs without re-introducing old problems. Only new problems. 😃
I have just released v8.1.0, which generates a Flat ES Module, in alignment with the latest Angular Package Format.
See #60 for more information.