Skip to content

fix: Dispatch correctly for bundlers like webpack#84

Merged
jan-auer merged 11 commits intomasterfrom
fix/dispatch
May 24, 2018
Merged

fix: Dispatch correctly for bundlers like webpack#84
jan-auer merged 11 commits intomasterfrom
fix/dispatch

Conversation

@jan-auer
Copy link
Member

@jan-auer jan-auer commented May 14, 2018

Frontend bundlers like webpack and rollup will statically resolve all requires, which might break the build or switch to the main process implementation in renderers. This PR should fix this by using module.require for importing the main implementation, which bypasses static bundlers entirely.

The updated example also verifies that sandbox mode works. Next step would be to update tests to use sandbox: true and then remove the disclaimer from docs and add a guide on how to use the SDK in sandbox mode properly, instead.

This diff is rather large, see the comment below for the relevant section. There should be sufficient code documentation above that statement explaining the reasoning behind this approach.

See #81 for more information.

@jan-auer jan-auer requested a review from timfish May 14, 2018 15:04
@jan-auer jan-auer self-assigned this May 14, 2018
@jan-auer jan-auer added the bug label May 14, 2018
const frontendClass: FrontendClass<CommonFrontend, ElectronOptions> =
process.type === 'browser'
? require('./main').MainFrontend
? module.require('./main').MainFrontend
Copy link
Member Author

Choose a reason for hiding this comment

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

This is the actual fix, the rest is just an updated example.

@jan-auer jan-auer requested a review from HazAT May 23, 2018 14:13
@jan-auer
Copy link
Member Author

This is ready now.

Copy link
Member

@HazAT HazAT left a comment

Choose a reason for hiding this comment

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

Like the IPC_PING 🏅

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.

3 participants