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

fix: file support for electron renderer #12

Merged
merged 2 commits into from
Jul 23, 2021

Conversation

vasco-santos
Copy link
Member

Previous PR to fix browser export was not enough. File in electron renderer does not use the browser export and uses Node.js, causing ipfs/js-ipfs#3750 CI job in electron renderer to fail.

I think this is the cleanest solution, I moved the File implementation to a new fail, and add a fallback in Node.js.

The Blob implementation has the same issue (does not affect my other PR), if you like this solution I can fix Blob in a next PR

@vasco-santos vasco-santos requested a review from Gozala July 21, 2021 13:19
Copy link
Contributor

@Gozala Gozala left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be good idea to also rename lib.node.js to something less misleading now that it's also deals with electron.


// Marking export as a DOM File object instead of custom class.
/** @type {typeof globalThis.File} */
const File = WebFile
const File = typeof XMLHttpRequest === 'function' ? globalThis.File : WebFile
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not this ?

Suggested change
const File = typeof XMLHttpRequest === 'function' ? globalThis.File : WebFile
const File = typeof globalThis.File === 'function' ? globalThis.File : WebFile

@vasco-santos vasco-santos force-pushed the fix/file-support-for-electron-renderer branch from 1762816 to 5d7a089 Compare July 23, 2021 07:27
@vasco-santos vasco-santos merged commit 55b92ca into main Jul 23, 2021
@vasco-santos vasco-santos deleted the fix/file-support-for-electron-renderer branch July 23, 2021 07:54
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 this pull request may close these issues.

None yet

2 participants