1.0.0-beta.51 • Published 3 years ago

@expressive/babel-plugin-core v1.0.0-beta.51

Weekly downloads
46
License
MIT
Repository
github
Last release
3 years ago

babel-plugin-transform-xjs

Babel plugin for transforming do{ } statements into React compatable markup. Most comperable to babel-plugin-transform-react-jsx, with a completely different syntax at play. May be used along side JSX and it's respective babel-plugin (recommended) or even as a feature-complete replacement, depending on your needs.

Install

It is recommended you apply a preset rather than using this plugin directly.

Choose package for your current environment, web, native, or next for NEXT.js.

yarn install @expressive-react/preset-*

.babelrc

Note that babel infers babel-preset so you should replace * with only the keyword of package you've installed.

{
    "presets": [
        "@expressive-react/*"
    ]
}

Entry Points

babel-plugin-transform-xjs will enter context upon encountering the DoExpression e.g. do{} in various contexts. It will also do so for any method with the name "do" e.g. do(){} For more information on actual syntax, consult the main repo.

Element Expressions

let element = do {
    div();
}

//equivalent to in JSX

let element = (
    <div></div>
)

//outputs

let element = React.createElement("div", {})

Arrow Components

let SayHi = ({ to }) => do {
    div `Hello ${ to }`;
}

//equivalent to in JSX

let SayHi = (props) => (
    <div>Hello {props.to}</div>
)

//outputs

let SayHi = function(props) {
    return React.createElement("div", {}, "Hello " + props.to)
}

Do Component Method

class Greet extends React.Component {
    do(props){
        SayHi(to `World`)
    }
}

//equivalent to in JSX

class Greet extends React.Component {
    render(){
        var { props } = this;
        return (
            <SayHi to="World" />
        )
    }
}

Disclaimer

This plugin will conflict with babel-plugin-do-expressions. Make sure your project is not using it or the following presets as they do inherit this plugin.

License

MIT License

1.0.0-beta.51

3 years ago

1.0.0-beta.49

3 years ago

1.0.0-beta.48

4 years ago

1.0.0-beta.47

4 years ago

1.0.0-beta.45

4 years ago

1.0.0-beta.46

4 years ago

1.0.0-beta.44

4 years ago

1.0.0-beta.42

4 years ago

1.0.0-beta.43

4 years ago

1.0.0-beta.38

4 years ago

1.0.0-beta.36

4 years ago

1.0.0-beta.35

4 years ago

1.0.0-y.0

4 years ago

1.0.0-beta.34

4 years ago

1.0.0-beta.27

4 years ago

1.0.0-beta.24

5 years ago

1.0.0-beta.23

5 years ago

1.0.0-beta.22

5 years ago

1.0.0-beta.21

5 years ago

1.0.0-beta.20

5 years ago

1.0.0-beta.19

5 years ago

1.0.0-beta.16

5 years ago

1.0.0-beta.15

5 years ago

1.0.0-beta.14

5 years ago

1.0.0-beta.13

5 years ago

1.0.0-beta.12

5 years ago

1.0.0-beta.11

5 years ago

1.0.0-beta.10

5 years ago

1.0.0-beta.9

5 years ago

1.0.0-beta.8

5 years ago

1.0.0-beta.7

5 years ago

1.0.0-beta.6

5 years ago

1.0.0-beta.5

5 years ago

1.0.0-beta.4

5 years ago