How to use ng-table with webpack?

I am trying to use ng-table in my anuglarjs application. I did not understand that the version for npm is higher , and the new version does not exist yet, however my application is at the attack stage and I cannot use the gazebo.

I tried to download the latest version from git npm install git+ssh://git@github.com/esvit/ng-table.git --save

and then load it into the input file:

import angular from 'angular';
import ngTable from 'ng-table';

angular.module('app', [ngTable]);

Unfortunately, the web package contains many errors:

ERROR in ./src/app.js
Module not found: Error: Cannot resolve module 'angular'(...)

I also tried using import-loader:

const ngTable = require('imports?define=>false,angular!ng-table');

but failed. Can someone point me in the right direction? I really would not want to rewrite all the little things because of one library.

+4
source share
2 answers

ng-table :

// app.js
import angular from 'angular';
import ngTable from 'ng-table/dist/ng-table';

angular.module('app', [ngTable]);

, , commonjs

https://github.com/esvit/ng-table/issues/764#issuecomment-184357333

+1

. . "" .

webpack.config.js

config.resolve = {
  extensions: ['', '.js'],
  alias: {
    'ng-table': 'ng-table/dist/ng-table'
  },
  modulesDirectories: [ 'node_modules', 'bower_components' ],
};

config.module = {
  loaders: [{
    test: require.resolve('ng-table'),
    loader: 'imports-loader?define=>false,$=jquery,angular'
   }]
}

app.js

angular.module('app', ['ngTable']);

define=>false , , github. angular ng-table .

+1

Source: https://habr.com/ru/post/1628879/


All Articles