ghiscoding/aurelia-slickgrid

HOWTO Step by Step with Webpack missing critical step

Closed this issue · 2 comments

Following the Step-by-Step to the letter in the Wiki with a vanilla Typescript/Webpack/Aurelia-CLI project will result in a jQuery is not defined error when adding the following to main.ts.
aurelia.use.plugin(PLATFORM.moduleName('aurelia-slickgrid'));
The Wiki is missing a step where ProvidePlugin needs to be added to incorporate jquery. The following line needs to be added in the webpack.config.js file when importing dependencies.
const { ProvidePlugin } = require('webpack');
And the ProvidePlugin needs to be added to the plugins section of the webpack.config.js.

    new ProvidePlugin({
      '$': 'jquery',
      'jQuery': 'jquery',
      'window.jQuery': 'jquery',
      'window.$': 'jquery'
    })

That is fair enough, it's in my demo but not in the wiki, however don't you also need jQuery as an alias and also expose jQuery with a loader? I always thought it was required but haven't tried removing them

alias: {
      'aurelia-binding': path.resolve(__dirname, 'node_modules/aurelia-binding'),
      'jquery': path.join(__dirname, 'node_modules/jquery/dist/jquery'),
      moment$: 'moment/moment.js'
},

module: {
  rules: {
      // exposes jQuery globally as $ and as jQuery:
      { test: require.resolve('jquery'), loader: 'expose-loader?$!expose-loader?jQuery' },
  }
}

... seems to work without these lines, not sure what that brings. I remember finding that long time ago on Stack Overflow to use jQuery with WebPack without understanding all of it. I've modified the Wiki as per your suggestion here, let me know if that's ok so we can close this issue. Thanks for the feedback

Thanks for addressing. I don't think it's a big deal as the CLI project with navigation adds these lines to webpack.config.js and doesn't if the bare bones option is chosen. I added aurelia-slickgrid to an older project and it's not working completely but there are no issues with a newly created project. Haven't been able to figure out what the issue is yet with my older project. Versions of all packages appear to be the same.