Search code examples
javascriptnode.jsnpmbrowserifywebpack

Webpack equivalent for browserify shiming(global) of already included modules


I am wondering what the webpack equivalent of browserify shiming is?

I develop a widget using npm and webpack which is included in another app. This other app already includes moment.js already in a script tag.

I don't want to bundle moment.js again in the widget bundle but still be able to use it. (import moment from 'moment').

In browserify this was done with a global:moment statement. Does someone know the webpack equivalent?


Solution

  • I figured it out. I put the following in my webpack.config.js:

    externals: {
      'moment': 'moment',
    },