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

TypeError: Cannot read property 'type' of undefined #1000

Open
Novynn opened this issue Apr 9, 2019 · 4 comments
Open

TypeError: Cannot read property 'type' of undefined #1000

Novynn opened this issue Apr 9, 2019 · 4 comments

Comments

@Novynn
Copy link

Novynn commented Apr 9, 2019

Came across this problem while trying to optimize a script that requires vue-router@3.0.1. It looks like this line is the culprit:

if (bodyNode.consequent && bodyNode.consequent.body) {

I've fixed it locally by adding && bodyNode.consequent.body.length to the end of the if statement linked because consequent.body is an object not an array in this case ({type: 'BlockStatement', body: {...}}).

@pinuchfab
Copy link

Hello, we had the same problems recently while bundling yfiles.
Would this fix be released in a new version of requirejs from the jquery legacy team?
Regards
Fab

@anandthakker
Copy link

anandthakker commented Jul 15, 2020

I'm seeing this, too, when we optimize a project where one of the included modules is itself a library that was built using r.js (and minified). I can reproduce the error by replacing that module with just this minimal bit of code:

(function () {
  if (typeof define !== 'undefined') for (;;) {
  }
})()

@senthilkumar04
Copy link

Facing the same type error issue while bundling the packages using r.js
TypeError: Cannot read property 'type' of undefined

Is there any updates from the requirejs library for this issue ?

@Novynn Did you find any work around for this issue ?

@prantlf
Copy link

prantlf commented Apr 23, 2023

I maintain a fork using a modern JavaScript parser and enhanced source map support as @prantlf/requirejs. I merged #1005 fixing this problem. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants