简体   繁体   中英

Uncaught TypeError: Object(...) is not a function when bundling with WebPack 4

I am importing some library

import { connect } from '@captaincodeman/redux-connect-element';

into my TypeScript 4 Web Component and using it like

export class AppRouterElement extends connect(store, LitElement) {....}

and then simply yarn build (Yarn 2). Build succeeds with no errors, but at run-time I'm getting Uncaught TypeError: Object(...) is not a function

When digging into compiled JavaScript I see output of

let Sr = class extends (Object(wr.connect) (fn, vr)) {....}

which seems missing a comma. If I add that comma in-place, application seems working as expected. If I run the same source build with Rollup i have no runtime error. Which relevant WebPack (or mby TSC) configs I should look into/for. I have no idea about the correct name of this issue, so I stuck to google it properly.

i got a similar error, when import like this

import start from './modules/App.jsx';

it just like this

Uncaught TypeError: Object(...) is not a function
at eval (index.js:4)
at Module../src/index.js (main.d806e840d36f0916cf01.js:589)
at __webpack_require__ (main.d806e840d36f0916cf01.js:20)
at eval (webpack:///multi_(:8080/webpack)-dev-server/client?:2:18)
at Object.0 (main.d806e840d36f0916cf01.js:624)
at __webpack_require__ (main.d806e840d36f0916cf01.js:20)
at main.d806e840d36f0916cf01.js:84
at main.d806e840d36f0916cf01.js:87

after spending a few of my life~, i found i missed braces... just below i fixed

import { start } from './modules/App.jsx';

that is not the corresponding answer, hoping show some tip for you~

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM