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

BUG: Handle Array().concat() version of webpackJsonp #53

Closed
ryan-roemer opened this issue Oct 12, 2017 · 2 comments
Closed

BUG: Handle Array().concat() version of webpackJsonp #53

ryan-roemer opened this issue Oct 12, 2017 · 2 comments
Labels

Comments

@ryan-roemer
Copy link
Member

From @ryan-codingintrigue in FormidableLabs/webpack-dashboard#182 (comment)

@ryan-roemer I've been getting this error too since 1.0.0-7. I have a pretty big SPA, so it's been hard to get a repro of the issue, but I think I've narrowed it down to something to do with my bundle splitting.

My minimal example outputs a few bundles like this:

// bundle.0.js
webpackJsonp([0],[ ...
// bundle.1.js
webpackJsonp([1],{ ...
// etc.

However, my large SPA's bundles look like this:

// bundle.0.js
webpackJsonp([0],Array(171).concat([
// bundle.1.js
webpackJsonp([1],Array(171).concat([

I haven't been able to identify why, but it looks like this is causing the inspectpack parser/index.js#179 to be hit, making the parser assume throw that there "No code sections found"

The issue looks to be in getJsonpModules, where we've found a webpackJsonp, but expect second arg to be [] instead of Array(NUM).concat([]): https://github.com/FormidableLabs/inspectpack/blob/master/lib/parser/find-module-expression.js#L17-L22

@ryan-codingintrigue
Copy link

Given that the parameter index in webpackJsonp is still correct, would it be easier to add the check into extractModules? This seems to work for me:

if (t.isObjectExpression(node)) {
  // ...
}
if (t.isCallExpression(node) && node.arguments.length) {
  const potentialArrayNode = node.arguments[0];
  if (t.isArrayExpression(potentialArrayNode)) {
    return extractFromArrayExpression(potentialArrayNode, rawCode, opts);
  }
}

@ryan-roemer
Copy link
Member Author

@ryan-codingintrigue -- Cool! I'll wrap that into the branch I'm working on with regression tests...

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

No branches or pull requests

2 participants