Skip to content

Set output.globalObject to this #7741

Closed
hchiam/create-react-app
#1
@kentcdodds

Description

@kentcdodds

When using workerize-loader, things work great (it's a fantastic tool), except that it does not work in dev mode. This is because HotModuleReplacement gets loaded into the webworker and the HMR file references window.

Describe the solution you'd like

I'd like to have the webpack configuration set output.globalObject to 'this'. The default is 'window'. Changing it to 'this' will have no negative impact on existing or future users, and it will allow people to begin using workerize-loader without ejecting.

Describe alternatives you've considered

You can manually modify the configuration in node_modules (and just remember to do that anytime you re-install deps). Or you can eject.

Additional context

Before:

image

After:

image

This code is generated from this template:

https://github.com/webpack/webpack/blob/ba20513223607eaccb615c8ffabe824413b1613c/lib/web/JsonpMainTemplatePlugin.js#L603-L606

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions