music-metadata 10.8.3 → 10.9.1

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.
Files changed (2) hide show
  1. package/README.md +18 -5
  2. package/package.json +14 -14
package/README.md CHANGED
@@ -771,17 +771,30 @@ Dependency list:
771
771
 
772
772
  ## CommonJS backward compatibility
773
773
 
774
- For legacy CommonJS projects needing to load the `music-metadata` ESM module, you can use the `loadMusicMetadata` function:
774
+ Using Node.js 22, which is support loading ESM module via require
775
775
  ```js
776
- const { loadMusicMetadata } = require('music-metadata');
776
+ const mm = require('music-metadata');
777
+ ```
777
778
 
779
+ For older Node.js version < 22, you need to dynamically import **music-metadata**:
780
+ ```js
778
781
  (async () => {
779
782
  // Dynamically loads the ESM module in a CommonJS project
780
- const mm = await loadMusicMetadata();
781
-
782
- const metadata = await mm.parseFile('/path/to/your/file');
783
+ const mm = await import('music-metadata');
783
784
  })();
785
+ ```
786
+
787
+ For CommonJS TypeScript projects, using a Node.js version < 22, you can use [load-esm](https://github.com/Borewit/load-esm):
788
+
789
+ This method shall replace the embedded CJS loader `loadMusicMetadata()` function.
784
790
 
791
+ ```js
792
+ import {loadEsm} from 'load-esm';
793
+
794
+ (async () => {
795
+ // Dynamically loads the ESM module in a CommonJS project
796
+ const mm = await loadEsm<typeof import('music-metadata')>('music-metadata');
797
+ })();
785
798
  ```
786
799
 
787
800
  > [!NOTE]
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "music-metadata",
3
3
  "description": "Music metadata parser for Node.js, supporting virtual any audio and tag format.",
4
- "version": "10.8.3",
4
+ "version": "10.9.1",
5
5
  "author": {
6
6
  "name": "Borewit",
7
7
  "url": "https://github.com/Borewit"
@@ -18,17 +18,17 @@
18
18
  ],
19
19
  "type": "module",
20
20
  "exports": {
21
- ".": {
22
- "node": {
23
- "import": "./lib/index.js",
24
- "require": "./lib/node.cjs",
25
- "types": "./lib/index.d.ts"
26
- },
27
- "default": {
28
- "import": "./lib/core.js",
29
- "require": "./lib/default.cjs",
30
- "types": "./lib/core.d.ts"
31
- }
21
+ "node": {
22
+ "import": "./lib/index.js",
23
+ "module-sync": "./lib/index.js",
24
+ "require": "./lib/node.cjs",
25
+ "types": "./lib/index.d.ts"
26
+ },
27
+ "default": {
28
+ "import": "./lib/core.js",
29
+ "module-sync": "./lib/core.js",
30
+ "require": "./lib/default.cjs",
31
+ "types": "./lib/core.d.ts"
32
32
  }
33
33
  },
34
34
  "types": "lib/index.d.ts",
@@ -123,9 +123,9 @@
123
123
  "@types/debug": "^4.1.12",
124
124
  "@types/media-typer": "^1.1.3",
125
125
  "@types/mocha": "^10.0.10",
126
- "@types/node": "^22.13.1",
126
+ "@types/node": "^22.13.4",
127
127
  "c8": "^10.1.3",
128
- "chai": "^5.1.2",
128
+ "chai": "^5.2.0",
129
129
  "chai-as-promised": "^8.0.1",
130
130
  "del-cli": "^6.0.0",
131
131
  "mime": "^4.0.6",