Webpack: Webpack produces invalid JS code

Created on 14 Mar 2018  路  7Comments  路  Source: webpack/webpack

Using your latest version, turns out webpack is producing broken JS code
https://gist.githubusercontent.com/binarykitchen/a1899291fc3b470ba83cb9a245317775/raw/60de0910ca0a6bef87d96a202de8faa0ffb785ce/gistfile1.txt

Chrome complains with

index.coffee:2 Uncaught SyntaxError: missing ) after argument list
    at Object../lib/jquery/index.coffee (lib.js:851)
    at __webpack_require__ (lib.js:710)
    at fn (lib.js:95)
    at eval (multi_jquery_goog_ext:1)
    at Object.1 (lib.js:1060)
    at __webpack_require__ (lib.js:710)
    at lib.js:762
    at lib.js:765

Tried to find this out by eliminating each option one after one but no luck. Any clues what this could be? I have this error three times for all my three entry points in development mode.

Most helpful comment

fixed by #6691

All 7 comments

here another shorter invalid example webpack produces:

eval(
  'var portal;\n\nportal = __webpack_require____webpack_require__(/*! portal */ "./src/modules/portal.es"/*! portal */ "./src/modules/portal.es");\n\nportal.init();'
)

Hi, could you please give a small repo to reproduce it ?

It looks like you just deleted our lovely crafted issue template. It was there for good reasons. Please help us solving your issue by answering the questions asked in this template.

it's a very large app - it's obvious that webpack generates duplicate code

eval(
  'var portal;\n\nportal = __webpack_require____webpack_require__(/*! portal */ "./src/modules/portal.es"/*! portal */ "./src/modules/portal.es");\n\nportal.init();'
)

why twice webpack require? __webpack_require____webpack_require__

hmm, looks like it doesn't happen when i dont provide a callback to the webpack() constructor. weird.

i confirm, when you use webpack dev middleware, and use a callback in the webpack() constructor, then it outputs duplicate code.

the callback was used for running code after compilation. now i am listening to hooks instead and that fixed it.

i think webpack should have detected this and printed an error. that would save lots of developers time finding out what the heck is going on.

fixed by #6691

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jaesung2061 picture jaesung2061  路  3Comments

andersekdahl picture andersekdahl  路  3Comments

adjavaherian picture adjavaherian  路  3Comments

zerkalica picture zerkalica  路  3Comments

olalonde picture olalonde  路  3Comments