Socket
Book a DemoInstallSign in
Socket

enload

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install
Package was removed
Sorry, it seems this package was removed from the registry

enload

universal common loader for JS runtimes

0.1.1
unpublished
latest
Source
npmnpm
Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

enload - universal common loader for JS runtimes

Why?

  • Import a variety of configuration formats (YAML, TOML, JSON5)
  • Loosen Node's standard enforcement of import assertions for JSON
  • Import frontend framework formats for server templating (JSX, Vue, Svelte)
  • Import transpiled languages (TypeScript, CoffeeScript)

Install

npm install enload

For the loaders, peer deps must be installed and you will be informed if they're missing. See loaders for supported loaders.

Use

In the terminal

If you run from the terminal, you get both static and dynamic imports.

node --import=enload/register app.js

import config from "./config.json";

// or (await import("./config.json")).default

Programmatically

If you use programmatically, imports coming after the enload() invocation must be dynamic (import()).

import enload from "enload";

enload();

const config = (await import("./config.json")).default;

Configure

This currently applies only programmatically.

You can pass an extensions object property to remap a given loader to a new extension. In the following example, the yaml loader will trigger on .yml files.

import enload from "enload";

enload({ extensions: { yaml: ".yml" } });

const config = (await import("./config.yml")).default;

Loaders

NameExtensionDependency
csv.csvcsv-parse
json.json
json5.json5json5
toml.tomltoml
xml.xmlxml2js
yaml.yamlyaml
jsx.jsxesbuild
vue.vuevue
svelte.sveltesvelte
typescript.tsesbuild
coffeescript.coffeecoffeescript

License

MIT

Contributing

By submitting code you confirm that you are its sole owner and agree to place it under the terms of MIT, see LICENSE.

FAQs

Package last updated on 05 Mar 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.