Skip to content

Commit 80bc464

Browse files
committed
Fix vite global patch for browser environments
1 parent 489b583 commit 80bc464

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

vite.config.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,13 @@ export default defineConfig(({ mode }) => {
4444
// TODO: Remove this in the future ( https://github.com/meilisearch/meilisearch-js/issues/1806 )
4545
{
4646
output: {
47-
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]}})`,
47+
footer: `(function () {
48+
if (typeof self !== "undefined") {
49+
var clonedGlobal = Object.assign({}, self.${globalVarName});
50+
delete clonedGlobal.default;
51+
Object.assign(self, clonedGlobal);
52+
}
53+
})();`,
4854
},
4955
},
5056
},

0 commit comments

Comments
 (0)