-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
External module bundling #4754
External module bundling #4754
Conversation
@@ -167,6 +245,64 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi | |||
/** Called once the emit of the node is done */ | |||
let emitEnd = function (node: Node) { }; | |||
|
|||
/** Called to build the opening part of a bundled module wrapper */ | |||
let emitBundleWrapperStart: Map<Function> = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be Map<() => void>
.
write(`System.register([], function(${exportFunctionForFile}) {`); | ||
writeLine(); | ||
increaseIndent(); | ||
let exportStarName = emitExportStarFunction(undefined); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/* localNames */
switch(part) { | ||
case "": | ||
case ".": | ||
break; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indent from case clauses
does this implementation support the use case of transitive multi-file bundles? scenario: the structure we really want is a namespace for each of A and B and something 'dll-like' which wraps them up. however, Class2 must be defined in an external module to be able to import NpmModule. this causes a cascade of module usage: in reality project A and B might each have dozens or hundreds of classes, none of which have any reason to be defined in modules and internally microloaded other than the fact that some leaf of the internal dependency tree uses NpmModule. is this going to function without causing some sort of massive overhead? |
In the end, this at present does support offloading module dependencies to the external module loader when in-bundle resolution fails (the bundle consisting of every TS file in your project, rather than just those deemed 'reachable' from the entrypoint). This passthru works well for On that note - should our bundler bundle in reachable non-ts dependencies, a la browserify or webpack? Or is the TS project the exclusive scope of the bundle, and external bits are left to the user to package/bundle? A practical example would be bundling angular2 - I've been able to bundle it with the bundler here with some changes without it bundling in In either case, in situations like "bundleDependencies": {
"angular2/angular2": "angular2",
"jQuery": "jquery"
} to allow your bundle-external import statements import * as ng from 'angular2/angular2';
import * as $ from 'jQuery';
import SomeComponent from './somecomponent';
ng.bootstrap(SomeComponent);
$('title').html('SomeComponent Test'); to be depended upon correctly in the resulting bundle: System.register(["angular2", "jquery"], function(exports_1) {
var angular2_min_js;
var jquery_min_js;
//...
return {
setters: [function(m){angular2_min_js = m;}, function(m){jquery_min_js = m;}],
execute: function() {
//...
}
};
}); I propose adding this option hash, rather than traversing imports and attempting to identify what is bundle local ourselves, to support the same dynamic cases as mentioned in the original issue, but with bundle-external modules. Granted, we could do both - attempt automagic external dependency finding and defer to such a hash option if present. |
After some conversation, I think we've decided to simply autodetect external imports - I'm considering confirmed external imports as external and It also looks like we're going to just bundle TS, and only TS within our own package - so I'll need to test that we don't bundle anything across package bounds. |
Can you include work as part of #1544 in this change so that we issue an error and quit when
Or some variation of the above. |
@DanielRosenwasser You sure you didn't want to tack that on to #4811 instead? It deals with changes to |
Implements #4434 loosely based on the feedback in the issue and some internal feedback.
Changes from the original proposal:
Things to do (aside from integrate feedback):