-
Notifications
You must be signed in to change notification settings - Fork 4
Open
Description
Hi there, I'm not sure if I have found use for this tool yet or not, but it seems promising.
I've got a pretty big react native (expo) project setup and it took me a while to get it to compile with this plugin.
My goal is to see if I can speed this up.
Here are some changes I had to make to the code to get around various errors that came up when running v1.0.23
diff --git a/node_modules/babel-plugin-transform-barrels/src/barrel.js b/node_modules/babel-plugin-transform-barrels/src/barrel.js
index da7bc6a..41e77c6 100644
--- a/node_modules/babel-plugin-transform-barrels/src/barrel.js
+++ b/node_modules/babel-plugin-transform-barrels/src/barrel.js
@@ -289,10 +289,10 @@ class BarrelFile {
}
getDeepestDirectSpecifierObject(specifierObj) {
- const { esmPath, localName } = specifierObj;
+ const { esmPath, absEsmPath, localName } = specifierObj;
if (BarrelFile.isBarrelFilename(esmPath) && esmPath !== this.path) {
if (this.resolvedPathObject?.packageJsonExports) return specifierObj;
- const resolvedPathObject = resolver.resolve(esmPath ,this.path);
+ const resolvedPathObject = resolver.resolve(absEsmPath, this.path);
if (resolvedPathObject.packageJsonExports) return specifierObj;
const barrelFile = BarrelFileManagerFacade.getBarrelFile(resolvedPathObject.absEsmFile);
if (barrelFile.isBarrelFileContent) {
diff --git a/node_modules/babel-plugin-transform-barrels/src/executorConfig.js b/node_modules/babel-plugin-transform-barrels/src/executorConfig.js
index b9bf56b..7e3ec22 100644
--- a/node_modules/babel-plugin-transform-barrels/src/executorConfig.js
+++ b/node_modules/babel-plugin-transform-barrels/src/executorConfig.js
@@ -155,7 +155,7 @@ class ExecutorFactory {
jest.load();
return jest;
default:
- const defaultExecutor = new ExecutorConfig();
+ const defaultExecutor = new ExecutorConfig(alias, extensions);
defaultExecutor.load();
return defaultExecutor;
}
diff --git a/node_modules/babel-plugin-transform-barrels/src/main.js b/node_modules/babel-plugin-transform-barrels/src/main.js
index e5ccf81..7f6e3ce 100644
--- a/node_modules/babel-plugin-transform-barrels/src/main.js
+++ b/node_modules/babel-plugin-transform-barrels/src/main.js
@@ -22,7 +22,9 @@ const importDeclarationVisitor = (path, state) => {
const directSpecifierASTArray = []
for (const specifier of importsSpecifiers) {
const importedName = specifier?.imported?.name || "default";
- const importSpecifier = barrelFile.getDirectSpecifierObject(importedName).toImportSpecifier();
+ const directSpecifier = barrelFile.getDirectSpecifierObject(importedName)
+ if (!directSpecifier) return;
+ const importSpecifier = directSpecifier.toImportSpecifier();
if (!importSpecifier.path) return;
importSpecifier.localName = specifier.local.name;
const transformedASTImport = AST.createASTImportDeclaration(importSpecifier);
Metadata
Metadata
Assignees
Labels
No labels