Picture of Chris Gillison
Component javascript errors
by Chris Gillison - Monday, 21 June 2021, 10:07 AM
 

Hi all,

I've just jumped from Framework 5.6.1 to Framework 5.14.0 and I'm now getting similar javascript errors for 2 components - adapt-chartjs and adapt-dragndrop when I try to build the course.

Both components try to use extra .js files located in each component's js folder which ssems to break javascript:compile. I tried moving the js files to the core/js folder and updating the paths to them, but got the same errors.

Error for chart:

src\components\adapt-chartjs\js\Chart.min.js: Cannot read property 'type' of undefined

Errors for dragndrop:

src\components\adapt-dragndrop\js\jquery.ui.touch-punch.js: Cannot read property 'type' of undefined

src\components\adapt-dragndrop\js\jquery-ui.min.js: Cannot read property 'type' of undefined

Neither component has been updated in a fair while, and I'll log the issue on the respective gitHub repositories, but does anyone know of a quick fix to get these components up and running? They're great and I use them regularly!

Picture of Oliver Foster
Re: Component javascript errors
by Oliver Foster - Monday, 21 June 2021, 10:31 AM
 

Will have a look. 

Picture of Oliver Foster
Re: Component javascript errors
by Oliver Foster - Monday, 21 June 2021, 10:56 AM
 

It's because Adapt is now trying to convert the libraries from define/require (AMD syntax) to ES6 import/export.

Those files should be moved to the `libraries/Chart.min.js` folder and imported into Adapt via `libraries/Chart.min`.

This will exclude them from the transpilation process. 

Picture of Chris Gillison
Re: Component javascript errors
by Chris Gillison - Monday, 21 June 2021, 12:16 PM
 

Ah. Perfect! Thanks Ollie

Picture of Oliver Foster
Re: Component javascript errors
by Oliver Foster - Monday, 21 June 2021, 12:53 PM
 

No worries. Apologies for breaking them.

Picture of Oliver Foster
Re: Component javascript errors
by Oliver Foster - Monday, 21 June 2021, 5:04 PM
 

Could you try this PR https://github.com/adaptlearning/adapt_framework/pull/3181 to see if it helps?

Picture of Chris Gillison
Re: Component javascript errors
by Chris Gillison - Tuesday, 22 June 2021, 9:12 AM
 

Both components are working fine for me if I move the problematic .js files into a separate 'libraries' folder added to the 'src' folder and updating the paths to them. When I revert that change and use the PR, the  javascript:compile error returns.

Picture of Oliver Foster
Re: Component javascript errors
by Oliver Foster - Tuesday, 22 June 2021, 9:59 AM
 

You'd need to delete your node_modules folder, update the package.json with that new version number and then reinstall the node_modules using "npm install"

Picture of Chris Gillison
Re: Component javascript errors
by Chris Gillison - Tuesday, 22 June 2021, 11:00 AM
 

Oops - apologies. Done that. No errors when I build, but just getting a blank screen when I run grunt server now :(

Picture of Oliver Foster
Re: Component javascript errors
by Oliver Foster - Tuesday, 22 June 2021, 11:12 AM
 

Any console logs in the browser?

Picture of Chris Gillison
Re: Component javascript errors
by Chris Gillison - Tuesday, 22 June 2021, 11:20 AM
 

UPDATE: Sorry, forgot to put Chart.min back in the chartjs component's js folder. Building & running without errors now. :)

Picture of Oliver Foster
Re: Component javascript errors
by Oliver Foster - Tuesday, 22 June 2021, 11:51 AM
 

Coool. Thanks for reporting. Glad we got a solution, both ways.

Really they should be in the libraries folder, but at least it's not broken any more.

Picture of Chris Gillison
Re: Component javascript errors
by Chris Gillison - Tuesday, 22 June 2021, 12:34 PM
 

Many thanks for looking into it so swiftly.

Picture of Oliver Foster
Re: Component javascript errors
by Oliver Foster - Tuesday, 22 June 2021, 1:35 PM
 

No worries. 

 

Would you be able to leave a comment on the pr to say it worked? https://github.com/adaptlearning/adapt_framework/pull/3181

 

It's part of our review process.