From b52bbaaef7475ee527fea042424d778a73ef152f Mon Sep 17 00:00:00 2001 From: Harry Doan Date: Sat, 27 Jan 2024 22:52:26 -0800 Subject: [PATCH] [js] generate mjs file for esm (#13) --- javascript/package.json | 2 +- javascript/rollup.config.js | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/javascript/package.json b/javascript/package.json index 92f9b32..71fd5ec 100644 --- a/javascript/package.json +++ b/javascript/package.json @@ -14,7 +14,7 @@ "license": "MIT", "exports": { ".": { - "import": "./dist/index.js", + "import": "./dist/index.mjs", "require": "./dist/cjs/index.js" }, "./package.json": "./package.json" diff --git a/javascript/rollup.config.js b/javascript/rollup.config.js index c4c9bc9..464c357 100644 --- a/javascript/rollup.config.js +++ b/javascript/rollup.config.js @@ -27,6 +27,8 @@ export default { { dir: isCJSBuild ? 'dist/cjs' : 'dist', format: isCJSBuild ? 'cjs' : 'esm', + entryFileNames: isCJSBuild ? '[name].js' : '[name].mjs', // Output file name pattern + chunkFileNames: isCJSBuild ? '[name]-[hash].js' : '[name]-[hash].mjs', // For code splitting }, ], plugins: [ts({ tsconfig: isCJSBuild ? 'tsconfig.cjs.json' : 'tsconfig.json' }), commonjsPkgJSONPlugin()],