TypeError: Cannot read property 'TYPED_ARRAY_SUPPORT' of undefined #803

See original GitHub issue

🐛 bug report

When I import oidc-client and write “new UserManager({…})” in a parcel bundled project, I get this issue: “Uncaught TypeError: Cannot read property ‘TYPED_ARRAY_SUPPORT’ of undefined” I tried it without parcel and it worked. So the issue should be caused by parcel.

🎛 Configuration (.babelrc, package.json, cli command)

{
  "name": "my-project",
  "version": "0.1.0",
  "license": "UNLICENSED",
  "author": "Me",
  "scripts": {
    "start": "parcel src/index.html --no-cache --port 8080",
    "start:build": "http-server dist/ -o",
    "build": "parcel build src/index.html --no-cache"
  },
  "dependencies": {
    "lit-element": "^2.1.0",
    "oidc-client": "^1.7.0"
  },
  "devDependencies": {
    "http-server": "^0.11.1",
    "parcel-bundler": "^1.12.3",
    "parcel-plugin-webcomponents": "^1.2.0"
  },
  "browserslist": [
    "last 2 chrome version",
    "last 2 firefox version",
    "last 2 edge version",
    "last 2 safari version",
    "not dead"
  ]
}

🤔 Expected Behavior

oidc-client should just work.

😯 Current Behavior

image

💁 Possible Solution

No idea

🔦 Context

I just tried to use oidc-client in a parcel bundled project. Everything worked under webpack.

💻 Code Sample

import { UserManager } from 'oidc-client'

const userManager = new UserManager({})

🌍 Your Environment

Software Version(s)
Parcel 1.12.3
Node 11.11.0
npm 6.7.0
Operating System Windows 10

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:16 (6 by maintainers)

github_iconTop GitHub Comments

3reactions
devongovettcommented, Jul 9, 2019

Please don’t use <script type="module"> with parcel. There is no reason to do so as Parcel already compiles es6 modules away.

3reactions
mischniccommented, Mar 24, 2019

The buffer polyfill for browsers contains this code

Buffer.TYPED_ARRAY_SUPPORT = global.TYPED_ARRAY_SUPPORT !== undefined
  ? global.TYPED_ARRAY_SUPPORT
  : "DEFAULT";

If you run the parcel script in a type="module" script (which is unsupported), Parcel can’t get the global object using this because that’s forbidden in this context. Figuring out the global object is actually not trivial: https://github.com/tc39/proposal-global

Which usually doesn’t work because of this whole parcelRequire bug thing, but (and don’t ask me why) everything works fine if you include a css file first.

Doesn’t work for me… (#1401)

Read more comments on GitHub >

github_iconTop Results From Across the Web

Babel - Cannot read property 'TYPED_ARRAY_SUPPORT' of ...
After a week worth of investigation (thanks to @MinusFour for setting me on the right path), It appears that it was a Webpack...
Read more >
TypeError: Cannot read property 'data' of undefined
catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/ ...
Read more >
mqtt.js源码1 - CSDN博客
(function (f) { if (typeof exports === "object" && typeof module !== "undefined") { module.exports = f() } else if (typeof define ...
Read more >
replaceShortcuts - Drafts Directory
TemplateTagParser = void 0; function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a ...
Read more >
Viewing online file analysis results for 'background.js'
No similar samples ... Contains ability to read software policies ... Opens the MountPointManager (often used to detect additional infection ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found