Tag

Exports

1 views collected around this technical thread.

DaTaobao Tech
DaTaobao Tech
Aug 1, 2022 · Backend Development

Configuring Dynamic Entry Points for Node Packages: main, type, exports, and module fields

Library authors can configure package.json using main, type, exports, and module fields to provide separate CommonJS and ES module entry points, enabling runtime selection based on import or require, improving tree‑shaking, bundler compatibility, and TypeScript type resolution while restricting undefined sub‑paths.

CommonJSESMExports
0 likes · 11 min read
Configuring Dynamic Entry Points for Node Packages: main, type, exports, and module fields
ByteDance Dali Intelligent Technology Team
ByteDance Dali Intelligent Technology Team
Jun 11, 2021 · Backend Development

Node.js Package Module Import/Export Rules and Conditional Exports – A Comprehensive Guide

This article explains the latest Node.js package module specifications, covering how the "type", "exports", and "imports" fields in package.json determine ESM or CommonJS loading, the history of version changes, subpath mappings, conditional exports, and best practices for dual-module packages.

CommonJSESMExports
0 likes · 27 min read
Node.js Package Module Import/Export Rules and Conditional Exports – A Comprehensive Guide
vivo Internet Technology
vivo Internet Technology
Mar 3, 2021 · Backend Development

Understanding the Node.js Module System: Resolving, Loading, Wrapping, Caching and Exports

Node.js implements the CommonJS module system by using global require and module objects that, when a module is requested, resolve its absolute path, load and wrap the file, evaluate it to populate module.exports, cache the result, and handle exports, circular dependencies, JSON and native addons.

CommonJSExportsModule System
0 likes · 21 min read
Understanding the Node.js Module System: Resolving, Loading, Wrapping, Caching and Exports