Skip to content

Commit a2e0058

Browse files
authoredMay 26, 2020
Add support for ESM exports in the PackageJson type (#109)
1 parent d83a794 commit a2e0058

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed
 

‎source/package-json.d.ts

+37
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,29 @@ declare namespace PackageJson {
211211
[packageName: string]: string;
212212
}
213213

214+
/**
215+
Conditions which provide a way to resolve a package entry point based on the environment.
216+
*/
217+
export type ExportCondition = LiteralUnion<
218+
| 'import'
219+
| 'require'
220+
| 'node'
221+
| 'deno'
222+
| 'browser'
223+
| 'electron'
224+
| 'react-native'
225+
| 'default',
226+
string
227+
>;
228+
229+
/**
230+
Entry points of a module, optionally with conditions and subpath exports.
231+
*/
232+
export type Exports =
233+
| string
234+
| {[key in ExportCondition]: Exports}
235+
| {[key: string]: Exports};
236+
214237
export interface NonStandardEntryPoints {
215238
/**
216239
An ECMAScript module ID that is the primary entry point to the program.
@@ -380,11 +403,25 @@ export type PackageJson = {
380403
*/
381404
files?: string[];
382405

406+
/**
407+
Resolution algorithm for importing ".js" files from the package's scope.
408+
409+
[Read more.](https://nodejs.org/api/esm.html#esm_package_json_type_field)
410+
*/
411+
type?: 'module' | 'commonjs';
412+
383413
/**
384414
The module ID that is the primary entry point to the program.
385415
*/
386416
main?: string;
387417

418+
/**
419+
Standard entry points of the package, with enhanced support for ECMAScript Modules.
420+
421+
[Read more.](https://nodejs.org/api/esm.html#esm_package_entry_points)
422+
*/
423+
exports?: PackageJson.Exports;
424+
388425
/**
389426
The executable files that should be installed into the `PATH`.
390427
*/

0 commit comments

Comments
 (0)
Please sign in to comment.