Babel Schema Util
forked by babel-plugin-inline-import, you can apply different handler functions into the different files.
Babel plugin to add the opportunity to use import
with raw/literal content
It is good e.g. for importing *.schema
files into your code.
Examples
schema transform demo
Now (with Babel Schema Util):
// /some/demo.schema { : Image } // /some/a.js;
// /build/a.jsvar demo = "type": "array" "description": "foo" "properties": "href": "type": "string" "description": "href" "title": "type": "string" "description": "title" "img": "type": "image" "description": "image url" "amount": "type": "string" "description": "money amout" ;
Note: both cases are equivalent and will result in similar code after Babel transpile them. Check How it works section for details.
Install
npm install babel-plugin-schema-util --save-dev
Use
Add a .babelrc
file and write:
"plugins": "babel-plugin-schema-util"
or pass the plugin with the plugins-flag on CLI
babel-node myfile.js --plugins babel-plugin-schema-utilt
By default, Babel-Schema-Util is compatible with the following file extensions:
- .raw
- .text
- .graphql
- .schema
Customize
If you want to enable different file extensions, you can define them in your .babelrc
file
"plugins": "babel-plugin-schema-util" "extensions": ".json" ".sql" name: ".schema2" `~~`
Motivate
If you like this project just give it a star :) I like stars.