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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uncaught TypeError: Cannot read properties of undefined (reading 'prototype') at dd-gridstack.js:369:23 #2039

Closed
mengyu987 opened this issue Sep 16, 2022 · 13 comments · Fixed by #2121

Comments

@mengyu987
Copy link

An error is displayed after the VUE project is packaged
Uncaught TypeError: Cannot read properties of undefined (reading 'prototype') at dd-gridstack.js:139

@adumesny
Copy link
Member

you don't say what rev you are using, so the line number don't line up, but I assume the first one, and what you include.

GridStack.prototype._setupAcceptWidget = ...

https://github.com/gridstack/gridstack.js#extend-library
should work. closing.

@mengyu987
Copy link
Author

Some files cannot be found due to a bug after Vite2.0 is built,
led to Uncaught TypeError: Cannot read properties of undefined (reading 'prototype')
thank you for your reply
拴Q

@leiyaguang
Copy link

same problem

@mengyu987
Copy link
Author

同样的问题

你用的是vite来构建嘛,我将我的vite2升级为vite3就没问题了,我想可能是vite的问题

@leiyaguang
Copy link

leiyaguang commented Sep 19, 2022

是用vite2构建的,我更换了导入的地址后可以了。

// @ts-ignore
import GridStack from 'gridstack/dist/es5/gridstack-all';

@mengyu987
Copy link
Author

这样也可以,不过升级下vite也可以,2的bug太多了

@adumesny
Copy link
Member

adumesny commented Sep 19, 2022

read the doc - https://github.com/gridstack/gridstack.js#include - wrong include way (gridstack-all.js is only packaged for html include). use

import { GridStack } from 'gridstack';

@mengyu987
Copy link
Author

阅读文档 - https://github.com/gridstack/gridstack.js#include - 错误的包含方式(gridstack-all.js 仅打包用于 html 包含)。利用

import { GridStack } from 'gridstack';

This error is generated after referencing builds like this in VitE2 at GridStack ^6.0.1.

@adumesny
Copy link
Member

and please write content in english as I cannot translate it. You need to provide a running example showing it is a lib issue as I don't have bandwidth to debug other people issues.

@Ninita1
Copy link

Ninita1 commented Nov 23, 2022

I had the same problem. Locally everything works fine, but in production I had this ""Potentially unhandled rejection [3] TypeError: Cannot read properties of undefined (reading 'prototype')" error.
After some investigation I found that the problem was with the gridstack dependency.
image
I replaced import from "gridstack" to "gridstack/dist/es5/gridstack-all" and now it works fine in production.

@adumesny
Copy link
Member

adumesny commented Nov 23, 2022

ha thanks for the hint... I see those methods I extracted out to different file (from when I supported static smaller bundle) and could remove that now..

@adumesny adumesny reopened this Nov 23, 2022
@Pretagonist
Copy link

I have the same issue. When I use Vue 3 / Vite and build for production I get Uncaught TypeError: Cannot read properties of undefined (reading 'prototype') when the app tries to set the prototype methods for gridstack.

My guess is that something in the new method of importing fails in some way. When using the old way it worked in prod just fine. It's hard to troubleshoot since it only happens in the minified code but it consistently fails during SetupAcceptWidget.

Using the Vite dev servers with gridstack works without issues.

adumesny added a commit to adumesny/gridstack.js that referenced this issue Dec 27, 2022
* fix gridstack#2039
* moved all the D7D gridstack code into the gridstack.ts file as I gave up on the idea to build s a smaller static only code and delay load the D&D (which is much much smaller now)
as it was causing some build issues for some users...
@adumesny
Copy link
Member

fixed in next release

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.

5 participants