From e806b93c03cd7e5e307e28a56629ce501ef07e5b Mon Sep 17 00:00:00 2001 From: Shuyun Yang Date: Mon, 16 Nov 2026 02:57:45 -0800 Subject: [PATCH] fix: preserve distribution source-map filenames --- README.md | 12 +++++------- tools/fix-ext.mts | 2 +- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index c0f4dc0..bf38604 100644 --- a/README.md +++ b/README.md @@ -634,15 +634,13 @@ Note that `JSON` cases use `Buffer` to emulate I/O where a JavaScript string mus ### NPM / npmjs.com -The NPM package distributed in npmjs.com includes both ES2015+ and ES5 files: +The npm package provides three ES2020-targeted builds: -* `dist/` is compiled into ES2020 with CommomJS, provided for NodeJS v10 -* `dist.umd/` is compiled into ES5 with UMD - * `dist.umd/msgpack.min.js` - the minified file - * `dist.umd/msgpack.js` - the non-minified file -* `dist.esm/` is compiled into ES2020 with ES modules, provided for webpack-like bundlers and NodeJS's ESM-mode +* `dist.cjs/index.cjs`: CommonJS entry point for Node.js `require()`, with `index.d.cts` declarations. +* `dist.esm/index.mjs`: ES module entry point for Node.js `import` and compatible bundlers, with `index.d.mts` declarations. +* `dist.umd/msgpack.min.js` and `dist.umd/msgpack.js`: minified and unminified browser bundles, respectively. -If you use NodeJS and/or webpack, their module resolvers use the suitable one automatically. +Node.js requires version 18 or later. Use the package name `@msgpack/msgpack` rather than a path into `dist.cjs/` or `dist.esm/`; the package export map selects the appropriate entry point. ### CDN / unpkg.com diff --git a/tools/fix-ext.mts b/tools/fix-ext.mts index d7cd283..f280d9e 100644 --- a/tools/fix-ext.mts +++ b/tools/fix-ext.mts @@ -35,7 +35,7 @@ for (const file of files) { // .js.map => .mjs.map const mapping = JSON.parse(fs.readFileSync(`${file}.map`).toString("utf-8")); - mapping.file = mapping.file.replace(/\.js$/, ext); + mapping.file = mapping.file.replace(/\.js$/, `.${ext}`); fs.writeFileSync(`${fileMjs}.map`, JSON.stringify(mapping)); fs.unlinkSync(`${file}.map`); }