Skip to content
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

Closed
wants to merge 17 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix style nits
weswigham committed Sep 11, 2015
commit 9840aa4501333ff55fbb97801859828e5f169dc0
24 changes: 11 additions & 13 deletions src/compiler/emitter.ts
Original file line number Diff line number Diff line change
@@ -246,24 +246,24 @@ var __define = (this && this.__define) || (function() {
let emitEnd = function (node: Node) { };

/** Called to build the opening part of a bundled module wrapper */
let emitBundleWrapperStart: Map<Function> = {
[ModuleKind.CommonJS]: () => {
let emitBundleWrapperStart: Map<() => void> = {
[ModuleKind.CommonJS]() {
write("module.exports = ");
},
[ModuleKind.AMD]: () => { //TODO: handle external deps with amd better
[ModuleKind.AMD]() { //TODO: handle external deps with amd better
write("define([\"require\"], function(require){");
writeLine();
increaseIndent();
write("return ");
},
[ModuleKind.UMD]: () => {
[ModuleKind.UMD]() {
writeLines(umdHelper);
write("[\"require\"], function(require){");
writeLine();
increaseIndent();
write("return ");
},
[ModuleKind.System]: () => { //TODO: handle external deps with system
[ModuleKind.System]() { //TODO: handle external deps with system
currentSourceFile = <any>{identifiers: []};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know what you're trying to achieve here, please add a comment.

exportFunctionForFile = makeUniqueName("exports");
writeLine();
@@ -279,23 +279,23 @@ var __define = (this && this.__define) || (function() {
}

/** Called to build the closing part of a bundled module wrapper */
let emitBundleWrapperEnd: Map<Function> = {
[ModuleKind.CommonJS]: () => {
let emitBundleWrapperEnd: Map<() => void> = {
[ModuleKind.CommonJS]() {
write(";");
},
[ModuleKind.AMD]: () => {
[ModuleKind.AMD]() {
write(";");
decreaseIndent();
writeLine();
write("});");
},
[ModuleKind.UMD]: () => {
[ModuleKind.UMD]() {
write(";");
decreaseIndent();
writeLine();
write("});");
},
[ModuleKind.System]: () => {
[ModuleKind.System]() {
write(");");
decreaseIndent();
writeLine();
@@ -341,9 +341,7 @@ var __define = (this && this.__define) || (function() {
write("(function() {");
increaseIndent();
writeLines(defineHelper);
forEach(host.getSourceFiles(), file => {
emitEmitHelpers(file);
});
forEach(host.getSourceFiles(), emitEmitHelpers);
writeLine();
}
forEach(host.getSourceFiles(), sourceFile => {