diff --git a/tools/plunker-builder/builder.js b/tools/plunker-builder/builder.js
index 033e6fee62..9189cc0cf9 100644
--- a/tools/plunker-builder/builder.js
+++ b/tools/plunker-builder/builder.js
@@ -9,7 +9,9 @@ var fs = require("fs");
var globby = require('globby');
var mkdirp = require('mkdirp');
-var indexHtmlTranslator = require('./indexHtmlTranslator');
+var fileTranslator = require('./translator/fileTranslator');
+var indexHtmlRules = require('./translator/rules/indexHtml');
+var systemjsConfigExtrasRules = require('./translator/rules/systemjsConfigExtras');
var regionExtractor = require('../doc-shredder/regionExtractor');
class PlunkerBuilder {
@@ -141,7 +143,7 @@ class PlunkerBuilder {
}
if (relativeFileName == 'index.html') {
- content = indexHtmlTranslator.translate(content);
+ content = fileTranslator.translate(content, indexHtmlRules);
if (config.description == null) {
// set config.description to title from index.html
var matches = /
(.*)<\/title>/.exec(content);
@@ -150,6 +152,11 @@ class PlunkerBuilder {
}
}
}
+
+ if (relativeFileName == 'systemjs.config.extras.js') {
+ content = fileTranslator.translate(content, systemjsConfigExtrasRules);
+ }
+
content = regionExtractor.removeDocTags(content, extn.substr(1));
this.options.addField(postData, relativeFileName, content);
diff --git a/tools/plunker-builder/translator/fileTranslator.js b/tools/plunker-builder/translator/fileTranslator.js
new file mode 100644
index 0000000000..b4a050f80f
--- /dev/null
+++ b/tools/plunker-builder/translator/fileTranslator.js
@@ -0,0 +1,47 @@
+// var first_time = true; // DIAGNOSTIC
+
+function translate(html, rulesFile) {
+ rulesFile.rulesToApply.forEach(function(rxDatum) {
+ var rxRule = rulesFile.rules[rxDatum.pattern];
+ // rxFrom is a rexexp
+ var rxFrom = rxRule.from;
+ if (rxDatum.from) {
+ var from = rxDatum.from.replace('/', '\/');
+ var rxTemp = rxFrom.toString();
+ rxTemp = rxTemp.replace('%tag%', from);
+ rxFrom = rxFromString(rxTemp);
+ }
+ // rxTo is a string
+ var rxTo = rxRule.to;
+ if (rxDatum.to) {
+ var to = rxDatum.to;
+ to = Array.isArray(to) ? to : [to];
+ to = to.map(function (toItem) {
+ return rxTo.replace("%tag%", toItem);
+ });
+ rxTo = to.join("\n ");
+ }
+
+ /* DIAGNOSTIC
+ if (first_time && rxDatum.pattern === 'zone_pkg') {
+ first_time = false;
+
+ console.log('zone_pkg');
+ console.log(' rxFrom: '+rxFrom);
+ console.log(' rxTo: '+rxTo);
+ console.log(' replace: ' + html.replace(rxFrom, rxTo ));
+ }
+ */
+ html = html.replace(rxFrom, rxTo );
+ });
+
+ return html;
+}
+
+function rxFromString(rxString) {
+ var rx = /^\/(.*)\/(.*)/;
+ var pieces = rx.exec(rxString);
+ return RegExp(pieces[1], pieces[2]);
+}
+
+module.exports = {translate: translate};
diff --git a/tools/plunker-builder/indexHtmlTranslator.js b/tools/plunker-builder/translator/rules/indexHtml.js
similarity index 70%
rename from tools/plunker-builder/indexHtmlTranslator.js
rename to tools/plunker-builder/translator/rules/indexHtml.js
index 254fdcc750..68263885d1 100644
--- a/tools/plunker-builder/indexHtmlTranslator.js
+++ b/tools/plunker-builder/translator/rules/indexHtml.js
@@ -1,8 +1,4 @@
-module.exports = {
- translate: translate
-};
-
-var _rxRules = {
+var rules = {
basehref: {
from: //,
to: ''
@@ -41,7 +37,7 @@ var _rxRules = {
},
};
-var _rxData = [
+var rulesToApply = [
{
pattern: 'basehref',
},
@@ -113,49 +109,7 @@ var _rxData = [
}
];
-
-// var first_time = true; // DIAGNOSTIC
-
-function translate(html) {
- _rxData.forEach(function(rxDatum) {
- var rxRule = _rxRules[rxDatum.pattern];
- // rxFrom is a rexexp
- var rxFrom = rxRule.from;
- if (rxDatum.from) {
- var from = rxDatum.from.replace('/', '\/');
- var rxTemp = rxFrom.toString();
- rxTemp = rxTemp.replace('%tag%', from);
- rxFrom = rxFromString(rxTemp);
- }
- // rxTo is a string
- var rxTo = rxRule.to;
- if (rxDatum.to) {
- var to = rxDatum.to;
- to = Array.isArray(to) ? to : [to];
- to = to.map(function (toItem) {
- return rxTo.replace("%tag%", toItem);
- });
- rxTo = to.join("\n ");
- }
-
- /* DIAGNOSTIC
- if (first_time && rxDatum.pattern === 'zone_pkg') {
- first_time = false;
-
- console.log('zone_pkg');
- console.log(' rxFrom: '+rxFrom);
- console.log(' rxTo: '+rxTo);
- console.log(' replace: ' + html.replace(rxFrom, rxTo ));
- }
- */
- html = html.replace(rxFrom, rxTo );
- });
-
- return html;
-}
-
-function rxFromString(rxString) {
- var rx = /^\/(.*)\/(.*)/;
- var pieces = rx.exec(rxString);
- return RegExp(pieces[1], pieces[2]);
-}
+module.exports = {
+ rules: rules,
+ rulesToApply: rulesToApply
+};
diff --git a/tools/plunker-builder/translator/rules/systemjsConfigExtras.js b/tools/plunker-builder/translator/rules/systemjsConfigExtras.js
new file mode 100644
index 0000000000..d774197eac
--- /dev/null
+++ b/tools/plunker-builder/translator/rules/systemjsConfigExtras.js
@@ -0,0 +1,24 @@
+var rules = {
+ system_extra_main: {
+ from: /main:\s*[\'|\"]index.js[\'|\"]/g,
+ to: 'main: "index.ts"'
+ },
+ system_extra_defaultExtension: {
+ from: /defaultExtension:\s*[\'|\"]js[\'|\"]/g,
+ to: 'defaultExtension: "ts"'
+ }
+};
+
+var rulesToApply = [
+ {
+ pattern: 'system_extra_main'
+ },
+ {
+ pattern: 'system_extra_defaultExtension'
+ }
+];
+
+module.exports = {
+ rules: rules,
+ rulesToApply: rulesToApply
+};