Reference the CommonJS helpers when a file is not explicitly a module. (#8518)
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user