Conversation
WE2-1179 Signed-off-by: Sven Mitt <svenzik@users.noreply.github.com> Co-authored-by: Toomas Pärna <toomy4@users.noreply.github.com>
WE2-1179 Signed-off-by: Sven Mitt <svenzik@users.noreply.github.com>
e50b145 to
b007320
Compare
| }, | ||
| "module": "web-eid.js", | ||
| "main": "./dist/umd/web-eid.js", | ||
| "module": "./dist/es/web-eid.js", |
There was a problem hiding this comment.
The module property should be removed.
https://stackoverflow.com/questions/42708484/what-is-the-module-package-json-field-for
The
modulefield is not officially defined by Node.js and support is not planned. Instead, the Node.js community settled on package exports which they believe is more versatile.For practical reasons JavaScript bundlers will continue to support the
modulefield. The esbuild docs explain when to usemoduleas well as related fieldsmainandbrowser.
This field came from a proposal for how to integrate ECMAScript modules into node. Because of this, it's reasonable to expect that the file path in this field is an ECMAScript-style module. This proposal wasn't adopted by node (node uses
"type": "module"instead) but it was adopted by major bundlers because ECMAScript-style modules lead to better tree shaking, or dead code removal.For package authors: Some packages incorrectly use the
modulefield for browser-specific code, leaving node-specific code for themainfield. This is probably because node ignores themodulefield and people typically only use bundlers for browser-specific code. However, bundling node-specific code is valuable too (e.g. it decreases download and boot time) and packages that put browser-specific code inmoduleprevent bundlers from being able to do tree shaking effectively. If you are trying to publish browser-specific code in a package, use thebrowserfield instead.
| "url": "git@github.com:web-eid/web-eid.js.git" | ||
| }, | ||
| "module": "web-eid.js", | ||
| "main": "./dist/umd/web-eid.js", |
There was a problem hiding this comment.
The main property should be removed. It wasn't there in version 2.0.
This should be double checked. In which Node version was exports property added and which Node version is supported.
https://nodejs.org/api/packages.html#nodejs-packagejson-field-definitions
"main" - The default module when loading the package, if exports is not specified, and in versions of Node.js prior to the introduction of exports.
| export type { | ||
| ActionOptions, | ||
| LibraryAuthenticateResponse, | ||
| LibraryGetSigningCertificateResponse, | ||
| LibrarySignResponse, | ||
| LibraryStatusResponse | ||
| }; |
There was a problem hiding this comment.
Consider the following:
export {
ActionOptions,
LibraryAuthenticateResponse as AuthenticateResponse,
LibraryGetSigningCertificateResponse as GetSigningCertificateResponse,
LibrarySignResponse as SignResponse,
LibraryStatusResponse as StatusResponse,
};
|
WE2-1179