Babel config
See original GitHub issueš First off, thank you very much for making this! Iāve used component-playground
for a while, and have found this to be a really easy transition so far.
The one finicky thing Iām running into is āhowā Iām writing my components that I pass into the code
param.
My .babelrc
looks like this:
{
"presets": [
["env", {
"targets": {
"browsers": ["last 2 versions"]
}
}],
"stage-0",
"react"
],
"plugins": [
"transform-strict-mode"
]
}
Hereās an example Iām attempting to use:
const AlertExample = `
class Example extends React.Component {
state = {
toggleAlert: false,
};
handleToggleAlert = () => {
this.setState({
toggleAlert: !this.state.toggleAlert,
});
}
render() {
return (
<Fragment>
<Alert collapse={this.state.toggleAlert} type="primary" close>Test 1</Alert>
<Button type="reset" onClick={this.handleToggleAlert} >Toggle Alert</Button>
</Fragment>
);
}
}
`.trim();
so Iām using a few niceties when I write my own components. It looks like when passing that same type of code into <LiveProvider />
it doesnāt appear to be compiling, and blows up because of a syntax issue. Is there a way for react-live
to take advantage of my babel config?
Issue Analytics
- State:
- Created 6 years ago
- Comments:9
Top Results From Across the Web
Configure Babel
Babel can be configured! Many other tools have similar configs: ESLint ( .eslintrc ), Prettier ( .prettierrc ). All Babel API options are...
Read more >Advanced Features: Customizing Babel Config - Next.js
Customizing Babel Config ... Next.js includes the next/babel preset to your app, which includes everything needed to compile React applications and server-sideĀ ...
Read more >When to use babel.config.js and .babelrc - Stack Overflow
From the docs https://babeljs.io/docs/en/config-files#project-wide-configuration. Babel has two parallel config file formats which can beĀ ...
Read more >An example of the new babel.config.js. - gists Ā· GitHub
babel.config.js with useful plugins. */. module.exports = function(api) {. api.cache(true);. api.assertVersion("^7.4.5");. const presets = [.
Read more >How to Configure Babel For Your Monorepo
In this post join me as I add Babel configuration to a monorepo, making sure that it can sustain different configurations packages need...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I ended up using:
No, currently
react-live
neither usesbabel-standalone
nor does it allow extensive customisation of the transpilation that it performs. It currently just uses BublƩ, so whatever BublƩ is able to transpile,react-live
will also accept.Iāve read in another issue (not sure if GH or somewhere else?) that someone is currently simply using the
transformCode
prop usingbabel-standalone
. Maybe you can give that a try?