Reference the CommonJS helpers when a file is not explicitly a module. (#8518)

This commit is contained in:
Logan Smyth
2018-08-23 15:09:14 -07:00
committed by GitHub
parent 22bcfbe469
commit 023044c1d4
13 changed files with 67 additions and 51 deletions

View File

@@ -107,7 +107,6 @@ export default declare((api, options, dirname) => {
);
}
const helpersDir = useESModules ? "helpers/esm" : "helpers";
const injectCoreJS2 = `${corejsVersion}` === "2";
const moduleName = injectCoreJS2
? "@babel/runtime-corejs2"
@@ -145,6 +144,11 @@ export default declare((api, options, dirname) => {
const blockHoist =
isInteropHelper && !isModule(file.path) ? 4 : undefined;
const helpersDir =
useESModules && file.path.node.sourceType === "module"
? "helpers/esm"
: "helpers";
return this.addDefaultImport(
`${modulePath}/${helpersDir}/${name}`,
name,