Only transform this/use strict if a module.

This commit is contained in:
Logan Smyth
2017-09-14 17:36:25 -07:00
parent 8e6b5de042
commit 2b88e079ef
27 changed files with 46 additions and 58 deletions

View File

@@ -1,4 +1,5 @@
import {
isModule,
rewriteModuleStatementsAndPrepareHeader,
isSideEffectImport,
buildNamespaceInitStatements,
@@ -11,6 +12,10 @@ export default function({ types: t }) {
visitor: {
Program: {
exit(path, state) {
// For now this requires unambiguous rather that just sourceType
// because Babel currently parses all files as sourceType:module.
if (!isModule(path, true /* requireUnambiguous */)) return;
const {
loose,
allowTopLevelThis,