babel-plugin-s2s-some-root-ts
v1.0.0
Published
generate root object
Downloads
1
Readme
babel-plugin-s2s-some-root-ts
plugin for https://github.com/akameco/s2s
Search the directory and create Root.
Install
$ npm install --save-dev babel-plugin-s2s-some-root-ts
Example
ExportType: union
IN:
OUT:
/***** Do not edit this file *****/
import { Action as Container1 } from "../examples/container1/actionTypes";
import { Action as Container2 } from "../examples/container2/actionTypes";
export type Action = Container1 | Container2;
ExportType: object
IN:
OUT:
/***** Do not edit this file *****/
import { Container1 } from "../examples/container1/reducer";
import { Container2 } from "../examples/container2/reducer";
export const reducers = {
Container1,
Container2
};
ExportType: array
IN:
OUT:
/***** Do not edit this file *****/
import { Epic as Container1 } from "../examples/container1/epic";
import { Epic as Container2 } from "../examples/container2/epic";
export const Epics = [Container1, Container2];
Usage
module.exports = {
watch: './**/*.ts',
plugins: [
{
test: /actionTypes.ts$/,
plugin: ['s2s-some-root-ts', {
input: 'containers/**/actionTypes.ts',
output: 'types/action.ts',
globOptions: {},
exportType: 'object',
importName: 'action',
exportName: 'actions',
prefix: 'pre_',
suffix: '_suf',
}],
},
],
}
input
type: string
required: true
glob pattern.
output
type: string
required: true
outputh path.
globOptions
type: object
required: false
See https://github.com/isaacs/node-glob#options
exportType
type: string
union|array|object
required: false
default: union
Switch output type. Please see examples.
importName
type: string
required: false
default: Directory name
Name to import from file. If not specified, the directory name is specified.
exportName
type: string
required: false
default: Root
Name to export variable (or alias).
prefix
type: string
required: false
default: empty
Prefix of export.
suffix
type: string
required: false
default: empty
Suffix of export.