Shimming window[“jQuery”]

This configuration does not replace window[“jQuery”] with require(“jquery”) in knockout (v. 3.3.0) module.
What should I do to avoid exposing jQuery in window and provide knockout with jQuery?

new webpack.ProvidePlugin({
      'window.jQuery': 'jquery',
      'jQuery': 'jquery',
      'window["jQuery"]': 'jquery'
    })

Author: Fantashit

1 thought on “Shimming window[“jQuery”]

  1. @blazkovicz, if you are still interested on this, I solved this issue on my own by using a custom loader (maybe adding a generic text replacement loader would be a better solution):

    ko-loader.js:

    module.exports = function(source) {
      this.cacheable();
      return source.replace('jQueryInstance = window["jQuery"]', 'jQueryInstance = require("jquery")');
    };

    in webpack.config.js:

        ,resolveLoader: {
          alias: { 'ko-loader': __dirname + '/ko-loader' }
        }
        ,module: {
            loaders: [
              { test: /knockout-latest\.debug\.js$/, loader: 'ko-loader'}
            ]
        }

    I hope that helps.

Comments are closed.