JavaScript module loader
- Import a variety of configuration formats (YAML, TOML, JSON5)
- Import frontend framework formats for server-side templating (JSX, Vue, Svelte, Solid, Handlebars, Marko)
- Import transpiled languages (TypeScript, CoffeeScript)
- Other stuff (
.txtfiles as string,.wasmmodules)
npm install esload
esload comes bundled with the dependency-free loaders for .txt, .json and
.wasm. For additional loaders, consult the loader overview on
which packages to install.
If you run from the terminal, you get both static and dynamic imports.
node --import=esload app.js
importconfigfrom"./config.json";// or (await import("./config.json")).defaultIf used programmatically, imports coming after esload() must be dynamic
(import()).
importregisterfrom"esload/register";register();constconfig=(awaitimport("./config.json")).default;If esload detects an esload.config.js file in the package root, it will load
it automatically.
importyamlfrom"@esload/yaml";exportdefault{loaders: [yaml],virtuals: {"/config.yaml": 'foo: "bar"',},};Array property for additional loaders.
importyamlfrom"@esload/yaml";exportdefault{loaders: [yaml],};Object property in the form of { [path]: code } to load from memory instead
of the filesystem. Memory paths have precedence over filesystem paths.
exportdefault{virtuals: {// even if `/config.json` exists, it won't be loaded from disk"/config.json": '{ "foo": "bar" }',},};| Name | Package | Dependencies |
|---|---|---|
| text | esload | - |
| json | esload | - |
| wasm | esload | - |
| csv | @esload/csv | csv-parse |
| json5 | @esload/json5 | json5 |
| toml | @esload/toml | toml |
| xml | @esload/xml | xml2js |
| yaml | @esload/yaml | yaml |
| react | @esload/react | esbuild |
| vue | @esload/vue | vue |
| svelte | @esload/svelte | svelte |
| solid | @esload/solid | babel-present-solid@babel/core |
| handlebars | @esload/handlebars | handlebars |
| marko | @esload/marko | marko |
| typescript | @esload/typescript | esbuild |
| coffeescript | @esload/coffescript | coffeescript |
MIT
By contributing to esload, you agree that your contributions will be licensed under its MIT license.