fengdie-ast-analysis

0.2.2 • Public • Published

Usage

const { analyze } = require('fengdie-ast-analysis');
 
const start = new Date();
const result = analyze({
  sourcePath: '../Demo',
  outputFile: './.ast-info.json',  // optional, default is ./ast-info.json
});
const { injectComponent } = require('fengdie-ast-analysis');
 
const result = injectComponent({
  filePath: resolve(__dirname, './fixtures/pages/index.js'),
  component: {
    name: 'ByeBye',
    filePath: resolve(__dirname, './fixtures/components/ByeBye.js'),
  },
});
 
console.log(result);
/*
import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';
import { FengdieContainer as MyContainer } from 'fengdie-component';
import Hello from '../components/Hello';
import Bye from '../components/Bye';
import Normal from '../components/Normal';
 
import ByeBye from '../components/ByeBye.js'; // added here
 
function App() {
  return (
    <div>
      <MyContainer>
        <Hello />
        <Bye />
        <Normal />
        <ByeBye /> {// add here //}
      </MyContainer>
    </div>
  );
}
 
ReactDOM.render(<App />, document.getElementById('root'));
*/

TODO

  • 支持 default import
  • 支持 fengdie component 参数表达式
  • multiple fengdie containers/components warning
  • 增加 ignore 配置
  • add component inject

Readme

Keywords

none

Package Sidebar

Install

npm i fengdie-ast-analysis

Weekly Downloads

0

Version

0.2.2

License

MIT

Last publish

Collaborators

  • chrisfan
  • lizziesky