From 27ad96ddc9ca82fbf13fc9b33f85db52cc025055 Mon Sep 17 00:00:00 2001 From: Denis Davidyuk Date: Wed, 9 Feb 2022 18:35:13 +0300 Subject: [PATCH] fix: importing through mjs in webpack@4 --- package.json | 5 +++-- scripts/build.sh | 2 ++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 96a2fd6d..5c290add 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,7 @@ "uuid": "./dist/bin/uuid" }, "sideEffects": false, - "main": "./dist/index.js", + "main": "./dist/index", "exports": { ".": { "node": { @@ -39,7 +39,8 @@ "./dist/native.js": "./dist/native-browser.js", "./dist/rng.js": "./dist/rng-browser.js", "./dist/sha1.js": "./dist/sha1-browser.js", - "./dist/esm-node/index.js": "./dist/esm-browser/index.js" + "./dist/esm-node/index.js": "./dist/esm-browser/index.js", + "./dist/index.mjs": "./dist/esm-browser/index.js" }, "files": [ "CHANGELOG.md", diff --git a/scripts/build.sh b/scripts/build.sh index 1836a687..ba44feb4 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -38,6 +38,8 @@ babel --env-name esmBrowser src --source-root src --out-dir "$DIR/esm-browser" - # Transpile ESM versions of files for node babel --env-name esmNode src --source-root src --out-dir "$DIR/esm-node" --copy-files --quiet +echo "export * from './esm-node';" > "$DIR/index.mjs" + # No need to have the CLI files in the esm build rm -rf "$DIR/commonjs-browser/bin" rm -rf "$DIR/commonjs-browser/uuid-bin.js"