Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
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
12 changes: 9 additions & 3 deletions modules/angular1_router/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,20 +48,26 @@ function main(modulesDirectory) {
*/
var IMPORT_RE = new RegExp("import \\{?([\\w\\n_, ]+)\\}? from '(.+)';?", 'g');
var INJECT_RE = new RegExp("@Inject\\(ROUTER_PRIMARY_COMPONENT\\)", 'g');
var IMJECTABLE_RE = new RegExp("@Injectable\\(\\)", 'g');
var INJECTABLE_RE = new RegExp("@Injectable\\(\\)", 'g');
var REQUIRE_RE = new RegExp("require\\('(.*?)'\\);", 'g');
function transform(contents) {
contents = contents.replace(INJECT_RE, '').replace(IMJECTABLE_RE, '');
contents = contents.replace(INJECT_RE, '').replace(INJECTABLE_RE, '');
contents = contents.replace(IMPORT_RE, function (match, imports, includePath) {
//TODO: remove special-case
if (isFacadeModule(includePath) || includePath === './router_outlet') {
return '';
}
return match;
});
return ts.transpile(contents, {
contents = ts.transpile(contents, {
target: ts.ScriptTarget.ES5,
module: ts.ModuleKind.CommonJS
});

// Rename require functions from transpiled imports
contents = contents.replace(REQUIRE_RE, 'routerRequire(\'$1\');');

return contents;
}

function isFacadeModule(modulePath) {
Expand Down
2 changes: 1 addition & 1 deletion modules/angular1_router/src/module_template.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ function routerFactory($q, $location, $$directiveIntrospector, $browser, $rootSc
OpaqueToken: function () {},
Inject: function () {}
};
var require = function () {return exports;};
var routerRequire = function () {return exports;};

// When this file is processed, the line below is replaced with
// the contents of the compiled TypeScript classes.
Expand Down