Skip to content

Indirect dependency on Node environment #150

@kamsar

Description

@kamsar

I'm using url-parse within an Angular 6 (angular-cli) app.

Within url-parse, there's a place where it's looking for global, which does not exist in a browser environment:

var location = global && global.location || {};

In Angular 6 CLI, they removed webpack features that added a shim for global in a browser environment: angular/angular-cli#9827

When url-parse runs in the browser without the shim, I get ERROR ReferenceError: global is not defined

If I manually add a shim, for example <script>window.global = {};</script> in the head, it works.

It seems like a simple addition of a definition check for global would fix it longer term, such as:

typeof global !== 'undefined' && global.location || {};

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions