Issue 1:
Hello!

We're developing a universal tool, which could be used to compile multiple similar packages using Webpack. Therefore all build dependencies and Webpack configuration is present only in the tool package itself and not in the final packages.

With such approach we can only add a single dependency for our tool in the final package and use the tool to compile it. If we need to re-configure the compilation, we could do it in a single place, this is very convenient for us because we have hundred of such packages and we don't want to duplicate the build configuration for each of them.

This works pretty fine with npm, because npm puts all dependencies including transitive ones in the node_modules directory of the package in question (so called "flat" node modules). So, if we install our tool, which itself depends on, say babel-loader, both dependencies will be added to the node_modules directory of the final package and Webpack will be able to find it when it gets executed.

However, when we switched to Rush and pnpm, we stumbled upon a problem. These tools behave more clever that npm. They install dependencies using an intricate system of symlinks and they make sure to only add dependencies which are directly requested by the package in question. This helps to solve problems with phantom dependencies and NPM doppelgangers, which is a really good thing.

But, such approach doesn't work in our case, because Webpack is trying to resolve module loaders like babel-loader not from the tool directory (where they are actually installed), but from the build directory (directory of the final package). I've tried to debug the module resolution, but it looks like Webpack is not using the default Node.js one.

We've got similar situation with Rollup, but we've just managed to load required modules ourselves and pass the instances to the Rollup. But it looks like Webpack insists on resolving loaders on it's own. Please correct me if I'm wrong.

So the question is:

1). Is there a way to tell Webpack where to search for loader packages?

2). Is there a way to require loader ourselves and pass the instance to the Webpack directly (prevent Webpack from loading the loaders on it's own).

Could you share your thoughts on this problem? Any feedback will be highly appreciated. Thank you.

Issue 2:
Do you want to request a feature or report a bug?

Bug report

What is the current behavior?

The following import statement:

import { NgTableParams } from 'ng-table';

produces the following error logged to the console:

Cannot redefine property: NgTableParams

If the current behavior is a bug, please provide the steps to reproduce.

Run the demo-app in ng-table where the above import is attempted:

git clone -b webpack-problem https://github.com/esvit/ng-table.git

npm i

npm run setup:ci

cd demo-apps/es6-webpack

npm start

The last command will use webpack-dev-server to launch the demo-app in your default browser.

In chrome this produces the error logged to the console.

What is the expected behavior?

The import of NgTableParams should work

Please mention other relevant information such as the browser version, Node.js version, Operating System and programming language.

Possible related to: #2953

Environment details

Chrome: 54.0.2840.99

OS: Windows 10

Node: 6.2.2

npm: 3.10.9

webpack: 2.1.0-beta.27

typescript@2.0.3 used to compile the library

babel used to compile the demo-app that is failing