I am trying to use in my project a very new third-party module that I installed using npm . The module, obviously, was developed on an OS with a case-insensitive file system, so this requires the injectable.js file, whereas the actual file name is injectable.js . This disrupts the binding process.
Module developers are aware of this problem. Meanwhile, I'm trying to figure out how to use the module as is. I use Webpack to integrate my project.
The tree structure of the corresponding part of my project is something like this:
βββconfig β βββwebpack β βββwebpack.js β βββsrc β βββclient β βββindex.js β β βββnode_modules β βββthe module in question β βββ dist β β βββ decorators β β β βββ providers β β β βββ Injectable.js β β β β β βββ index.js | βββgulpfile.js
The index.js file in the node_modules/the module in question/dist folder requires the injectable.js file from the providers folder, but does this with the require('./decorators/providers/injectable');
I would like to add the alias ./decorators/providers/injectable to << 24> using ./decorators/providers/injectable .
Here is what I do in the webpack.js file:
resolve: { alias: { './decorators/providers/injectable': './decorators/providers/Injectable.js', }, }
But this still does not work; I get the error Module not found: Error: Cannot resolve 'file' or 'directory' ./decorators/providers/injectable
Could you suggest how to replace one file name in a node module with another when linking to Webpack?
UPDATE:
Here is the webpack configuration file:
var path = require('path'); var rucksack = require('rucksack-css')({ fallbacks: true, autoprefixer: true }); var precss = require('precss'); var csswring = require('csswring'); var webpack = require('webpack'); module.exports = { context: path.join(__dirname, '../../'), debug: false, entry: [ './src/client/' ], output: { path: path.join(__dirname, '../../public/assets/js'), filename: 'bundle.js' }, module: { loaders: [ { test: /\.js$/, exclude: /node_modules/, loader: 'babel?stage=1' }, { test: /\.css$/, loader: 'style-loader!css-loader!postcss-loader' }, {test: /\.png$/, loader: 'file-loader'}, {test: /\.gif$/, loader: 'file-loader'}, {test: /\.jpe?g$/, loader: 'file-loader'}, {test: /\.eot$/, loader: 'file-loader'}, {test: /\.woff2?$/, loader: 'file-loader'}, {test: /\.ttf$/, loader: 'file-loader'}, {test: /\.svg$/, loader: 'file-loader'} ] }, postcss: function () { return [rucksack, precss, csswring]; }, plugins: [ new webpack.NormalModuleReplacementPlugin( /ng-forward\/dist\/decorators\/providers\/injectable\.js/, require.resolve('ng-forward/dist/decorators/providers/Injectable') ) ], resolve: { extensions: ['', '.js'] } };