Create File class for babel helpers (#10575)

* add test

* fix: pass File to helper traverser

* pass babel.File to helpers.ensure
This commit is contained in:
Huáng Jùnliàng
2020-03-17 04:58:46 -04:00
committed by GitHub
parent 748897be07
commit 4bf36e64da
8 changed files with 61 additions and 10 deletions

View File

@@ -2,6 +2,7 @@ import * as helpers from "@babel/helpers";
import generator from "@babel/generator";
import template from "@babel/template";
import * as t from "@babel/types";
import File from "../transformation/file/file";
// Wrapped to avoid wasting time parsing this when almost no-one uses
// build-external-helpers.
@@ -136,6 +137,7 @@ function buildHelpers(body, namespace, whitelist) {
const ref = (refs[name] = getHelperReference(name));
helpers.ensure(name, File);
const { nodes } = helpers.get(name, getHelperReference, ref);
body.push(...nodes);

View File

@@ -174,7 +174,7 @@ export default class File {
}
// make sure that the helper exists
helpers.ensure(name);
helpers.ensure(name, File);
const uid = (this.declarations[name] = this.scope.generateUidIdentifier(
name,