@kdcloudjs/kwc-babel-plugin-component
v1.0.0
Published
Babel plugin to transform a KWC module
Maintainers
Keywords
Readme
@kdcloudjs/kwc-babel-plugin-component
Summary
This babel plugin does the following transform:
- Global decorator transform:
- Transform
@apidecorator topublicPropertiesandpublicMethodsstatic properties. - Transform
@wiredecorator towirestatic property. - Transform
@trackdecorator totrackstatic property.
- Transform
- KWC component class sugar syntax:
- Check for misspelled lifecycle hooks.
- Import and inject
renderfrom a collocated template if a component class doesn't already implement arendermethod.
- Optimization:
- If the compiler inject the default template a component, it will also wire the template style to the component.
Installation
npm install babel @kdcloudjs/kwc-babel-plugin-componentUsage
const babel = require('@babel/core');
const kwcPlugin = require('@kdcloudjs/kwc-babel-plugin-component');
const source = `
import { KingdeeElement } from '@kdcloudjs/kwc';
export default class extends KingdeeElement {}`;
const { code } = babel.transformSync(source, {
plugins: [
[
kwcPlugin,
{
/* options */
},
],
],
});Options
name(type:string, optional) - name of the component, e.g.fooinx/foo.namespace(type:string, optional) - namepace of the component, e.g.xinx/foo.isExplicitImport(type:boolean, optional) - true if this is an explicit import.dynamicImports(type:object, optional) - see below:loader(type:string, optional) - loader to use at runtime.strictSpecifier(type:boolean, optional) - true if a strict specifier should be used.
instrumentation(type:InstrumentationObject, optional) - instrumentation object to gather metrics and non-error logs for internal use. See the@kdcloudjs/kwc-errorspackage for details on the interface.apiVersion(type:number, optional) - API version to associate with the compiled component.
