diff --git a/package.json b/package.json index f764536..ebf7326 100644 --- a/package.json +++ b/package.json @@ -2,9 +2,12 @@ "name": "hash-wasm", "version": "4.12.0", "description": "Lightning fast hash functions for browsers and Node.js using hand-tuned WebAssembly binaries (MD4, MD5, SHA-1, SHA-2, SHA-3, Keccak, BLAKE2, BLAKE3, PBKDF2, Argon2, bcrypt, scrypt, Adler-32, CRC32, CRC32C, RIPEMD-160, HMAC, xxHash, SM3, Whirlpool)", - "main": "dist/index.umd.js", - "module": "dist/index.esm.js", - "types": "dist/lib/index.d.ts", + "main": "dist/index.cjs", + "exports": { + "require": "dist/index.cjs", + "default": "dist/index.mjs" + }, + "types": "dist/index.d.ts", "scripts": { "build": "sh -c ./scripts/build.sh", "lint": "npx @biomejs/biome check lib test", diff --git a/rollup.config.mjs b/rollup.config.mjs index fbbfa8f..ccf997d 100644 --- a/rollup.config.mjs +++ b/rollup.config.mjs @@ -53,13 +53,16 @@ const MAIN_BUNDLE_CONFIG = { input: "lib/index.ts", output: [ { - file: "dist/index.umd.js", + file: "dist/index.cjs", name: "hashwasm", format: "umd", }, { - file: "dist/index.esm.js", format: "es", + entryFileNames: "[name].mjs", + preserveModules: true, + preserveModulesRoot: "lib", + dir: "dist", }, ], plugins: [json(), typescript(), license(LICENSE_CONFIG)], @@ -69,12 +72,12 @@ const MINIFIED_MAIN_BUNDLE_CONFIG = { input: "lib/index.ts", output: [ { - file: "dist/index.umd.min.js", + file: "dist/index.min.cjs", name: "hashwasm", format: "umd", }, { - file: "dist/index.esm.min.js", + file: "dist/index.min.mjs", format: "es", }, ], @@ -90,7 +93,7 @@ const INDIVIDUAL_BUNDLE_CONFIG = (algorithm) => ({ input: `lib/${algorithm}.ts`, output: [ { - file: `dist/${algorithm}.umd.min.js`, + file: `dist/${algorithm}.min.cjs`, name: "hashwasm", format: "umd", extend: true, diff --git a/scripts/build.sh b/scripts/build.sh index 5d04b31..9319a5c 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -32,6 +32,6 @@ docker volume rm hash-wasm-volume # node scripts/optimize node scripts/make_json node --max-old-space-size=4096 ./node_modules/rollup/dist/bin/rollup -c -npx tsc ./lib/index --outDir ./dist --downlevelIteration --emitDeclarationOnly --declaration --resolveJsonModule --allowSyntheticDefaultImports +npx tsc ./lib/index --rootDir ./lib --outDir ./dist --downlevelIteration --emitDeclarationOnly --declaration --resolveJsonModule --allowSyntheticDefaultImports #-s ASSERTIONS=1 \ diff --git a/tsconfig.json b/tsconfig.json index c462cad..54c3c35 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,9 +1,10 @@ { "compilerOptions": { - "target": "ES6", "module": "ES6", - "lib": ["es2017", "es7", "es6", "dom"], + "target": "es2017", + "lib": ["es2017", "dom"], "baseUrl": ".", + "rootDir": "lib", "strict": false, "esModuleInterop": true, "downlevelIteration": true, @@ -13,4 +14,4 @@ "include": [ "lib", ] -} \ No newline at end of file +}