Introduction
Teloce-NPM lets a web page use npm packages without Node.js and without a node_modules folder. You name the packages you need, run one command, and call use('name').
It is a small Python tool. It downloads each package from the npm registry, verifies and scans it, turns it into one browser-ready file, and wires it into your page. There is nothing to bundle by hand and no build server to run.
Two ways to use it
Teloce-NPM works with plain HTML, CSS and JavaScript, and with Teloce components (.vel or .html). The package manager is the same in both. Pick whichever fits your project.
Pick your style
<!doctype html>
<html>
<head>
<!--
Use dayjs from teloce-npm
-->
</head>
<body>
<p id="today"></p>
<script type="module">
await use.ready;
document.getElementById("today").textContent = use("dayjs")().format("dddd, MMMM D");
</script>
</body>
</html>Use dayjs from teloce-npm
<script>
export default {
data() { return { today: "" }; },
async mounted() {
await use.ready;
this.today = use('dayjs')().format('dddd, MMMM D');
}
};
</script>
<template>
<h1>{{ today }}</h1>
</template>Then, for either:
pip install teloce-npm
teloce-npm installteloce-npm install finds the Use line, downloads and checks dayjs, writes the files your page needs and adds two <script> tags to it.
How it works
- Scan.
installreads your.htmland.velfiles forUse <package> from teloce-npmlines, and thepackageslist inteloce-npm.json. - Download. Each package comes from the npm registry as a tarball and is checked against its SHA-512 integrity hash.
- Check. The package is scanned for dangerous code and looked up in the OSV vulnerability database. See Security.
- Wrap or bundle. Plain scripts are wrapped so they expose a browser global. Packages that need it (ES modules, CSS, fonts, workers, npm dependencies) are bundled with an esbuild-based bundler for Python. See Wrapper formats.
- Generate.
loader.js,use.jsandmanifest.jsonare written next to your static files, and two script tags are added to your page. - Run. In the browser the loader loads every package.
await use.readywaits for it, anduse('name')returns the package.
Why use it
- No Node.js. It is pure Python and works in a plain Python container or CI job.
- Reproducible.
teloce-npm.lockpins every version and integrity hash.install --frozen-lockfileis made for CI. - Secure by default. Integrity checks, a code scanner, vulnerability lookups, download and extraction limits, and a registry host allowlist.
- Real libraries. Monaco, Chart.js, D3, Three.js, Lodash, Day.js, marked and DOMPurify, PapaParse, Fuse.js, canvas-confetti, SortableJS, highlight.js and Supabase are all tested. See the examples.
- Small runtime. The browser side is two small generated files.
What it is not
Teloce-NPM is not a replacement for npm. It has no scripts, no dev dependencies and no workspaces, and it does not compile TypeScript or JSX. It installs browser libraries so a page can use them.
Requirements
Python 3.9 or newer, and internet access to the npm registry when you install. Teloce components need Teloce-Py. See Installation.
Next steps
- Installation
- Plain HTML, CSS and JavaScript, a complete walkthrough
- Teloce project, a complete walkthrough with Teloce components
- Teloce, Flaxon and SSR