Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

104
Views
Deno: Provide Polyfills for Node.js Built-Ins

Does Deno have a way to shim/polyfill Node.js modules?

That is, let's say I have a typescript file that's part of a Node.js project, and it looks something like this

import { performance } from 'perf_hooks';

function hello() {
  console.log(performance.performance.timeOrigin)
  console.log("Hello World")
}

export {
  hello
}

I want to use this module in a deno program, so I do something like this

import {hello} from './some-module.ts'

function main() {
  hello()
}

However, I can't do this because there's no perf_hooks module in Deno.

% deno run main.ts 
Check file:///private/tmp/main.ts
error: TS2305 [ERROR]: Module '"deno:///none.d.ts"' has no exported member 'performance'.
import { performance } from 'perf_hooks';
         ~~~~~~~~~~~
    at file:///private/tmp/some-module.ts:1:10

I would like to write my own version of perf_hooks that implements the properties and methods I need, and then tell Deno Hey -- whenever anyone wants perf_hook use my module instead.

Does Deno have anything built in that would let me do this? If not is there some common practive/bundling technique that the Deno community uses to do this sort of thing.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You can use https://deno.land/x/std/node. It provide some Node's built-in modules. For external modules, you can take a look at https://esm.sh (The syntax is https://esm.sh/<npm-pkg>.

And if you want to use it like NodeJS environment, you can do the following:

import { ... } from "module"; // Let's use NodeJS "module" module for this

Then specify an import map

{
  "imports": {
    "module": "https://deno.land/std/node/module.ts"
  }
}

Run with the --import-map flag

$ deno run --import-map=/path/to/import_map.json your_file.ts
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!