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

Create an option for a compiler #462

Open
kof opened this issue May 31, 2017 · 19 comments · Fixed by #1700
Open

Create an option for a compiler #462

kof opened this issue May 31, 2017 · 19 comments · Fixed by #1700

Comments

@kof
Copy link

kof commented May 31, 2017

If someone has a certain babel configuration and wants to use the same code in the styleguide readme, we need to enable swaping out buble for babel.

@sapegin
Copy link
Member

sapegin commented May 31, 2017

We need an option to swap Buble for anything, not for Babel. I will be happy to accept a pull request ;-)

@sapegin sapegin added the good first issue Good for newcomers label Jun 7, 2017
@ambroselittle

This comment has been minimized.

@sapegin

This comment has been minimized.

@ambroselittle

This comment has been minimized.

@sapegin

This comment has been minimized.

@ambroselittle

This comment has been minimized.

@ambroselittle

This comment has been minimized.

@ghost

This comment has been minimized.

@okonet
Copy link
Member

okonet commented Feb 28, 2020

Styleguidist won’t support Babel by default again — it’s just to big to load on the frontend.

I've stumbled upon https://github.com/lynaghk/babel/ and I think we could evaluate it at least.

@sapegin
Copy link
Member

sapegin commented Feb 28, 2020

Keep in mind that you're quoting 2017 me, I've changed my opinion since then ;-)

There's also https://github.com/alangpierce/sucrase that looks very promising and does exactly what we need to run examples in modern browsers including JSX, TypeScript, and Flow. It could be a good default instead of Buble. According to Bundlephobia it's 40 KB minified gzipped. We'll still need an option to change it to real Babel or TypeScript for folks who need it.

@okonet
Copy link
Member

okonet commented Feb 28, 2020

Yeah I realize that just wanted to pin the link here so it's not lost. I'm really interested in a full-blown TS support in Styleguidist TBH so yeah, we need the parser to be a plugin.

@dweng0
Copy link

dweng0 commented Apr 26, 2020

Has anyone done any work on this? I'd like to poke about with it. Pointers or suggestions would be great.

@okonet
Copy link
Member

okonet commented Apr 26, 2020

I think @sapegin has a WIP branch already somewhere

@dweng0
Copy link

dweng0 commented Apr 26, 2020

OK, I was just going to go with creating an IoC Dependency injected option to provide the transpiler in the config or use the current default if its not set. But if there's a WIP I'll just see what that looks like instead.

@okonet
Copy link
Member

okonet commented Apr 26, 2020

I’m not 100% sure about that so you better look for it or wait for Artem’s answer

@sapegin
Copy link
Member

sapegin commented Apr 27, 2020

@dweng0 yeah, it's done as part of #1553 but the whole branch is far from done, so feel free to extract it into a separate pull request so we can release it separately. It also changes the default compiler, which I think we should release as well with the new option, otherwise, transpiling imports would make the whole thing more complex than it should be.

@dweng0
Copy link

dweng0 commented Apr 27, 2020

Cheers, I'll take a look and see if J can help out

@sapegin sapegin added this to the 12.0.0: Customizable compiler milestone Oct 21, 2020
@sapegin
Copy link
Member

sapegin commented Oct 21, 2020

The pull request is here!

#1700

sapegin added a commit that referenced this issue Nov 12, 2020
1. Replace Bublé with Sucrase: faster, supports more ECMAScript features, like imports (we used to transpile them ourselves), optional chaining, class fields, etc.
2. Allow custom compilers, like Babel or TypeScript using the new compilerModule and compileExample option.

Closes #462
@poteirard
Copy link
Contributor

poteirard commented Jan 11, 2021

I tested the alpha version in our react-components library and it works as expected 🎉

We've good some improvement!

With @latest

pnpm build  165.08s user 18.77s system 173% cpu 1:46.19 total

With @next

pnpm build  123.16s user 14.50s system 170% cpu 1:20.84 total

I guess the bottleneck it's in react-docgen-typescript in our case?

Thank you!

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

Successfully merging a pull request may close this issue.

6 participants