JavaScript Modules
Curvea includes a small JavaScript module graph for files in:
src/assets/js
It is useful for normal site behavior scripts.
It is not a full replacement for a dedicated bundler.
Entry files
Every JavaScript file in src/assets/js is treated as an entry file.
Files are transformed and written to:
dist/assets/js
Supported file extensions
The current transformer supports:
.js
.mjs
.cjs
CSS imports are also handled through proxy modules.
Supported import styles
The transformer rewrites:
- static ESM imports
- ESM exports with
from - side-effect imports
- dynamic imports with literal strings
- some CommonJS
require()calls
Import path support
Supported paths include:
- relative imports
@/imports fromsrc- supported package imports through package resolution
Extensionless imports
Curvea resolves supported JavaScript file candidates for imports.
Because this is limited, prefer explicit .js paths when possible.
CSS imports from JavaScript
When a JavaScript module imports CSS, Curvea emits the CSS asset and creates a proxy module that injects a stylesheet link at runtime.
Runtime CSS loader
When CSS imports are used from JavaScript, Curvea emits a runtime module:
/_curvea/runtime/css-loader.js
Limitations
Some npm packages may fail depending on:
- unsupported package exports
- unsupported module formats
- non-literal require calls
- unsupported file extensions
- complex CommonJS patterns
When in doubt, keep browser JavaScript simple and close to standard ESM.