question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Provide build process for standalone bundle

See original GitHub issue

A 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:closed
  • Created 8 years ago
  • Comments:9 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
cthraxcommented, Mar 6, 2016

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. 😃

0reactions
jvandemocommented, Apr 14, 2017

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found