musicbrainz-api 0.20.2 → 0.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +26 -18
- package/lib/entry-default.d.ts +0 -4
- package/package.json +7 -9
- package/lib/entry-default.cjs +0 -5
- package/lib/entry-node.cjs +0 -5
package/README.md
CHANGED
|
@@ -473,27 +473,35 @@ async function getCoverArt(releaseGroupMbid, coverType = '') {
|
|
|
473
473
|
|
|
474
474
|
## CommonJS backward compatibility
|
|
475
475
|
|
|
476
|
-
|
|
476
|
+
I recommend CommonJS projects to consider upgrading their project to ECMAScript Module (ESM).
|
|
477
|
+
Please continue reading how to use **musicbrainz-api** in a CommonJS project.
|
|
478
|
+
|
|
479
|
+
Using Node.js ≥ 22, which is support loading ESM module via require, you can use:
|
|
477
480
|
```js
|
|
478
|
-
const {
|
|
481
|
+
const { MusicBrainzApi } = require('musicbrainz-api');
|
|
482
|
+
```
|
|
479
483
|
|
|
480
|
-
|
|
484
|
+
Other CommonJS projects have to use [dynamic import](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Operators/import) to load the **musicbrainz-api** pure ESM module:
|
|
485
|
+
```js
|
|
486
|
+
async function run() {
|
|
487
|
+
// Dynamically loads the ESM module in a CommonJS project
|
|
488
|
+
const { MusicBrainzApi } = await import('musicbrainz-api');
|
|
489
|
+
};
|
|
481
490
|
|
|
482
|
-
|
|
483
|
-
|
|
491
|
+
run();
|
|
492
|
+
```
|
|
484
493
|
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
appContactInfo: 'user@mail.org',
|
|
489
|
-
});
|
|
494
|
+
This is known not to work in TypeScript CommonJS projects, as the TypeScript compiler, in my opinion,
|
|
495
|
+
incorrectly converts the [dynamic import](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Operators/import)
|
|
496
|
+
to `require()`. To perform the dynamic import in TypeScript, you can use [load-esm](https://github.com/Borewit/load-esm):
|
|
490
497
|
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
console.log(release.title);
|
|
494
|
-
}
|
|
495
|
-
})();
|
|
496
|
-
```
|
|
498
|
+
```js
|
|
499
|
+
import {loadEsm} from 'load-esm';
|
|
497
500
|
|
|
498
|
-
|
|
499
|
-
|
|
501
|
+
async function run() {
|
|
502
|
+
// Dynamically loads the ESM module in a TypeScript CommonJS project
|
|
503
|
+
const { MusicBrainzApi } = await loadEsm<typeof import('musicbrainz-api')>('musicbrainz-api');
|
|
504
|
+
};
|
|
505
|
+
|
|
506
|
+
run();
|
|
507
|
+
```
|
package/lib/entry-default.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,23 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "musicbrainz-api",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.21.0",
|
|
4
4
|
"description": "MusicBrainz API client for reading and submitting metadata",
|
|
5
5
|
"exports": {
|
|
6
6
|
"node": {
|
|
7
|
-
"
|
|
8
|
-
"
|
|
7
|
+
"types": "./lib/entry-node.d.ts",
|
|
8
|
+
"default": "./lib/entry-node.js"
|
|
9
9
|
},
|
|
10
10
|
"default": {
|
|
11
|
-
"
|
|
12
|
-
"
|
|
11
|
+
"types": "./lib/entry-default.d.ts",
|
|
12
|
+
"default": "./lib/entry-default.js"
|
|
13
13
|
}
|
|
14
14
|
},
|
|
15
|
-
"types": "lib/
|
|
15
|
+
"types": "lib/entry-default.d.ts",
|
|
16
16
|
"files": [
|
|
17
17
|
"lib/**/*.js",
|
|
18
|
-
"lib/**/*.d.ts"
|
|
19
|
-
"lib/entry-node.cjs",
|
|
20
|
-
"lib/entry-default.cjs"
|
|
18
|
+
"lib/**/*.d.ts"
|
|
21
19
|
],
|
|
22
20
|
"type": "module",
|
|
23
21
|
"author": {
|
package/lib/entry-default.cjs
DELETED