babel-plugin-jsx-sfc

1.6.1 • Public • Published

babel-plugin-jsx-sfc

Babel plugin for compile and enhance the limitation of jsx-sfc runtime code.

How it works

const App = sfc({
  Component: (props) => { ... },
  static: {
    hooks: { ... },
    utils: { ... }
  },
  render({ data }) { ... },
  styles: () => ({ ... })
});

     

// "123" is line number
const $sfcOptions_123 = sfc.createOptions({
  static: {
    hooks: { ... },
    utils: { ... }
  },
  render({ data }) { ... },
  styles: () => ({ ... })
});

// Extract the actual component function
const Sfc_123 = (props) => {
  ...
  return $sfcOptions_123.render({ ... });
};
Sfc_123.displayName = 'App';

// It's just use Object.assign to merge members of "$sfcOptions_123" to create final component function.
const App = sfc(Sfc_123, $sfcOptions_123);

License

MIT

/babel-plugin-jsx-sfc/

    Package Sidebar

    Install

    npm i babel-plugin-jsx-sfc

    Weekly Downloads

    36

    Version

    1.6.1

    License

    MIT

    Unpacked Size

    24.2 kB

    Total Files

    7

    Last publish

    Collaborators

    • joe_sky