This is a first attempt at a compiler I/O API, which is for most practical purposes the top-level API of this library. This is the piece that reads in source files, calls the compiler API for each file, and then outputs the compiled files. Here is what the current prototype API looks like (feel free to suggest alternate syntax):
The above example is what a component library's build.js file might look like. In this example, it would compile all of the component library's universal components, and then output the compiled Vue and React files into separate Vue and React directories under the dist directory. The compiled output could then be published to NPM as either separate React and Vue libraries, or as a single unified library (e.g., import {Page} from 'framework7/react/ or import {Page} from 'framework7/vue/).
I created separate component-library and app directories in the test area. The build.js file now calls the compile-io API to compile the "component library" first, and it then calls rollup to compile the Vue and React apps. The Vue and React app components import the compiled universal component, but the import path is not as clean here as it would be when importing from a component library's NPM package.
This is just a simple prototype and is certainly not complete. Here are some ideas for the future that come to mind:
CLI that calls this API
Instead of passing in a configuration object, it might be nice to have the option to have the configuration in a separate file. That would be especially helpful with minimizing the verboseness of CLI calls.
Ability to configure output settings for ES5 vs. ESNEXT, etc. Right now, we only support ES5 output.
This is a first attempt at a compiler I/O API, which is for most practical purposes the top-level API of this library. This is the piece that reads in source files, calls the compiler API for each file, and then outputs the compiled files. Here is what the current prototype API looks like (feel free to suggest alternate syntax):
The above example is what a component library's
build.js
file might look like. In this example, it would compile all of the component library's universal components, and then output the compiled Vue and React files into separate Vue and React directories under the dist directory. The compiled output could then be published to NPM as either separate React and Vue libraries, or as a single unified library (e.g.,import {Page} from 'framework7/react/
orimport {Page} from 'framework7/vue/
).I created separate
component-library
andapp
directories in thetest
area. The build.js file now calls the compile-io API to compile the "component library" first, and it then calls rollup to compile the Vue and React apps. The Vue and React app components import the compiled universal component, but the import path is not as clean here as it would be when importing from a component library's NPM package.This is just a simple prototype and is certainly not complete. Here are some ideas for the future that come to mind:
CLI that calls this API
Instead of passing in a configuration object, it might be nice to have the option to have the configuration in a separate file. That would be especially helpful with minimizing the verboseness of CLI calls.
Ability to configure output settings for ES5 vs. ESNEXT, etc. Right now, we only support ES5 output.
Source-map support
Fool-proof error handling