README
Dev Notes On Nebula Web Tier
Nebula web tier is designed for supplying web faced layer to run user requests. Through this tier, Nebula provides supports for
- Nebula UI via web requests (GET).
- Nebula REST API - defined by
api.jsextensions
Some UI Dependencies In Use
- install grunt "npm install -g grunt-cli"
- use selectize for multi-values input
- go to "selectize/" and "npm install"
- build with plugins "grunt --plugins=remove_button,restore_on_backspace"
- we can also use it from CDNJS directly if no changes in the build
- https://cdnjs.cloudflare.com/ajax/libs/selectize.js/0.12.6/js/standalone/selectize.min.js
- https://cdnjs.cloudflare.com/ajax/libs/selectize.js/0.12.6/css/selectize.min.css
Web tier is fully in ESM.
To embrace ESM is a good choice as modern browser and node.js (>v13) server are all supporting it. This is good for
- module reuse by both browser stack and web stack stack (node).
- good for future upgrade with optimizations.
Hence, we're declaring Nebula Web Tier is fully in ESM mode.
However, there are some legacy dependencies require us stay in require for some cases. So here are some detailed notes.
- We use webpack to build bundle for NebulaClient library, we keep this in
commonjsstill due to its own limitation. - Because of #1, we have to use
createRequireto ensurerequireis still available in ES module mode. - We're enforcing using
named exportrather thandefault export, so please keepexport default xxout of the code base. - All Nebula ES modules will be organized in folder
_for better identification, please follow this convension as well. - If a module is used by both Web Server and Browser, we will
minifyit, we use VS Code extensionMinifyto do this work.
Nebula tier is designed to be a plugable platform so that any adopter can customize Nebula for its own appication.
That is why I spent a lot of effort to enforce Nebula Web to be a consistent tech stack, above convensions are some basic requirements for nebula web advanced development.
Use Webpack
Webpack is used to produce two bundles for both browser and node.js, follow these steps to refresh them whenver proto contracts updated in the service.
0. remove "type:module" from package.json to make below command work (due to webpack bad support for ES6).
- $ ~/nebula/src/service/http/nebula > npm install (based on package.json - can be reused for all service)
- ~/nebula/src/service/http/nebula > npx webpack
- $ in dist/web/main.js, prepend "export" in it to export NebulaClient. (webpack doesn't generate
exportkey)