Skip to content

Commit 0165a5f

Browse files
committed
Make requested changes
1 parent af2be86 commit 0165a5f

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
],
1818
"license": "MIT",
1919
"type": "module",
20-
"jsdelivr": "./dist/umd/index.min.js",
20+
"main": "./dist/umd/index.min.js",
2121
"exports": {
2222
".": {
2323
"types": "./dist/types/index.d.ts",

vite.config.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,14 @@ export default defineConfig(({ mode }) => {
1212
build: {
1313
// for UMD build we do not want to empty directory, so previous builds stay intact
1414
emptyOutDir: isCJSBuild,
15-
minify: true,
15+
// don't minify CJS build, Node.js doesn't benefit from it
16+
minify: !isCJSBuild,
1617
sourcemap: true,
17-
// UMD build targets lower level ES, while CJS the lowest Node.js LTS version
18+
// UMD build should target the lowest level ES,
19+
// while CJS the lowest Node.js LTS compatible version
1820
target: isCJSBuild ? "es2022" : "es6",
1921
lib: {
20-
// leave out token from UMD build
22+
// leave out token export from UMD build
2123
entry: isCJSBuild ? [indexInput, tokenInput] : indexInput,
2224
name: isCJSBuild ? undefined : globalVarName,
2325
formats: isCJSBuild ? ["cjs"] : ["umd"],
@@ -37,7 +39,9 @@ export default defineConfig(({ mode }) => {
3739
// make sure external imports that should not be bundled are listed here for CJS build
3840
external: ["node:crypto"],
3941
}
40-
: // https://github.com/vitejs/vite/issues/11624
42+
: // the following code enables Vite in UMD mode to extend the global object with all of
43+
// the exports, and not just a property of it ( https://github.com/vitejs/vite/issues/11624 )
44+
// TODO: Remove this in the future ( https://github.com/meilisearch/meilisearch-js/issues/1806 )
4145
{
4246
output: {
4347
footer: `(function(d,_){(d=typeof globalThis!="undefined"?globalThis:d||self,_(d))})(this,function(d){for(var k of Object.keys(d.${globalVarName})){d[k]=d.${globalVarName}[k]}})`,

0 commit comments

Comments
 (0)