Merge pull request #6280 from loganfsmyth/only-transform-modules

Only transform 'this'->'undefined' and inject 'use strict' if module statements are present
This commit is contained in:
Logan Smyth
2017-09-23 11:24:52 -07:00
committed by GitHub
35 changed files with 87 additions and 71 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,

View File

@@ -0,0 +1,3 @@
"use strict";
var foo = () => void 0;

View File

@@ -0,0 +1,3 @@
"use strict";
(void 0).foo();

View File

@@ -0,0 +1,3 @@
"use strict";
var self = void 0;