Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

caches collides with the Browser API #492

Closed
steabert opened this issue Feb 20, 2023 · 3 comments · May be fixed by #628
Closed

caches collides with the Browser API #492

steabert opened this issue Feb 20, 2023 · 3 comments · May be fixed by #628

Comments

@steabert
Copy link

In one of our projects we use @apollo/client wich itself includes this package. After bundling as ES module, there is a top-level variable caches that seems to collide with the one in the Browser's API.

So, using the optimism's ES module in a browser with type=module doesn't work. Is that the correct behaviour?

@zolero
Copy link

zolero commented May 16, 2023

I've got the same issue. I'll follow this.

@zolero
Copy link

zolero commented May 16, 2023

Renaming the variable of cache variable in the bundle.cjs.js and bundle.esm.js solves it for me.

const caches = new Set<Cache<any, AnyEntry>>();

Afterwards we make a patch using:

patch-package optimism

Hope this helps.

lekoaf added a commit to lekoaf/optimism that referenced this issue Dec 14, 2023
Renames the `caches` variable because
it interferes with the global browser
API.

Fixes benjamn#492
@steabert
Copy link
Author

Revisiting this problem, I think I probably made the mistake of loading an ESM bundle as text/javascript while going back and forth between ESM and IIFE, and didn't notice that. If I load my ESM bundle as module it all works (as it should).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants