Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot import react-bootstrap-typeahead #9350

Closed
gagdiez opened this issue Oct 30, 2023 · 2 comments 路 Fixed by #9362
Closed

Cannot import react-bootstrap-typeahead #9350

gagdiez opened this issue Oct 30, 2023 · 2 comments 路 Fixed by #9362

Comments

@gagdiez
Copy link
Contributor

gagdiez commented Oct 30, 2023

馃悰 bug report

Parcel is failing to load the react-bootstrap-typeahead component, failing with the error: TypeError: Cannot read properties of undefined (reading 'default')

馃帥 Configuration (.babelrc, package.json, cli command)

see repository bellow

{
  "name": "my-near-app",
  "version": "1.0.0",
  "license": "(MIT AND Apache-2.0)",
  "type": "module",
  "scripts": {
    "start": "parcel index.html"
  },
  "dependencies": {
    "react": "^18.2.0",
    "react-bootstrap-typeahead": "6.3.1",
    "react-dom": "^18.2.0"
  },
  "devDependencies": {
    "parcel": "^2.10.1",
    "process": "^0.11.10"
  }
}

minimal repo to reproduce error here: https://github.com/gagdiez/rbt-error-minimal

馃 Expected Behavior

The library should load and no error be displayed

馃槸 Current Behavior

hasOwnProperty
node_modules/.pnpm/react-bootstrap-typeahead@6.3.1_react-dom@18.2.0_react@18.2.0/node_modules/react-bootstrap-typeahead/es/utils/index.js:17
  14 | export { default as getStringLabelKey } from './getStringLabelKey';
  15 | export { default as getTruncatedOptions } from './getTruncatedOptions';
  16 | export { default as getUpdatedActiveIndex } from './getUpdatedActiveIndex';
> 17 | export { default as hasOwnProperty } from './hasOwnProperty';
  18 | export { default as isSelectable } from './isSelectable';
  19 | export { default as isShown } from './isShown';
  20 | export * from './nodash';
View compiled
(anonymous function)
node_modules/.pnpm/@parcel+transformer-js@2.10.1_@parcel+core@2.10.1/node_modules/@parcel/transformer-js/src/esmodule-helpers.js:11:58
   8 | 
   9 | exports.exportAll = function (source, dest) {
  10 |   Object.keys(source).forEach(function (key) {
> 11 |     if (key === 'default' || key === '__esModule' || dest.hasOwnProperty(key)) {
     |                                                          ^  12 |       return;
  13 |     }
  14 | 

馃敠 Context

Trying to build an application that uses that Component

馃捇 Code Sample

minimal repo to reproduce error here: https://github.com/gagdiez/rbt-error-minimal

馃實 Your Environment

Software Version(s)
Parcel 2.10.1
Node 18.16.0
npm/Yarn yarn 1.22.19
Operating System MacOS Latest stable
@gagdiez gagdiez changed the title Cannot import React Component Cannot import react-bootstrap-typeahead Oct 30, 2023
@ericgio
Copy link

ericgio commented Oct 30, 2023

React-Bootstrap-Typeahead has a helper function called hasOwnProperty. I believe what's happening is that Parcel's esmodule-helpers are trying to call that rather than Object.prototype.hasOwnProperty.

Suggested fix is to call the prototype function directly, which is safer:

Object.prototype.hasOwnProperty.call(dest, key)

@gagdiez
Copy link
Contributor Author

gagdiez commented Nov 4, 2023

can confirm that @ericgio suggestion works, will see to contribute it except if @ericgio prefers to do it (since it was their finding).

@gagdiez gagdiez mentioned this issue Nov 4, 2023
3 tasks
@mischnic mischnic linked a pull request Nov 12, 2023 that will close this issue
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants