diff --git a/packages/babel-helpers/src/index.ts b/packages/babel-helpers/src/index.ts index 5a422f226374..0a6f2a6234d6 100644 --- a/packages/babel-helpers/src/index.ts +++ b/packages/babel-helpers/src/index.ts @@ -271,7 +271,19 @@ 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()), + code: "[internal Babel helper code]", + path: null, + inputMap: null, + } as File; + traverse(fakeFile.ast, { + Program(path) { + fakeFile.path = path; + path.stop(); + }, + }); + return fakeFile; } } return new FileClass(