From 645d184da0abc2b854931f2718dd75e9d382c616 Mon Sep 17 00:00:00 2001 From: austinkelleher Date: Tue, 7 Feb 2017 10:46:47 -0500 Subject: [PATCH] Fixes #487 - Add marko compiler type and version to compiled output. --- bin/markoc.js | 6 ++-- compiler/Builder.js | 5 +++ compiler/CodeWriter.js | 5 +-- compiler/CompileContext.js | 9 ++++- compiler/ast/Comment.js | 36 +++++++++++++++++++ compiler/ast/TemplateRoot.js | 12 ++++++- compiler/config.js | 10 ++++-- compiler/index.js | 2 +- .../compileFileForBrowser-callback.js/test.js | 9 +++-- .../compileFileForBrowser.js/test.js | 6 ++-- .../compileForBrowser-callback.js/test.js | 8 ++--- .../expected.js | 13 +++++++ .../template.marko | 1 + .../test.js | 24 +++++++++++++ .../api-compiler/compileForBrowser.js/test.js | 6 ++-- test/autotests/api-compiler/configure/test.js | 5 +-- .../codegen/block-comment/expected.js | 4 +++ test/autotests/codegen/block-comment/index.js | 5 +++ test/autotests/codegen/comment/expected.js | 1 + test/autotests/codegen/comment/index.js | 5 +++ .../expected.js | 13 +++++++ .../template.marko | 1 + .../test.js | 15 ++++++++ test/compiler-browser-test.js | 8 +++-- test/compiler-test.js | 10 +++--- test/inline-test.js | 5 +-- test/markoc-tests.js | 8 ++++- test/vdom-compiler-test.js | 4 +-- test/widgets-compilation-deprecated-tests.js | 8 +++-- test/widgets-compilation-tests.js | 8 +++-- 30 files changed, 210 insertions(+), 42 deletions(-) create mode 100644 compiler/ast/Comment.js create mode 100644 test/autotests/api-compiler/compileForBrowser-write-version-comment.js/expected.js create mode 100644 test/autotests/api-compiler/compileForBrowser-write-version-comment.js/template.marko create mode 100644 test/autotests/api-compiler/compileForBrowser-write-version-comment.js/test.js create mode 100644 test/autotests/codegen/block-comment/expected.js create mode 100644 test/autotests/codegen/block-comment/index.js create mode 100644 test/autotests/codegen/comment/expected.js create mode 100644 test/autotests/codegen/comment/index.js create mode 100644 test/autotests/markoc/single-template-write-version-comment/expected.js create mode 100644 test/autotests/markoc/single-template-write-version-comment/template.marko create mode 100644 test/autotests/markoc/single-template-write-version-comment/test.js diff --git a/bin/markoc.js b/bin/markoc.js index a783d3cf2..aa767d7b6 100644 --- a/bin/markoc.js +++ b/bin/markoc.js @@ -121,7 +121,9 @@ if (args.vdom) { } var compileOptions = { - output: output + output: output, + compilerType: 'markoc', + compilerVersion: markoPkgVersion || markocPkgVersion }; var force = args.force; @@ -377,4 +379,4 @@ if (args.clean) { }); } -} \ No newline at end of file +} diff --git a/compiler/Builder.js b/compiler/Builder.js index f999629f8..6f7d9c9e4 100644 --- a/compiler/Builder.js +++ b/compiler/Builder.js @@ -9,6 +9,7 @@ var FunctionDeclaration = require('./ast/FunctionDeclaration'); var FunctionCall = require('./ast/FunctionCall'); var Literal = require('./ast/Literal'); var Identifier = require('./ast/Identifier'); +var Comment = require('./ast/Comment'); var If = require('./ast/If'); var ElseIf = require('./ast/ElseIf'); var Else = require('./ast/Else'); @@ -273,6 +274,10 @@ class Builder { return new HtmlComment({comment}); } + comment(comment) { + return new Comment({comment}); + } + htmlElement(tagName, attributes, body, argument, openTagOnly, selfClosed) { if (typeof tagName === 'object' && !(tagName instanceof Node)) { let def = arguments[0]; diff --git a/compiler/CodeWriter.js b/compiler/CodeWriter.js index d22479fab..41aa2689a 100644 --- a/compiler/CodeWriter.js +++ b/compiler/CodeWriter.js @@ -6,6 +6,7 @@ const Literal = require('./ast/Literal'); const Identifier = require('./ast/Identifier'); const ok = require('assert').ok; const Container = require('./ast/Container'); +const Comment = require('./ast/Comment'); const isValidJavaScriptVarName = require('./util/isValidJavaScriptVarName'); class CodeWriter { @@ -84,7 +85,7 @@ class CodeWriter { // Do nothing } else if (this._code.endsWith(';')) { this._code += '\n'; - } else if (this._code.endsWith('\n' + this.currentIndent)) { + } else if (this._code.endsWith('\n' + this.currentIndent) || node instanceof Comment) { // Do nothing } else { this._code += ';\n'; @@ -260,4 +261,4 @@ class CodeWriter { } } -module.exports = CodeWriter; \ No newline at end of file +module.exports = CodeWriter; diff --git a/compiler/CompileContext.js b/compiler/CompileContext.js index 5e07e6d5d..9f5ece8dd 100644 --- a/compiler/CompileContext.js +++ b/compiler/CompileContext.js @@ -17,6 +17,8 @@ var Walker = require('./Walker'); var EventEmitter = require('events').EventEmitter; var utilFingerprint = require('./util/fingerprint'); +const markoPkgVersion = require('../package.json').version; + const FLAG_PRESERVE_WHITESPACE = 'PRESERVE_WHITESPACE'; const deresolveOptions = { @@ -102,7 +104,12 @@ class CompileContext extends EventEmitter { this.options = options || {}; + const writeVersionComment = this.options.writeVersionComment; + this.outputType = this.options.output || 'html'; + this.compilerType = this.options.compilerType || 'marko'; + this.compilerVersion = this.options.compilerVersion || markoPkgVersion; + this.writeVersionComment = writeVersionComment !== 'undefined' ? writeVersionComment : true; this._vars = {}; this._uniqueVars = new UniqueVars(); @@ -737,4 +744,4 @@ CompileContext.prototype.util = { isJavaScriptReservedWord: require('./util/isJavaScriptReservedWord') }; -module.exports = CompileContext; \ No newline at end of file +module.exports = CompileContext; diff --git a/compiler/ast/Comment.js b/compiler/ast/Comment.js new file mode 100644 index 000000000..1c48c51b7 --- /dev/null +++ b/compiler/ast/Comment.js @@ -0,0 +1,36 @@ +'use strict'; + +const Node = require('./Node'); + +function _isMultilineComment(comment) { + return comment && comment.indexOf('\n') !== -1; +} + +class Comment extends Node { + constructor(def) { + super('Comment'); + + const comment = def.comment; + + if (_isMultilineComment(comment)) { + this.comment = `/*\n${comment}\n*/`; + } else { + this.comment = `// ${comment}`; + } + } + + generateCode(codegen) { + return this; + } + + writeCode(writer) { + var name = this.comment; + writer.write(name); + } + + toString() { + return this.comment; + } +} + +module.exports = Comment; diff --git a/compiler/ast/TemplateRoot.js b/compiler/ast/TemplateRoot.js index 153212259..bbdbd85b7 100644 --- a/compiler/ast/TemplateRoot.js +++ b/compiler/ast/TemplateRoot.js @@ -11,6 +11,12 @@ function createVarsArray(vars) { }); } +function _buildVersionComment(builder, context) { + const version = context.compilerVersion; + const compilerType = context.compilerType; + return builder.comment(`Compiled using ${compilerType}@${version} - DO NOT EDIT`); +} + class TemplateRoot extends Node { constructor(def) { super('TemplateRoot'); @@ -86,6 +92,10 @@ class TemplateRoot extends Node { let body = []; + if (context.writeVersionComment) { + body.push(_buildVersionComment(builder, context)); + } + let staticNodes = context.getStaticNodes([templateDeclaration]); if (staticNodes.length) { body = body.concat(staticNodes); @@ -155,4 +165,4 @@ class TemplateRoot extends Node { } } -module.exports = TemplateRoot; \ No newline at end of file +module.exports = TemplateRoot; diff --git a/compiler/config.js b/compiler/config.js index 103b1ca73..0d1bec615 100644 --- a/compiler/config.js +++ b/compiler/config.js @@ -37,8 +37,14 @@ if (g.__MARKO_CONFIG) { preserveWhitespace: false, // The default output mode for compiled templates - output: 'html' + output: 'html', + + /** + * Whether the version should be written to the template as a comment e.g. + * // Compiled using marko@4.0.0 - DO NOT EDIT + */ + writeVersionComment: true }; } -module.exports = config; \ No newline at end of file +module.exports = config; diff --git a/compiler/index.js b/compiler/index.js index c690bfb84..079362675 100644 --- a/compiler/index.js +++ b/compiler/index.js @@ -238,4 +238,4 @@ exports.registerTaglib = function(path) { clearCaches(); }; -exports.isVDOMSupported = true; \ No newline at end of file +exports.isVDOMSupported = true; diff --git a/test/autotests/api-compiler/compileFileForBrowser-callback.js/test.js b/test/autotests/api-compiler/compileFileForBrowser-callback.js/test.js index 529d7fc14..ccde7f6e7 100644 --- a/test/autotests/api-compiler/compileFileForBrowser-callback.js/test.js +++ b/test/autotests/api-compiler/compileFileForBrowser-callback.js/test.js @@ -1,15 +1,14 @@ -var fs = require('fs'); var path = require('path'); exports.check = function(marko, markoCompiler, expect, helpers, done) { var compiler = require('marko/compiler'); var templatePath = path.join(__dirname, 'template.marko'); - compiler.compileFileForBrowser(templatePath, {}, function(err, compiledTemplate) { + compiler.compileFileForBrowser(templatePath, { + writeVersionComment: false + }, function(err, compiledTemplate) { helpers.compare(compiledTemplate.code, '.js'); done(); }); - - -}; \ No newline at end of file +}; diff --git a/test/autotests/api-compiler/compileFileForBrowser.js/test.js b/test/autotests/api-compiler/compileFileForBrowser.js/test.js index 3b3c870ce..36e08bdaf 100644 --- a/test/autotests/api-compiler/compileFileForBrowser.js/test.js +++ b/test/autotests/api-compiler/compileFileForBrowser.js/test.js @@ -5,9 +5,11 @@ exports.check = function(marko, markoCompiler, expect, helpers, done) { var compiler = require('marko/compiler'); var templatePath = path.join(__dirname, 'template.marko'); - var compiledTemplate = compiler.compileFileForBrowser(templatePath, {}); + var compiledTemplate = compiler.compileFileForBrowser(templatePath, { + writeVersionComment: false + }); helpers.compare(compiledTemplate.code, '.js'); done(); -}; \ No newline at end of file +}; diff --git a/test/autotests/api-compiler/compileForBrowser-callback.js/test.js b/test/autotests/api-compiler/compileForBrowser-callback.js/test.js index f8a957e53..bf6b1f448 100644 --- a/test/autotests/api-compiler/compileForBrowser-callback.js/test.js +++ b/test/autotests/api-compiler/compileForBrowser-callback.js/test.js @@ -7,11 +7,11 @@ exports.check = function(marko, markoCompiler, expect, helpers, done) { var templateSrc = fs.readFileSync(templatePath, { encoding: 'utf8' }); - compiler.compileForBrowser(templateSrc, templatePath, {}, function(err, compiledTemplate) { + compiler.compileForBrowser(templateSrc, templatePath, { + writeVersionComment: false + }, function(err, compiledTemplate) { helpers.compare(compiledTemplate.code, '.js'); done(); }); - - -}; \ No newline at end of file +}; diff --git a/test/autotests/api-compiler/compileForBrowser-write-version-comment.js/expected.js b/test/autotests/api-compiler/compileForBrowser-write-version-comment.js/expected.js new file mode 100644 index 000000000..f3abba7e1 --- /dev/null +++ b/test/autotests/api-compiler/compileForBrowser-write-version-comment.js/expected.js @@ -0,0 +1,13 @@ +var marko_template = module.exports = require("marko/vdom").t(); + +function render(input, out) { + var data = input; + + out.t("Hello "); + + out.t(data.name); + + out.t("!"); +} + +marko_template._ = render; diff --git a/test/autotests/api-compiler/compileForBrowser-write-version-comment.js/template.marko b/test/autotests/api-compiler/compileForBrowser-write-version-comment.js/template.marko new file mode 100644 index 000000000..4b6673751 --- /dev/null +++ b/test/autotests/api-compiler/compileForBrowser-write-version-comment.js/template.marko @@ -0,0 +1 @@ +-- Hello ${data.name}! \ No newline at end of file diff --git a/test/autotests/api-compiler/compileForBrowser-write-version-comment.js/test.js b/test/autotests/api-compiler/compileForBrowser-write-version-comment.js/test.js new file mode 100644 index 000000000..24bc21463 --- /dev/null +++ b/test/autotests/api-compiler/compileForBrowser-write-version-comment.js/test.js @@ -0,0 +1,24 @@ +var fs = require('fs'); +var path = require('path'); +var markoVersion = require('../../../../package.json').version; + +function _appendMarkoVersionComment(str) { + return '// Compiled using marko@' + markoVersion + ' - DO NOT EDIT\n' + str; +} + +exports.check = function(marko, markoCompiler, expect, helpers, done) { + var compiler = require('marko/compiler'); + var templatePath = path.join(__dirname, 'template.marko'); + var expectedPath = path.join(__dirname, 'expected.js'); + + var templateSrc = fs.readFileSync(templatePath, { encoding: 'utf8' }); + + var compiledTemplate = compiler.compileForBrowser(templateSrc, templatePath); + var expected = fs.readFileSync(expectedPath, { encoding: 'utf8' }); + + compiledTemplate.code = _appendMarkoVersionComment(compiledTemplate.code); + expected = _appendMarkoVersionComment(expected); + + expect(compiledTemplate.code).to.deep.equal(expected); + done(); +}; diff --git a/test/autotests/api-compiler/compileForBrowser.js/test.js b/test/autotests/api-compiler/compileForBrowser.js/test.js index d0daac890..ce6228ee2 100644 --- a/test/autotests/api-compiler/compileForBrowser.js/test.js +++ b/test/autotests/api-compiler/compileForBrowser.js/test.js @@ -6,9 +6,11 @@ exports.check = function(marko, markoCompiler, expect, helpers, done) { var templatePath = path.join(__dirname, 'template.marko'); var templateSrc = fs.readFileSync(templatePath, { encoding: 'utf8' }); - var compiledTemplate = compiler.compileForBrowser(templateSrc, templatePath, {}); + var compiledTemplate = compiler.compileForBrowser(templateSrc, templatePath, { + writeVersionComment: false + }); helpers.compare(compiledTemplate.code, '.js'); done(); -}; \ No newline at end of file +}; diff --git a/test/autotests/api-compiler/configure/test.js b/test/autotests/api-compiler/configure/test.js index 5dbc94776..53a03e63d 100644 --- a/test/autotests/api-compiler/configure/test.js +++ b/test/autotests/api-compiler/configure/test.js @@ -1,8 +1,9 @@ -exports.check = function(marko, markoCompiler, expect, helpers, done) { +exports.check = function(marko, markoCompiler, expect, helpers, done) { var compiler = require('marko/compiler'); compiler.configure(); // Use defaults expect(compiler.config.writeToDisk).to.equal(true); expect(compiler.config.preserveWhitespace).to.equal(false); + expect(compiler.config.writeVersionComment).to.equal(true); compiler.configure({ preserveWhitespace: true @@ -14,4 +15,4 @@ exports.check = function(marko, markoCompiler, expect, helpers, done) { expect(compiler.config.writeToDisk).to.equal(true); expect(compiler.config.preserveWhitespace).to.equal(false); done(); -}; \ No newline at end of file +}; diff --git a/test/autotests/codegen/block-comment/expected.js b/test/autotests/codegen/block-comment/expected.js new file mode 100644 index 000000000..df17126d2 --- /dev/null +++ b/test/autotests/codegen/block-comment/expected.js @@ -0,0 +1,4 @@ +/* +This is a comment +on multiple lines +*/ diff --git a/test/autotests/codegen/block-comment/index.js b/test/autotests/codegen/block-comment/index.js new file mode 100644 index 000000000..9ca9bfeb7 --- /dev/null +++ b/test/autotests/codegen/block-comment/index.js @@ -0,0 +1,5 @@ +'use strict'; + +module.exports = function(builder) { + return builder.comment('This is a comment\non multiple lines'); +}; diff --git a/test/autotests/codegen/comment/expected.js b/test/autotests/codegen/comment/expected.js new file mode 100644 index 000000000..35915f268 --- /dev/null +++ b/test/autotests/codegen/comment/expected.js @@ -0,0 +1 @@ +// This is a comment diff --git a/test/autotests/codegen/comment/index.js b/test/autotests/codegen/comment/index.js new file mode 100644 index 000000000..6491f86b8 --- /dev/null +++ b/test/autotests/codegen/comment/index.js @@ -0,0 +1,5 @@ +'use strict'; + +module.exports = function(builder) { + return builder.comment('This is a comment'); +}; diff --git a/test/autotests/markoc/single-template-write-version-comment/expected.js b/test/autotests/markoc/single-template-write-version-comment/expected.js new file mode 100644 index 000000000..520686368 --- /dev/null +++ b/test/autotests/markoc/single-template-write-version-comment/expected.js @@ -0,0 +1,13 @@ +var marko_template = module.exports = require("marko/html").t(__filename), + marko_helpers = require("marko/runtime/html/helpers"), + marko_escapeXml = marko_helpers.x; + +function render(input, out) { + var data = input; + + out.w("Hello " + + marko_escapeXml(data.name) + + "!"); +} + +marko_template._ = render; diff --git a/test/autotests/markoc/single-template-write-version-comment/template.marko b/test/autotests/markoc/single-template-write-version-comment/template.marko new file mode 100644 index 000000000..4b6673751 --- /dev/null +++ b/test/autotests/markoc/single-template-write-version-comment/template.marko @@ -0,0 +1 @@ +-- Hello ${data.name}! \ No newline at end of file diff --git a/test/autotests/markoc/single-template-write-version-comment/test.js b/test/autotests/markoc/single-template-write-version-comment/test.js new file mode 100644 index 000000000..95a2fb9cb --- /dev/null +++ b/test/autotests/markoc/single-template-write-version-comment/test.js @@ -0,0 +1,15 @@ +var expect = require('chai').expect; +var markoVersion = require('../../../../package.json').version; + +function _appendMarkoVersionComment(str) { + return '// Compiled using markoc@' + markoVersion + ' - DO NOT EDIT\n' + str; +} + +exports.test = function(helpers) { + helpers.spawnSync(['template.marko']); + + var compiledFile = helpers.readSync('template.marko.js').toString(); + var expectedFile = _appendMarkoVersionComment(helpers.readSync('expected.js')); + + expect(compiledFile).to.deep.equal(expectedFile); +}; diff --git a/test/compiler-browser-test.js b/test/compiler-browser-test.js index 4670a6d6f..a2e2e8320 100644 --- a/test/compiler-browser-test.js +++ b/test/compiler-browser-test.js @@ -24,11 +24,13 @@ describe('compiler (browser target)', function() { main = require(mainPath); } + var compilerOptions = { writeVersionComment: false }; + if (main && main.checkError) { var e; try { - compiler.compileFileForBrowser(templatePath); + compiler.compileFileForBrowser(templatePath, compilerOptions); } catch(_e) { e = _e; } @@ -41,7 +43,7 @@ describe('compiler (browser target)', function() { done(); } else { - var compiledTemplate = compiler.compileFileForBrowser(templatePath, main && main.compilerOptions); + var compiledTemplate = compiler.compileFileForBrowser(templatePath, Object.assign(compilerOptions, main && main.compilerOptions)); if(main && main.checkTemplate) { main.checkTemplate(compiledTemplate); @@ -56,4 +58,4 @@ describe('compiler (browser target)', function() { } }); -}); \ No newline at end of file +}); diff --git a/test/compiler-test.js b/test/compiler-test.js index 01d81b484..7217f0b60 100644 --- a/test/compiler-test.js +++ b/test/compiler-test.js @@ -22,11 +22,13 @@ describe('compiler', function() { main = require(mainPath); } + var compilerOptions = { writeVersionComment: false }; + if (main && main.checkError) { var e; try { - compiler.compileFile(templatePath); + compiler.compileFile(templatePath, compilerOptions); } catch(_e) { e = _e; } @@ -39,14 +41,14 @@ describe('compiler', function() { done(); } else if(main && main.checkTemplate) { - var template = require('marko').load(templatePath, main.compilerOptions); + var template = require('marko').load(templatePath, Object.assign(compilerOptions, main.compilerOptions)); main.checkTemplate(template); done(); } else { - var compiledSrc = compiler.compileFile(templatePath, main && main.compilerOptions); + var compiledSrc = compiler.compileFile(templatePath, Object.assign(compilerOptions, main && main.compilerOptions)); helpers.compare(compiledSrc, '.js'); done(); } }); -}); \ No newline at end of file +}); diff --git a/test/inline-test.js b/test/inline-test.js index 2250e31d2..be0483c45 100644 --- a/test/inline-test.js +++ b/test/inline-test.js @@ -17,10 +17,11 @@ describe('inline', function() { var indexPath = path.join(dir, 'index.js'); var inlineCompiler = compiler.createInlineCompiler(indexPath); + var compilerOptions = { writeVersionComment: false }; var src = fs.readFileSync(indexPath, { encoding: 'utf8' }); src = src.replace(/marko`([^`]*)`/g, function(match, templateSrc) { - var compiled = inlineCompiler.compile(templateSrc); + var compiled = inlineCompiler.compile(templateSrc, compilerOptions); return compiled.code; }); @@ -57,4 +58,4 @@ describe('inline', function() { }); -}); \ No newline at end of file +}); diff --git a/test/markoc-tests.js b/test/markoc-tests.js index ef89025d5..902c8a18a 100644 --- a/test/markoc-tests.js +++ b/test/markoc-tests.js @@ -16,10 +16,16 @@ describe('markoc' , function() { var autoTestDir = nodePath.join(__dirname, 'autotests/markoc'); autotest.scanDir(autoTestDir, function run(dir, helpers, done) { - var testModule = require(nodePath.join(dir, 'test.js')); + const testModule = require(nodePath.join(dir, 'test.js')); + helpers.existsSync = function(filename) { return fs.existsSync(nodePath.join(dir, filename)); }; + + helpers.readSync = function(filename) { + return fs.readFileSync(nodePath.join(dir, filename)); + }; + helpers.spawnSync = function(args, options) { options = options || {}; if (!options.cwd) { diff --git a/test/vdom-compiler-test.js b/test/vdom-compiler-test.js index cbaa50085..67bceeb0e 100644 --- a/test/vdom-compiler-test.js +++ b/test/vdom-compiler-test.js @@ -24,7 +24,7 @@ describe('compiler (vdom)', function() { main = require(mainPath); } - var compilerOptions = { output: 'vdom' }; + var compilerOptions = { output: 'vdom', writeVersionComment: false }; if (main && main.checkError) { var e; @@ -51,4 +51,4 @@ describe('compiler (vdom)', function() { } }); -}); \ No newline at end of file +}); diff --git a/test/widgets-compilation-deprecated-tests.js b/test/widgets-compilation-deprecated-tests.js index 61a0ef9e8..f763b4230 100644 --- a/test/widgets-compilation-deprecated-tests.js +++ b/test/widgets-compilation-deprecated-tests.js @@ -34,11 +34,13 @@ describe('marko-widgets (compilation, deprecated)', function() { main = require(mainPath); } + var compilerOptions = { writeVersionComment: false }; + if (main && main.checkError) { var e; try { - compiler.compileFile(templatePath); + compiler.compileFile(templatePath, compilerOptions); } catch(_e) { e = _e; } @@ -50,9 +52,9 @@ describe('marko-widgets (compilation, deprecated)', function() { main.checkError(e); done(); } else { - var actualSrc = compiler.compileFile(templatePath, main && main.compilerOptions); + var actualSrc = compiler.compileFile(templatePath, Object.assign(compilerOptions, main && main.compilerOptions)); actualSrc = stripVarData(actualSrc); - + var actualPath = path.join(testPath, './actual.js'); var expectedPath = path.join(testPath, './expected.js'); fs.writeFileSync(actualPath, actualSrc); diff --git a/test/widgets-compilation-tests.js b/test/widgets-compilation-tests.js index 9e52712a0..a66d7c25f 100644 --- a/test/widgets-compilation-tests.js +++ b/test/widgets-compilation-tests.js @@ -35,11 +35,13 @@ describe('marko-widgets (compilation)', function() { main = require(mainPath); } + var compilerOptions = { writeVersionComment: false }; + if (main && main.checkError) { var e; try { - compiler.compileFile(templatePath); + compiler.compileFile(templatePath, compilerOptions); } catch(_e) { e = _e; } @@ -51,7 +53,7 @@ describe('marko-widgets (compilation)', function() { main.checkError(e); done(); } else { - var actualSrc = compiler.compileFile(templatePath, main && main.compilerOptions); + var actualSrc = compiler.compileFile(templatePath, Object.assign(compilerOptions, main && main.compilerOptions)); actualSrc = stripVarData(actualSrc); var actualPath = path.join(testPath, './actual.js'); @@ -63,4 +65,4 @@ describe('marko-widgets (compilation)', function() { } }); }); -}); \ No newline at end of file +});