I have a problem with lazy loading and webpack.
There is a video of Sean Larkin showing how easy it is with webpack 4 to create a lazy loaded bundle (Here). But when I try to do it with typescript I run into some problems.
index.ts
export const someThing = something => import("./lazy/lazy");
and
lazy/lazy.ts
export default "I am lazy";
when I run it without any webpack configuration and name the files to ".js" I get a main chunk and a small chunk for the lazy loaded module.
But when I run it as ".ts" files with a simple webpack configuration I get just the "main.js" file and no extra chunk.
webpack.config.js
let config = {
resolve: {
extensions: [".ts", ".js"]
},
module: {
rules: [
{ test: /\.ts$/, use: ["ts-loader"], exclude: /node_modules/ },
]
},
}
module.exports = config;
and
tsconfig.json
{
"compilerOptions": {
"module": "commonjs",
"target": "es5",
"noImplicitAny": false,
"sourceMap": true,
"lib": [ "es6", "dom" ],
"removeComments": true
}
}
Is there something to configure I am mission? What exactly is the difference between the import of a "js" file to a "ts" file?