webdoc-labs / webdoc

Documentation generator for the web
https://www.webdoclabs.com
Other
79 stars 9 forks source link

Babel cannot parse decorators #83

Closed lazarljubenovic closed 3 years ago

lazarljubenovic commented 3 years ago

We're getting the following error on our codebase.

Babel couldn't parse file in @webdoc/parser (libs/...component.ts)
C:\...\nvm\v15.4.0\node_modules\@webdoc\cli\node_modules\@babel\parser\lib\index.js:748
    const err = new SyntaxError(message);
                ^
SyntaxError: This experimental syntax requires enabling one of the following parser plugin(s): 'decorators-legacy, decorators' (11:0)

Obviously, the babel parser is missing the decorators and/or decorators-legacy plugin, but I can't figure out how to influence the used babel plugins.

I've checked out source code for @webdoc/parser and saw the babel config file.

https://github.com/webdoc-labs/webdoc/blob/1413c09868321f61f23984e4e33ff17d473dcd30/packages/webdoc-parser/babel.config.json#L2

But I don't see any way to influence this, so I'm not sure if this issue is a simple question or missing docs or missing feature :smile:

ShukantPal commented 3 years ago

@lazarljubenovic I see you're interested in the source a little bit. The babel config you pointed here was for @webdoc/parser's build - not the runtime parsing of the documented codebase. Those plugins are defined here:

https://github.com/webdoc-labs/webdoc/blob/1413c09868321f61f23984e4e33ff17d473dcd30/packages/webdoc-parser/src/symbols-babel/index.js#L13

Right now, the configuration doesn't have an option to add/remove these. The idea was to add all the plugins b/c I didn't foresee any reason not to have a plugin. I did forget decorators.

I'll try to make a fix for this tonight or tomorrow and do a quick release.

lazarljubenovic commented 3 years ago

The babel config you pointed here was for @webdoc/parser's build

Duh, that's obvious now. A brainfart on my part 😅 Thanks for pointing to the right direction.

I didn't foresee any reason not to have a plugin

Indeed, given the backward compatibility, I don't see why anyone would want to remove a plugin, either.

Adding plugins, on the other hand, is probably something that someone else would eventually ask for -- some people like to add all sorts of stage 1 stuff into their projects -- so that might be a good low-priority addition for the roadmap.