I've been working on integrating webpack into my typescript application. To get a better understanding of webpack, I decided to do a minimal migration. I started by cloning the Angular2 quickstart seed and added a webpack.config.js:
'use strict';
let path = require('path');
module.exports = {
entry: './app/main.ts',
module: {
rules: [
{
test: /\.tsx?$/,
loader: 'awesome-typescript-loader',
exclude: /node_modules/,
},
]
},
output: {
filename: '/bundle.js',
path: path.resolve(__dirname, 'dist')
},
resolve: {
extensions: [".tsx", ".ts", ".js"]
},
};
I then attempted to build it:
PS C:\Users\ltheisen\git\pastdev-test-webpack> .\node_modules\.bin\webpack --display-error-details
Hash: 954fdea72e6d10e35648
Version: webpack 1.14.0
Time: 31ms
ERROR in Entry module not found: Error: Cannot resolve 'file' or 'directory' ./app/main.ts in C:\Users\ltheisen\git\pastdev-test-webpack
resolve file
C:\Users\ltheisen\git\pastdev-test-webpack\app\main.ts.tsx doesn't exist
C:\Users\ltheisen\git\pastdev-test-webpack\app\main.ts.ts doesn't exist
C:\Users\ltheisen\git\pastdev-test-webpack\app\main.ts.js doesn't exist
resolve directory
C:\Users\ltheisen\git\pastdev-test-webpack\app\main.ts\package.json doesn't exist (directory description file)
C:\Users\ltheisen\git\pastdev-test-webpack\app\main.ts is not a directory (directory default file)
Looking at the --display-error-details
output, it seems that even though webpack checks for files with all three extensions listed in resolve.extensions
, it doesn't check for the file itself. Most examples I've come across use the file extension for the entry
(webpack basic setup, typescript integrating with build tools, ...). When I removed the extension, webpack was able to find the entry
file (though I encountered other issues...).
So, my question is: am I missing something obvious here? Is there something wrong with what I'm doing, or could it be an issue with the documentation?
---- UPDATE ---- It seems like there might be an issue with the npmjs repository. The webpack 2 documentation for installation states:
npm install webpack --save-dev
However, npmjs is showing version 1.14.0 as the current version:
https://i.sstatic.net/C1szA.png
This is surprising since version 2.2.0 was released recently... Perhaps the update hasn't propagated to npmjs yet? After updating to webpack 2, the issue seemed to have been resolved...