gridstack / gridstack.js

Build interactive dashboards in minutes.
https://gridstackjs.com
MIT License
6.79k stars 1.29k forks source link

Module parse failed: Unexpected token #2844

Closed Nadir-Alishly closed 1 day ago

Nadir-Alishly commented 1 day ago

Issue

When importing mentioned versions of gridstack.js on Vue 2 framework, and running npm start I get error below.

ERROR in ./node_modules/gridstack/dist/gridstack.js 182:33
Module parse failed: Unexpected token (182:33)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
|             opts._alwaysShowResizeHandle = opts.alwaysShowResizeHandle;
|         }
>         let bk = opts.columnOpts?.breakpoints;
|         // LEGACY: oneColumnMode stuff changed in v10.x - check if user explicitly set something to convert over
|         const oldOpts = opts;
 @ ./src/components/dashboard-grid.vue?vue&type=script&lang=js (./node_modules/vue-loader/lib??vue-loader-options!./src/components/dashboard-grid.vue?vue&type=script&lang=js) 23:6-25
 @ ./src/components/dashboard-grid.vue?vue&type=script&lang=js
 @ ./src/components/dashboard-grid.vue
 @ ./node_modules/vue-loader/lib??vue-loader-options!./src/views/class-statistics.vue?vue&type=script&lang=js
 @ ./src/views/class-statistics.vue?vue&type=script&lang=js
 @ ./src/views/class-statistics.vue
 @ ./src/router/routes.js
 @ ./src/router/index.js
 @ ./src/index.js
 @ ./src/entry-server.js

Environment

os: Linux Endavour OS browser: Firefox/ Brave framework: Vue 2.6.14 npm version: 6.14.15 webpack version: 4.41.4

gridstack.js versions: from 8.0.0 to 11.0.1 (works for 7.3.0 and older)

Steps to reproduce

Expected behavior

You should get error mentioned above in your console

My Thoughts

This gridstack.js versions may be incompatible with webpack version.

adumesny commented 1 day ago

opts.columnOpts?.breakpoints you must be using a very old versin of typescript if that is not supported. v8 is ES2020 https://github.com/gridstack/gridstack.js/releases?q=v8.0.0&expanded=true so you might need to use newer settings or use the old es5 folder content for legacy.