diff --git a/src/babel/transformation/file/index.js b/src/babel/transformation/file/index.js index bec58c718a..ad8f851e83 100644 --- a/src/babel/transformation/file/index.js +++ b/src/babel/transformation/file/index.js @@ -337,6 +337,7 @@ export default class File { ref._generated = true; ref.id = uid; ref.type = "FunctionDeclaration"; + this.attachAuxiliaryComment(ref); this.path.unshiftContainer("body", ref); } else { ref._compact = true; diff --git a/test/core/api.js b/test/core/api.js index 2fb0330ff3..4464600e3e 100644 --- a/test/core/api.js +++ b/test/core/api.js @@ -18,6 +18,16 @@ suite("api", function () { assert.ok(!result.ast); }); + test("{ auxiliaryComment }", function () { + assert.ok(transform("class Foo {}", { + auxiliaryComment: "foobar" + }).code.indexOf("foobar") >= 0); + + assert.ok(transform("for (let i in bar) { foo(function () { i; }); break; continue; }", { + auxiliaryComment: "foobar" + }).code.indexOf("foobar") >= 0); + }); + suite("getModuleId() {} option", function () { // As of this commit, `getModuleId` is the only option that isn't JSON // compatible which is why it's not inside /test/core/fixtures/transformation