Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compilation error with recent version of Babel parser #52

Closed
o0Djeen0o opened this issue Jun 8, 2021 · 4 comments
Closed

Compilation error with recent version of Babel parser #52

o0Djeen0o opened this issue Jun 8, 2021 · 4 comments

Comments

@o0Djeen0o
Copy link

o0Djeen0o commented Jun 8, 2021

Hi,

We recently upgraded babel stack and started to have issues with Typescript integration. Basically, if a file only contains type declarations, like :

export interface IMyInterface {
    id: string;
}

then Babel will type it as an ExportNamedDeclaration

(see this fixture with input and output)

However, from babel plugin transform UI5 side, it seems that such node is not skipped, leading to an error and impossibility to compile :

SyntaxError: C:\<my-interface>.ts: Unknown ExportNamedDeclaration shape. (This is an error on an internal node. Probably an internal error.)
    at File.buildCodeFrameError (C:\<my-project>\node_modules\@babel\core\lib\transformation\file\file.js:244:12)
    at NodePath.buildCodeFrameError (C:\<my-project>\node_modules\@babel\traverse\lib\path\index.js:133:21)
    at PluginPass.ExportNamedDeclaration (C:\<my-project>\node_modules\babel-plugin-transform-modules-ui5\dist\modules\visitor.js:244:18)
    at newFn (C:\<my-project>\node_modules\@babel\traverse\lib\visitors.js:171:21)
    at NodePath._call (C:\<my-project>\node_modules\@babel\traverse\lib\path\context.js:53:20)
    at NodePath.call (C:\<my-project>\node_modules\@babel\traverse\lib\path\context.js:40:17)
    at NodePath.visit (C:\<my-project>\node_modules\@babel\traverse\lib\path\context.js:90:31)
    at TraversalContext.visitQueue (C:\<my-project>\node_modules\@babel\traverse\lib\context.js:110:16)
    at TraversalContext.visitSingle (C:\<my-project>\node_modules\@babel\traverse\lib\context.js:79:19)
    at TraversalContext.visit (C:\<my-project>\node_modules\@babel\traverse\lib\context.js:138:19) {
  code: 'BABEL_TRANSFORM_ERROR'

For me, a quick win would be to skip visiting such node from the plugin. For instance, here we should add a check for the node type, like :

 if (node.type === "ExportNamedDeclaration") {
    return;
  }

Maybe this is a bit to simple and would need some refinements ?

Any help would be welcomed, as I'm not confident with my AST parsing comprehension :-)

Best regards

@o0Djeen0o
Copy link
Author

Hi,

The error is related to this change:
babel/babel#13314

@lemaiwo
Copy link

lemaiwo commented Jun 29, 2021

Facing the same problem, any solution for this?

@GuillaumedesPommareSAP
Copy link
Contributor

Facing the same problem, any solution for this?

I opened a PR for this issue: #53
Not sure if it will be the final fix, at least it solved the problem in our use case.

@r-murphy
Copy link
Collaborator

r-murphy commented Jul 6, 2021

Thanks for the PR @GuillaumedesPommareSAP.
I just published a quick patch release 7.0.4. Please give a try.

I have another branch in progress with some other dependency updates.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants