Parcel doesn't generate chunks for dynamic imports when using typescript.
Here's an example:
No custom config
Chunks should be generated
only one bundle is generated
Typescript, by default, bundles all imports into a single file. Add a tsconfig.json similar to this one to the project:
{
"compilerOptions": {
"target": "esnext",
"sourceMap": true,
"module": "es6"
}
}
Thanks @KeineLimonade, using these settings actually works!
But when I try to use that tsconfig, I am getting the following errors in the IDE:
[ts] Dynamic import is only supported when '--module' flag is 'commonjs' or 'esNext'.
This is extremely confusing :)
ok. got it working with:
{
"compilerOptions": {
"target": "es2018",
"sourceMap": true,
"module": "esnext",
"jsx": "preserve",
"lib": ["esnext"]
}
}
我的这个问题还是存在
我已经按照上面的方法加过了 但是还是存在
if this is a fix it should be the parcel.js default. However, for me this is not fixing anything.
The tsconfig is not fixing anything either. I am having the same issue in a typescript project with react router as well.
Most helpful comment
ok. got it working with: