From d32f587e3cbbc332704022f80ff9bd854e3fcee6 Mon Sep 17 00:00:00 2001 From: Sebastian McKenzie Date: Sat, 7 Mar 2015 03:31:24 +1100 Subject: [PATCH] expose dynamicImports when es6.modules is blacklisted babel/ember-cli-babel#24 --- src/babel/transformation/file.js | 6 +++++- .../transformers/internal/module-formatter.js | 4 ++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/babel/transformation/file.js b/src/babel/transformation/file.js index e4d0de2391..d7528b052a 100644 --- a/src/babel/transformation/file.js +++ b/src/babel/transformation/file.js @@ -339,7 +339,11 @@ export default class File { this.dynamicImported.push(declar); if (noDefault) this.dynamicImportedNoDefault.push(declar); - this.moduleFormatter.importSpecifier(specifiers[0], declar, this.dynamicImports); + if (this.transformers["es6.modules"].canRun()) { + this.moduleFormatter.importSpecifier(specifiers[0], declar, this.dynamicImports); + } else { + this.dynamicImports.push(declar); + } } return id; diff --git a/src/babel/transformation/transformers/internal/module-formatter.js b/src/babel/transformation/transformers/internal/module-formatter.js index a601ff4230..5d17476725 100644 --- a/src/babel/transformation/transformers/internal/module-formatter.js +++ b/src/babel/transformation/transformers/internal/module-formatter.js @@ -1,12 +1,12 @@ import * as strict from "../../helpers/strict"; export function Program(program, parent, scope, file) { - if (!file.transformers["es6.modules"].canRun()) return; - strict.wrap(program, function () { program.body = file.dynamicImports.concat(program.body); }); + if (!file.transformers["es6.modules"].canRun()) return; + if (file.moduleFormatter.transform) { file.moduleFormatter.transform(program); }