schovi / webpack-chrome-extension

Moved and redesigned into https://github.com/schovi/create-chrome-extension
MIT License
167 stars 27 forks source link

Uncaught ReferenceError: webpackJsonp is not defined #21

Open quorak opened 8 years ago

quorak commented 8 years ago

Hey there,

great repo. helped me a lot to bootstrap my application. I run into one scenario, you might have an Idea. I want to load a module delayed, depending on the interaction of the customer. I use require.ensure("modulename") to do this. It works, there is a dedicated 0.0.js file created which will only be loaded when the customers clicks a button.

It works very well in the newtab.js but in the content.js which is injected in every page that the customer opens, i get a Uncaught ReferenceError: webpackJsonp is not defined (in the development env).

Do you know if the content.js is executed in a different namespace or something similar? Would be a great feature to get this working.

thanks again

j-walker23 commented 8 years ago

Awesome repo. Thank you!

@quorak ever figure this one out?

psimyn commented 8 years ago

I think this will work if you add a third argument to require.ensure

Here is an example using content/index.js

document.addEventListener('click', () => {
  require.ensure([], () => {
    var welcome = require('shared/welcome').default
    welcome('content/index.js')
  }, 'content/index')
})