Performance: Node.js built-in module support
This affects the startup time and memory usage of Deno applications when using Node.js built-in modules.
Use Deno native APIs or selectively import only needed polyfills: import { readFileStr } from 'https://deno.land/std/fs/mod.ts';
import fs from 'node:fs'; // Using many Node.js built-in modules without optimization
| Pattern | Module Load Time | Memory Usage | Startup Delay | Verdict |
|---|---|---|---|---|
| Import full Node.js built-in modules | High (polyfills loaded) | High (+100kb) | Medium (50-100ms) | [X] Bad |
| Use native Deno APIs or minimal polyfills | Low | Low (+20kb) | Low (10-30ms) | [OK] Good |
path module in Deno?pathimport path from "node:path"; to access Node.js path module in Deno.fs module in Deno?fs.fsimport * as fs from "node:fs"; to import all fs exports as a namespace.import { join } from "node:path";
const fullPath = join("/home", "user", "docs");
console.log(fullPath);join from Node.js path modulejoin function combines path segments using the correct separator for the OS.buffer module:
import { Buffer } from "buffer";
const buf = Buffer.from("hello");
console.log(buf.toString());buffer.events module in Deno to create an event emitter. Which code snippet correctly imports and uses it?events module exports EventEmitterevents module exports EventEmitter as a named export, so namespace import is common.import * as events from "node:events"; then new events.EventEmitter() is correct in Deno.Pass the test and this pattern moves unknown