JSDWA (Java Script Distributed Web Assets) is a modern approach that leverages JavaScript and JavaScript Template Literals to create a powerful web asset serving system. It provides a PHP-like templating experience with enhanced capabilities and modern JavaScript features, supporting multiple web application architectures.
- Web Asset Serving: Serve JS string exports as any text-based web assets with appropriate MIME types (HTML, CSS, SVG, etc.)
- On-the-fly: Build and minification for all assets. You don't need Webpack or that "yet-another-newer-hipster-thing" anymore
- Server-Side Rendering: Built-in SSR support for native Custom Elements
- Performance Optimized: Fast in-memory cache for production usage
- Isomorphic Code: Full-stack DRY support with shared code between client and server
- Modern Dependency Management: Automated importmap generation based on package.json and your endpoints structure. Share the common code with ease
- Platform Standards: Modern web standards usage without legacy dependencies
- Hybrid Web App Model Support: Seamlessly combine SSR, SPA, micro-frontends, and on-demand dynamic components without complex configurations
- Distributed Assets Model: ESM over HTTPS support with direct URL access to application components
- Extensibility: Add custom middleware to support your specific use cases
- Flexible Styling: Use JavaScript right in your styles, forget about additional pre- or post-processors for CSS and their creepy syntax. Use classic way styling or encapsulated Shadow DOM. Or use them both without any limitations
- SVG as JSDWA: Make your SVG-illustration images dynamic as everything else in your project
npm install https://github.com/rnd-pro/jsdwa-server.git
- Create a configuration file (
project.cfg.js
):
export default {
routes: './ref/routes.js',
pageDataFn: './ref/data.js',
ssrComponents: {
templates: './ref/wc/{name}/tpl.html.js',
scripts: './ref/wc/{name}/index.js',
styles: './ref/wc/{name}/style.css',
},
cache: true,
port: 3000,
importmap: true,
}
- Start the server using one of these methods:
Using the CLI (recommended):
# Start with default settings
jsdwa
# Start with custom port
jsdwa --port 8080
# Start with caching enabled
jsdwa --cache
# Start with both options
jsdwa --port 8080 --cache
Using Node directly:
node ./node_modules/jsdwa-server/src/index.js
Option | Description |
---|---|
--port <number> |
Set the server port number |
--cache |
Enable in-memory caching |
Option | Description |
---|---|
routes |
Path to your routes configuration file |
pageDataFn |
Path to your page data middleware function |
ssrComponents |
Configuration for server-side rendered components |
cache |
Enable/disable in-memory caching |
port |
Server port number |
importmap |
Enable/disable automatic importmap generation |
Option | Description |
---|---|
templates |
Template path schema |
scripts |
Component scripts path schema |
styles |
Component styles path schema |
// ref/routes.js
export default {
'/': './pages/home/index.html.js',
'/about/': './pages/about/index.html.js',
'/contact/': './pages/contact/index.html.js'
};
Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.
MIT
rnd-pro.com ([email protected])