-
Notifications
You must be signed in to change notification settings - Fork 5
Spec for Component.py
This is very much a work in progress.
To prevent component.py from adding any noticeable overhead it is neccesary to do similar building as is done with javascript components.
This involves creating a component_config.py
file in the build directory which defines all the component contexts and aliases component
to username-component
.
Currently component is a single python file, it is possible that in the future it will become a full module but apart from making the name slightly misleading this won't make it backward-incompatible.
from component import require
example_component = require("example-component")
By default requiring a component would just return the module, however if your component is just a function you can decorate it with @export
and just the function will be exported.
from component import export
@export
def my_function(){
}
I plan to support the exporting of any python object.
- Should cache modules using
sys.modules
.
- Should include builder version number, and required component.py version number in compiled config file so component.py can warn when if it's version isn't compatible with builder version.
- Should warn if component has two dependencies with same name (although this can still work, they just won't be aliased).