diff --git a/packages/babel-helpers/src/index.ts b/packages/babel-helpers/src/index.ts index 5a422f226374..cf8c3c28601e 100644 --- a/packages/babel-helpers/src/index.ts +++ b/packages/babel-helpers/src/index.ts @@ -271,7 +271,11 @@ function loadHelper(name: string) { const fn = (): File => { if (!process.env.BABEL_8_BREAKING) { if (!FileClass) { - return { ast: file(helper.ast()) } as File; + const fakeFile = { ast: file(helper.ast()), path: null } as File; + traverse(fakeFile.ast, { + Program: path => (fakeFile.path = path).stop(), + }); + return fakeFile; } } return new FileClass(