Skip to content

Commit

Permalink
Merge #1829
Browse files Browse the repository at this point in the history
1829: Fix Vite global patch for browser environments r=Strift a=flevi29

# Pull Request

## What does this PR do?
- adjust footer applied by Vite, so that it doesn't cause issues with Node.js, and doesn't apply default export to global variable

## PR checklist
Please check if your PR fulfills the following requirements:
- [x] Does this PR fix an existing issue, or have you listed the changes applied in the PR description (and why they are needed)?
- [x] Have you read the contributing guidelines?
- [x] Have you made sure that the title is accurate and descriptive of the changes?

Thank you so much for contributing to Meilisearch!


Co-authored-by: F. Levi <[email protected]>
  • Loading branch information
meili-bors[bot] and flevi29 authored Jan 20, 2025
2 parents 489b583 + 80bc464 commit 0b829db
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,13 @@ export default defineConfig(({ mode }) => {
// TODO: Remove this in the future ( https://github.com/meilisearch/meilisearch-js/issues/1806 )
{
output: {
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]}})`,
footer: `(function () {
if (typeof self !== "undefined") {
var clonedGlobal = Object.assign({}, self.${globalVarName});
delete clonedGlobal.default;
Object.assign(self, clonedGlobal);
}
})();`,
},
},
},
Expand Down

0 comments on commit 0b829db

Please sign in to comment.