0.1.0-0 • Published 4 years ago

jsx2qa-compiler v0.1.0-0

Weekly downloads
1
License
BSD-3-Clause
Repository
-
Last release
4 years ago

jsx2qa-compiler

Transform JSX styled Rax Components into quickapp parts.

example

input:

import { Component } from 'rax';

export default class extends Component {

  render() {
    return (<view>hello world</view>);
  }
}

Run jsx2qa compiler.

  • type: Required, enum of app, page, component.
  • outputPath: Required, string of dist path.
  • sourcePath: Required, string of source path.
  • resourcePath: Required, string of original file path.
const compile = require('jsx2qa-compiler');
const { baseOptions } = compile;

const output = compile(code, { ...baseOptions, type: 'component' });

output:

  • ast
    • Babel 7 format AST of JS code
  • imported
    • Imported modules and local identifiers
  • exported
    • Exported identifiers
  • template
    • axml template for quickapp
  • code
    • Transformed JS code.
  • map
    • Source map of JS code
  • config
    • JS Object, quickapp config
  • style
    • String, acss of style.
  • usingComponents

eg.

{
  ast: ASTNodeTree,
  imported: {
    rax: [
      {
        local: "Component",
        default: false,
        importFrom: "Component",
        name: "rax",
        external: true
      }
    ]
  },
  exported: ["default"],
  code:
    'import { createComponent as __create_component__, Component as __component__ } from "jsx2mp-runtime";\n\nconst __def__ = class extends __component__ {\n  render() {\n    return {};\n  }\n\n};\n\nComponent(__create_component__(__def__, {\n  events: []\n}));',
  map: null,
  config: {
    component: true,
    usingComponents: {}
  },
  style: "",
  usingComponents: {},
  iconfontMap: [],
  template: "<div>hello world</div>"
}