From 2b2f58a8234e068f35107ae4b58cb96a8d6ceb98 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Ribaudo?= Date: Thu, 10 Mar 2022 00:44:49 +0100 Subject: [PATCH] Fix `@babel/core@7.0.0` compatibility --- packages/babel-helpers/src/index.ts | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) 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(