You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/types/packagejson.ts
+87-47Lines changed: 87 additions & 47 deletions
Original file line number
Diff line number
Diff line change
@@ -1,36 +1,3 @@
1
-
/**
2
-
* A “person” is an object with a “name” field and optionally “url” and “email”. Or you can shorten that all into a single string, and npm will parse it for you.
3
-
*/
4
-
exporttypePackageJsonPerson=
5
-
|string
6
-
|{
7
-
name: string;
8
-
email?: string;
9
-
url?: string;
10
-
};
11
-
12
-
typePackageJsonExportKey=
13
-
|"."
14
-
|"import"
15
-
|"require"
16
-
|"types"
17
-
|"node"
18
-
|"browser"
19
-
|"default"
20
-
|(string&{});
21
-
22
-
typePackageJsonExportsObject={
23
-
[PinPackageJsonExportKey]?:
24
-
|string
25
-
|PackageJsonExportsObject
26
-
|Array<string|PackageJsonExportsObject>;
27
-
};
28
-
29
-
exporttypePackageJsonExports=
30
-
|string
31
-
|PackageJsonExportsObject
32
-
|Array<string|PackageJsonExportsObject>;
33
-
34
1
exportinterfacePackageJson{
35
2
/**
36
3
* The name is what your thing is called.
@@ -41,18 +8,22 @@ export interface PackageJson {
41
8
* - The name ends up being part of a URL, an argument on the command line, and a folder name. Therefore, the name can’t contain any non-URL-safe characters.
42
9
*/
43
10
name?: string;
11
+
44
12
/**
45
13
* Version must be parseable by `node-semver`, which is bundled with npm as a dependency. (`npm install semver` to use it yourself.)
46
14
*/
47
15
version?: string;
16
+
48
17
/**
49
18
* Put a description in it. It’s a string. This helps people discover your package, as it’s listed in `npm search`.
50
19
*/
51
20
description?: string;
21
+
52
22
/**
53
23
* Put keywords in it. It’s an array of strings. This helps people discover your package as it’s listed in `npm search`.
* The url to your project’s issue tracker and / or the email address to which issues should be reported. These are helpful for people who encounter issues with your package.
63
34
*/
64
35
bugs?:
65
-
|string
66
-
|{
67
-
url?: string;
68
-
email?: string;
69
-
};
36
+
|string
37
+
|{
38
+
url?: string;
39
+
email?: string;
40
+
};
41
+
70
42
/**
71
43
* You should specify a license for your package so that people know how they are permitted to use it, and any restrictions you’re placing on it.
72
44
*/
73
45
license?: string;
46
+
74
47
/**
75
48
* Specify the place where your code lives. This is helpful for people who want to contribute. If the git repo is on GitHub, then the `npm docs` command will be able to find you.
76
49
* For GitHub, GitHub gist, Bitbucket, or GitLab repositories you can use the same shortcut syntax you use for npm install:
77
50
*/
78
51
repository?:
79
-
|string
80
-
|{
81
-
type: string;
82
-
url: string;
83
-
/**
84
-
* If the `package.json` for your package is not in the root directory (for example if it is part of a monorepo), you can specify the directory in which it lives:
85
-
*/
86
-
directory?: string;
87
-
};
52
+
|string
53
+
|{
54
+
type: string;
55
+
url: string;
56
+
/**
57
+
* If the `package.json` for your package is not in the root directory (for example if it is part of a monorepo), you can specify the directory in which it lives:
58
+
*/
59
+
directory?: string;
60
+
};
61
+
62
+
/**
63
+
* The `scripts` field is a dictionary containing script commands that are run at various times in the lifecycle of your package.
64
+
*/
88
65
scripts?: Record<string,string>;
66
+
89
67
/**
90
68
* If you set `"private": true` in your package.json, then npm will refuse to publish it.
91
69
*/
92
70
private?: boolean;
71
+
93
72
/**
94
73
* The “author” is one person.
95
74
*/
96
75
author?: PackageJsonPerson;
76
+
97
77
/**
98
78
* “contributors” is an array of people.
99
79
*/
100
80
contributors?: PackageJsonPerson[];
81
+
101
82
/**
102
83
* The optional `files` field is an array of file patterns that describes the entries to be included when your package is installed as a dependency. File patterns follow a similar syntax to `.gitignore`, but reversed: including a file, directory, or glob pattern (`*`, `**\/*`, and such) will make it so that file is included in the tarball when it’s packed. Omitting the field will make it default to `["*"]`, which means it will include all files.
103
84
*/
104
85
files?: string[];
86
+
105
87
/**
106
88
* The main field is a module ID that is the primary entry point to your program. That is, if your package is named `foo`, and a user installs it, and then does `require("foo")`, then your main module’s exports object will be returned.
107
89
* This should be a module ID relative to the root of your package folder.
108
90
* For most modules, it makes the most sense to have a main script and often not much else.
109
91
*/
110
92
main?: string;
93
+
111
94
/**
112
95
* If your module is meant to be used client-side the browser field should be used instead of the main field. This is helpful to hint users that it might rely on primitives that aren’t available in Node.js modules. (e.g. window)
113
96
*/
114
97
browser?: string|Record<string,string|false>;
98
+
115
99
/**
116
100
* The `unpkg` field is used to specify the URL to a UMD module for your package. This is used by default in the unpkg.com CDN service.
117
101
*/
118
102
unpkg?: string;
103
+
119
104
/**
120
105
* A map of command name to local file name. On install, npm will symlink that file into `prefix/bin` for global installs, or `./node_modules/.bin/` for local installs.
121
106
*/
122
107
bin?: string|Record<string,string>;
108
+
123
109
/**
124
110
* Specify either a single file or an array of filenames to put in place for the `man` program to find.
125
111
*/
126
112
man?: string|string[];
113
+
127
114
/**
128
115
* Dependencies are specified in a simple object that maps a package name to a version range. The version range is a string which has one or more space-separated descriptors. Dependencies can also be identified with a tarball or git URL.
129
116
*/
130
117
dependencies?: Record<string,string>;
118
+
131
119
/**
132
120
* If someone is planning on downloading and using your module in their program, then they probably don’t want or need to download and build the external test or documentation framework that you use.
133
121
* In this case, it’s best to map these additional items in a `devDependencies` object.
134
122
*/
135
123
devDependencies?: Record<string,string>;
124
+
136
125
/**
137
126
* If a dependency can be used, but you would like npm to proceed if it cannot be found or fails to install, then you may put it in the `optionalDependencies` object. This is a map of package name to version or url, just like the `dependencies` object. The difference is that build failures do not cause installation to fail.
138
127
*/
139
128
optionalDependencies?: Record<string,string>;
129
+
140
130
/**
141
131
* In some cases, you want to express the compatibility of your package with a host tool or library, while not necessarily doing a `require` of this host. This is usually referred to as a plugin. Notably, your module may be exposing a specific interface, expected and specified by the host documentation.
142
132
*/
143
133
peerDependencies?: Record<string,string>;
134
+
144
135
/**
145
136
* TypeScript typings, typically ending by `.d.ts`.
146
137
*/
147
138
types?: string;
139
+
148
140
/**
149
141
* This field is synonymous with `types`.
150
142
*/
151
143
typings?: string;
144
+
152
145
/**
153
146
* Non-Standard Node.js alternate entry-point to main.
154
147
* An initial implementation for supporting CJS packages (from main), and use module for ESM modules.
155
148
*/
156
149
module?: string;
150
+
157
151
/**
158
152
* Make main entry-point be loaded as an ESM module, support "export" syntax instead of "require"
* A “person” is an object with a “name” field and optionally “url” and “email”. Or you can shorten that all into a single string, and npm will parse it for you.
0 commit comments