0.0.3
Proof of concept for a bridge between Deno and npm packages
Attributes
Includes Deno configuration
Repository
Current version released
3 years ago
Dependencies
std
Versions
npm_bridge
This is a proof of concept I threw together in a few hours. DO NOT USE THIS AS IT LIKELY WON’T WORK. I haven’t implemented a lot.
Proof of concept for a bridge between Deno and npm packages.
Works similarly to using npm in Node.
Step 1: Setup - Install dependencies
In the root of your application:
- Define your dependencies in a
npm_deps.json
{ "dependencies": { "ts-morph": "^14.0.0" } }
- Run
deno run -A --no-check --reload https://deno.land/x/npm_bridge/main.ts
Step 2: Use dependencies
- Import and use the package via a bare specifier:
// main.ts import { Project } from "ts-morph"; const project = new Project(); const sourceFile = project.createSourceFile("test.ts", "class MyClass {}"); console.log(sourceFile.getClassOrThrow("MyClass").getName());
- Run it:
deno run --allow-read --allow-env --unstable main.ts
What this does
- Runs
npm install
with the dependencies you specified. - Analyzes the
node_modules
folder and creates wrapper ESM modules around the CJS code. - Creates an import map to map bare specifiers to the wrapper ESM modules and to map import specifiers with no extensions to extensions.
- Updates or adds the import map to your deno.json file.