Giter Club home page Giter Club logo

Comments (9)

nicolo-ribaudo avatar nicolo-ribaudo commented on June 6, 2024 2

I have a workaround in #213, but it's be good to have a reproduction to figure out if the problem has other consequences.

from babel-polyfills.

liuxingbaoyu avatar liuxingbaoyu commented on June 6, 2024

path+"" can print out the code, which may be helpful to you. :)

from babel-polyfills.

jinliming2 avatar jinliming2 commented on June 6, 2024

I also encountered a very similar error, and the error stack trace appears to originate from the same location. After downgrading @babel/helper-define-polyfill-provider to version 0.5.0 using yarn's resolutions, the error disappeared.

When printing path+"" before the error in the code, I did not observe any particular anomalies. Similarly, printing path.parentPath+"" did not reveal any issues. However, path.parentPath.node was null.

TypeError: Cannot read properties of null (reading 'children')
    at isRemoved (/dev/shm/project/node_modules/@babel/helper-define-polyfill-provider/lib/visitors/usage.js:10:30)
    at isRemoved (/dev/shm/project/node_modules/@babel/helper-define-polyfill-provider/lib/visitors/usage.js:14:10)
    at isRemoved (/dev/shm/project/node_modules/@babel/helper-define-polyfill-provider/lib/visitors/usage.js:14:10)
    at PluginPass.MemberExpression (/dev/shm/project/node_modules/@babel/helper-define-polyfill-provider/lib/visitors/usage.js:75:104)
    at newFn (/dev/shm/project/node_modules/@babel/traverse/lib/visitors.js:160:14)
    at NodePath._call (/dev/shm/project/node_modules/@babel/traverse/lib/path/context.js:46:20)
    at NodePath.call (/dev/shm/project/node_modules/@babel/traverse/lib/path/context.js:36:17)
    at NodePath.visit (/dev/shm/project/node_modules/@babel/traverse/lib/path/context.js:82:31)
    at TraversalContext.visitQueue (/dev/shm/project/node_modules/@babel/traverse/lib/context.js:89:16)
    at TraversalContext.visitSingle (/dev/shm/project/node_modules/@babel/traverse/lib/context.js:65:19)
    at TraversalContext.visit (/dev/shm/project/node_modules/@babel/traverse/lib/context.js:112:19)
    at traverseNode (/dev/shm/project/node_modules/@babel/traverse/lib/traverse-node.js:22:17)
    at NodePath.visit (/dev/shm/project/node_modules/@babel/traverse/lib/path/context.js:88:52)
    at TraversalContext.visitQueue (/dev/shm/project/node_modules/@babel/traverse/lib/context.js:89:16)
    at TraversalContext.visitQueue (/dev/shm/project/node_modules/@babel/traverse/lib/context.js:94:21)
    at TraversalContext.visitSingle (/dev/shm/project/node_modules/@babel/traverse/lib/context.js:65:19)
    at TraversalContext.visit (/dev/shm/project/node_modules/@babel/traverse/lib/context.js:112:19)
    at traverseNode (/dev/shm/project/node_modules/@babel/traverse/lib/traverse-node.js:22:17)
    at traverse (/dev/shm/project/node_modules/@babel/traverse/lib/index.js:52:34)
    at transformFile (/dev/shm/project/node_modules/@babel/core/lib/transformation/index.js:82:31)
    at transformFile.next (<anonymous>)
    at run (/dev/shm/project/node_modules/@babel/core/lib/transformation/index.js:24:12)
    at run.next (<anonymous>)
    at /dev/shm/project/node_modules/@babel/core/lib/transform-ast.js:23:33
    at Generator.next (<anonymous>)
    at evaluateSync (/dev/shm/project/node_modules/gensync/index.js:251:28)
    at sync (/dev/shm/project/node_modules/gensync/index.js:89:14)
    at stopHiding - secret - don't use this - v1 (/dev/shm/project/node_modules/@babel/core/lib/errors/rewrite-stack-trace.js:47:12)
    at transformFromAstSync (/dev/shm/project/node_modules/@babel/core/lib/transform-ast.js:43:83)
    at Object.transform (/dev/shm/project/node_modules/metro-react-native-babel-transformer/src/index.js:251:20)
    at /dev/shm/project/node_modules/metro/src/JSTransformer/worker.js:241:31
    at Generator.next (<anonymous>)
    at asyncGeneratorStep (/dev/shm/project/node_modules/metro/src/JSTransformer/worker.js:75:24)
    at _next (/dev/shm/project/node_modules/metro/src/JSTransformer/worker.js:95:9)
    at /dev/shm/project/node_modules/metro/src/JSTransformer/worker.js:100:7
    at new Promise (<anonymous>)
    at /dev/shm/project/node_modules/metro/src/JSTransformer/worker.js:92:12
    at JsTransformer.transform (/dev/shm/project/node_modules/metro/src/JSTransformer/worker.js:394:7)
    at Object.<anonymous> (/dev/shm/project/node_modules/metro/src/DeltaBundler/Worker.js:102:38)
    at Generator.next (<anonymous>)
    at asyncGeneratorStep (/dev/shm/project/node_modules/metro/src/DeltaBundler/Worker.js:14:24)
    at _next (/dev/shm/project/node_modules/metro/src/DeltaBundler/Worker.js:34:9)
    at /dev/shm/project/node_modules/metro/src/DeltaBundler/Worker.js:39:7
    at new Promise (<anonymous>)
    at Object.<anonymous> (/dev/shm/project/node_modules/metro/src/DeltaBundler/Worker.js:31:12)
    at Object.transform (/dev/shm/project/node_modules/metro/src/DeltaBundler/Worker.js:79:21)
    at execFunction (/dev/shm/project/node_modules/jest-worker/build/workers/processChild.js:155:17)
    at execHelper (/dev/shm/project/node_modules/jest-worker/build/workers/processChild.js:139:5)
    at execMethod (/dev/shm/project/node_modules/jest-worker/build/workers/processChild.js:143:5)
    at process.<anonymous> (/dev/shm/project/node_modules/jest-worker/build/workers/processChild.js:64:7)

from babel-polyfills.

jinliming2 avatar jinliming2 commented on June 6, 2024

I suspect the issue is because path.removed is false, while path.parentPath.removed is true. However, I don't know the reason why.

Why would a node that has already been removed still be traversed by traverse?

from babel-polyfills.

nicolo-ribaudo avatar nicolo-ribaudo commented on June 6, 2024

I assume that the ancestor node is being removed while it's descendants are still being traversed. Would you be able to create a repo that shows the issue? You config + the file it's crashing on would be a good starting point, but you can probably reduce it.

from babel-polyfills.

epmatsw avatar epmatsw commented on June 6, 2024

Sorry, missed this.

in our case, the offending code is an ObjectMethod that gets replaced by a plugin with an ObjectProperty where the value is an object literal with a function as a value. I can check the removed flags today as well.

from babel-polyfills.

epmatsw avatar epmatsw commented on June 6, 2024

I can test the fix in our codebase today as well

from babel-polyfills.

jinliming2 avatar jinliming2 commented on June 6, 2024

I haven't found a minimal implementation to reproduce this issue yet, but I tested this solution by modifying files under node_modules in my project, and the issue disappeared.

image

In my case, I have a plugin based on babel-plugin-macros, which utilizes the path.replaceWith / path.replaceWithMultiple API to remove certain layers of nodes in the JSX tree, replacing the current node with its children. Sometimes, it also creates a jsxFragment to wrap some of the children.

This error is triggered in certain specific JSX structures, but not in all JSX structures.

from babel-polyfills.

nicolo-ribaudo avatar nicolo-ribaudo commented on June 6, 2024

Workaround published in @babel/[email protected]

from babel-polyfills.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.