FogelAI / babel-plugin-transform-barrels

A Babel plugin that transforms indirect imports through a barrel file (index.js) into direct imports.
14 stars 1 forks source link

I'm getting this error Cannot read properties of null (reading 'program') #2

Open sibelius opened 8 months ago

sibelius commented 8 months ago

I'm using this in a monorepo, similar to https://github.com/sibelius/relay-workshop

FogelAI commented 8 months ago

Hi @sibelius

I have released a new version of the plugin (v1.0.9) that adds support for workspaces. This update should resolve your issue.

Please update your version and let me know if it resolves your issue.

Thanks

sibelius commented 7 months ago

still breaking

at BarrelFilesMapping.createSpecifiersMapping (../../node_modules/babel-plugin-transform-barrels/src/barrel.js:182:15)
      at BarrelFilesMapping.getDirectSpecifierObject (../../node_modules/babel-plugin-transform-barrels/src/barrel.js:240:12)
      at ../../node_modules/babel-plugin-transform-barrels/src/barrel.js:260:45
          at Array.map (<anonymous>)
      at PluginPass.importDeclarationVisitor (../../node_modules/babel-plugin-transform-barrels/src/barrel.js:258:61)
      at call (../../node_modules/@babel/traverse/src/visitors.ts:293:14)
      at NodePath.call [as _call] (../../node_modules/@babel/traverse/src/path/context.ts:35:20)
      at NodePath._call [as call] (../../node_modules/@babel/traverse/src/path/context.ts:20:17)
      at NodePath.call [as visit] (../../node_modules/@babel/traverse/src/path/context.ts:94:31)
      at TraversalContext.visit [as visitQueue] (../../node_modules/@babel/traverse/src/context.ts:144:16)
      at TraversalContext.visitQueue [as visitMultiple] (../../node_modules/@babel/traverse/src/context.ts:98:17)
      at TraversalContext.visitMultiple [as visit] (../../node_modules/@babel/traverse/src/context.ts:174:19)
      at visit (../../node_modules/@babel/traverse/src/traverse-node.ts:40:17)
      at NodePath.visit (../../node_modules/@babel/traverse/src/path/context.ts:101:33)
      at TraversalContext.visit [as visitQueue] (../../node_modules/@babel/traverse/src/context.ts:144:16)
      at TraversalContext.visitQueue [as visitSingle] (../../node_modules/@babel/traverse/src/context.ts:108:19)
      at TraversalContext.visitSingle [as visit] (../../node_modules/@babel/traverse/src/context.ts:176:19)
      at visit (../../node_modules/@babel/traverse/src/traverse-node.ts:40:17)
      at traverse (../../node_modules/@babel/traverse/src/index.ts:82:15)
      at transformFile (../../node_modules/@babel/core/src/transformation/index.ts:124:15)
          at transformFile.next (<anonymous>)
      at transformFile (../../node_modules/@babel/core/src/transformation/index.ts:48:12)
          at run.next (<anonymous>)
      at transform (../../node_modules/@babel/core/src/transform.ts:29:20)
          at transform.next (<anonymous>)
      at evaluateSync (../../node_modules/gensync/index.js:251:28)

try on relay-workshop

sibelius commented 1 month ago

another error

Cannot read properties of undefined (reading 'absEsmFile')

at PluginPass.importDeclarationVisitor (../../node_modules/babel-plugin-transform-barrels/src/main.js:15:79)
      at call (../../node_modules/@babel/traverse/src/visitors.ts:304:14)
      at NodePath.call [as _call] (../../node_modules/@babel/traverse/src/path/context.ts:36:20)
      at NodePath.call (../../node_modules/@babel/traverse/src/path/context.ts:21:18)
      at NodePath.call [as visit] (../../node_modules/@babel/traverse/src/path/context.ts:95:31)
      at TraversalContext.visit [as visitQueue] (../../node_modules/@babel/traverse/src/context.ts:147:16)
      at TraversalContext.visitQueue [as visitMultiple] (../../node_modules/@babel/traverse/src/context.ts:98:17)
      at TraversalContext.visitMultiple [as visit] (../../node_modules/@babel/traverse/src/context.ts:177:19)
      at visit (../../node_modules/@babel/traverse/src/traverse-node.ts:40:17)
      at NodePath.visit (../../node_modules/@babel/traverse/src/path/context.ts:102:33)
      at TraversalContext.visit [as visitQueue] (../../node_modules/@babel/traverse/src/context.ts:147:16)
      at TraversalContext.visitQueue [as visitSingle] (../../node_modules/@babel/traverse/src/context.ts:108:19)
      at TraversalContext.visitSingle [as visit] (../../node_modules/@babel/traverse/src/context.ts:179:19)
      at visit (../../node_modules/@babel/traverse/src/traverse-node.ts:40:17)
      at traverse (../../node_modules/@babel/traverse/src/index.ts:82:15)
      at transformFile (../../node_modules/@babel/core/src/transformation/index.ts:124:15)
          at transformFile.next (<anonymous>)
      at transformFile (../../node_modules/@babel/core/src/transformation/index.ts:48:12)
          at run.next (<anonymous>)
      at transform (../../node_modules/@babel/core/src/transform.ts:29:20)
          at transform.next (<anonymous>)
      at evaluateSync (../../node_modules/gensync/index.js:251:28)
      at sync (../../node_modules/gensync/index.js:89:14)
      at fn (../../node_modules/@babel/core/src/errors/rewrite-stack-trace.ts:99:14)
      at transformSync (../../node_modules/@babel/core/src/transform.ts:66:52)
      at Object.process (../testutils/babelBarrel.js:32:29)
      at ScriptTransformer.transformSource (../../node_modules/@jest/transform/build/ScriptTransformer.js:545:31)
      at ScriptTransformer._transformAndBuildScript (../../node_modules/@jest/transform/build/ScriptTransformer.js:674:40)
      at ScriptTransformer.transform (../../node_modules/@jest/transform/build/ScriptTransformer.js:726:19)
srosato commented 1 week ago

I get the same error and I am trying to figure out what part of my code leads to Cannot read properties of undefined (reading 'absEsmFile')

FogelAI commented 1 week ago

Hi @srosato Is this a public project? If so, could you share the repository? Please enable the logging to a file option and add the log file here.