ag-grid / ag-grid-aurelia

Aurelia wrapper for ag-Grid project
MIT License
23 stars 8 forks source link

Can't load aurelia.use.plugin('ag-grid-aurelia') with new aurelia-webpack-plugin #10

Closed nashwaan closed 7 years ago

nashwaan commented 7 years ago

I'm submitting a ... (check one with "x")

[x] bug report => search github for a similar issue or PR before submitting
[ ] feature request
[ ] support request => Please do not submit support request here

Current behavior Using aurelia.use.plugin('ag-grid-aurelia'); in export function configure(aurelia) {} will not work with the new aurelia-webpack-plugin v2 (currently 2.0.0-rc.1).

Expected behavior Be able to load ag-grid-aurelia plugin without issues under aurelia-webpack-plugin v2.

Minimal reproduction of the problem with instructions Please download minimal Aurelia + Webpack setup from here. Then do the following simple steps. npm install --save ag-grid ag-grid-aurelia

src/main.js:

import {PLATFORM} from 'aurelia-framework';
export function configure(aurelia) {
  aurelia.use
     .standardConfiguration()
     .plugin('ag-grid-aurelia') // <--- added this line
     .developmentLogging();
  aurelia.start().then(() => aurelia.setRoot(PLATFORM.moduleName('app')));
}

To fix this error, I wrap it in PLATFORM.moduleName(). See more info about PLATFORM.moduleName() as described by @jods4.

import {PLATFORM} from 'aurelia-framework';
export function configure(aurelia) {
  aurelia.use
     .standardConfiguration()
     .plugin(PLATFORM.moduleName('ag-grid-aurelia')) // <--- wrapping in PLATFORM.moduleName()
     .developmentLogging();
  aurelia.start().then(() => aurelia.setRoot(PLATFORM.moduleName('app')));
}

However, the browser gives this error: Uncaught (in promise) Error: Unable to find module with ID: ag-grid-aurelia/lib/agGridAurelia

I think internally, ag-grid-library is trying to load ag-grid-aurelia module. If this is the case, then this as well need to be wrapped by PLATFORM.moduleName()

What is the motivation / use case for changing the behavior? As aurelia-webpack-plugin is upgrading to v2 (currently 2.0.0-rc.1), ag-grid-aurelia will fail to load on webpack setups.

Please tell us about your environment: Windows, VS Code, Webpack, Webpack Dev Server

swalters commented 7 years ago

@seanlandsman I'll try to look at this today

swalters commented 7 years ago

I've recreate a webpack loader issue here https://github.com/swalters/agGridAureliaWebpack and am waiting for feedback from Aurelia team

https://github.com/aurelia/webpack-plugin/issues/96

nashwaan commented 7 years ago

A temporary solution is to add following lines in webpack.config.js

const AureliaWebpackPlugin = require('aurelia-webpack-plugin');
...
.plugins = [
...
    new AureliaWebpackPlugin.ModuleDependenciesPlugin({
        'ag-grid-aurelia': [
          './lib/agGridAurelia',
          './lib/agGridColumn',
          './lib/agTemplate'
        ]
    }),
seanlandsman commented 7 years ago

As the issue over at aurelia/webpack-plugin has been fixed I assume that this has been fixed too

If this is still an issue please open a new issue and I'll investigate

thanks