Skip to content

Usage of has-symbols in GetIntrinsic.js breaks non-node usages of package #59

Closed
@nvahalik

Description

In v1.15.0, GetIntrinsic.js started using has-symbols:

https://github.com/ljharb/es-abstract/blob/master/GetIntrinsic.js#L16

When called in a non-node environment, it causes an error since it is referencing global:

Uncaught (in promise): ReferenceError: global is not defined
./node_modules/has-symbols/index.js@http://my-app-here:2024:18
__webpack_require__@http://localhost:8100/runtime.js:84:30
./node_modules/es-abstract/GetIntrinsic.js@http://my-app-here:749:18
__webpack_require__@http://localhost:8100/runtime.js:84:30
./node_modules/es-abstract/es5.js@http://my-app-here:937:20
__webpack_require__@http://localhost:8100/runtime.js:84:30
./node_modules/string.prototype.trim/implementation.js@http://my-app-here:14204:10
__webpack_require__@http://localhost:8100/runtime.js:84:30

I have confirmed that reverting to v1.14.2 fixes the issue.

Activity

ljharb

ljharb commented on Oct 17, 2019

@ljharb
Owner

global is the node global, and every bundler by default changes this to window for browsers.

Perhaps you've deviated from the default settings by adding node: false to your webpack config?

nvahalik

nvahalik commented on Oct 17, 2019

@nvahalik
Author

My current use case is with Ionic v4. Angular builds the app just fine and this problem only happens during runtime.

ljharb

ljharb commented on Oct 17, 2019

@ljharb
Owner

Building the app "just fine" would include transforming global to window for the browser, like every bundler has done since node has existed. I'm not familiar with Ionic specifically.

nvahalik

nvahalik commented on Oct 22, 2019

@nvahalik
Author

@ljharb Apparently for Angular CLI this is no longer the case:

angular/angular-cli#9827 (comment)

Angular used to provide a shim for global but as of 6.x, it is not anymore.

nvahalik

nvahalik commented on Oct 22, 2019

@nvahalik
Author

Closing this ticket out since the problem is actually in the has-symbol module.

ljharb

ljharb commented on Oct 22, 2019

@ljharb
Owner

Then Angular has chosen to make much of the ecosystem incompatible ¯_(ツ)_/¯

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Usage of has-symbols in GetIntrinsic.js breaks non-node usages of package · Issue #59 · ljharb/es-abstract