carlsednaoui / ouibounce

Increase your landing page conversion rates.
MIT License
2.31k stars 372 forks source link

Warnings logged when used with webpack #118

Closed lencioni closed 8 years ago

lencioni commented 8 years ago

Hi! I am using this package in a project that is built with webpack, and I am seeing the following warnings logged in my console:

./~/ouibounce/build/ouibounce.js
Critical dependencies:
10:29-36 require function is used in a way in which dependencies cannot be statically extracted
 @ ./~/ouibounce/build/ouibounce.js 10:29-36
./~/ouibounce/build/ouibounce.min.js
Critical dependencies:
4:105-112 require function is used in a way in which dependencies cannot be statically extracted
 @ ./~/ouibounce/build/ouibounce.min.js 4:105-112

Is there something special I need to do to use this with webpack?

lencioni commented 8 years ago

It looks like this is happening because of the UMD build (via gulp-wrap-umd). There's an issue on that project that pointed me to a webpack plugin that helps webpack understand UMD.

lencioni commented 8 years ago

That plugin did not seem to help in my situation. However, it turns out that we had some configuration that disables AMD stuff:

{
  test: /./,
  loader: 'imports?define=>false',
},

If I remove this, I can get the warnings to go away.

lencioni commented 8 years ago

Just to totally close the loop on this, I ended up changing my above configuration to

{
  test: /./,
  exclude: [
    require.resolve('ouibounce'),
  ],
  loader: 'imports?define=>false',
},