GoogleChromeLabs / browser-fs-access

File System Access API with legacy fallback in the browser
https://googlechromelabs.github.io/browser-fs-access/demo/
Apache License 2.0
1.38k stars 84 forks source link

'self is not defined' in Nuxt SSG #34

Closed kota-yata closed 3 years ago

kota-yata commented 3 years ago

Since Nuxt Universal(SSR/SSG) create page on server side, openFile function failed in Nuxt project

Reference Error : self is not defined

To deal with this error, I added a conditional branch in supported.mjs of in node_modules and it works well.

// @license © 2020 Google LLC. Licensed under the Apache License, Version 2.0.
let e;
if(process.browser) {
  e="chooseFileSystemEntries"in self?"chooseFileSystemEntries":"showOpenFilePicker"in self&&"showOpenFilePicker";
}

export default e;

I'm going to send PR soon

tomayac commented 3 years ago

See https://github.com/GoogleChromeLabs/browser-fs-access/pull/35#issuecomment-787809762 for the rationale for closing this.