module (compiler option)
The compiler option that says which module system the output uses and, with NodeNext, how each file is treated.
In more detail
Values such as NodeNext, ESNext and CommonJS decide whether import and export are kept or rewritten to require. With NodeNext, each file is treated as an ES module or CommonJS according to its extension and the nearest package.json type field. TypeScript 6.0 changed the default to esnext.
Related terms
- module resolution — How a runtime or tool turns the name in an import, such as ./util.js or express, into the exact file to load.
- NodeNext — A module and moduleResolution setting that makes TypeScript follow exactly the module rules of current Node.js.
- ECMAScript modules — The standard JavaScript module system, written with import and export statements, used by browsers and modern tools.
- CommonJS — Node.js's original module system, which loads code with require() and exports it with module.exports.
Taught in
- tsconfig.json: target, lib, strict And NodeNext — Production TypeScript