code splitting broken on Windows
See original GitHub issueWhat happens and why it is wrong
Briefly: Code splitting is not supported now
Versions
- typescript: 3.5.3
- rollup: 1.20.3
- rollup-plugin-typescript2: 0.24.0
rollup.config.js
import resolve from 'rollup-plugin-node-resolve';
import ts2 from 'rollup-plugin-typescript2';
export default {
// NOTE: object here
input: {
'my-lib': 'src/main.ts',
'my-tools': 'src/tools.ts'
},
output: {
dir: 'dist',
format: 'esm'
},
plugins: [
resolve(),
ts2()
]
};
tsconfig.json
{
"compilerOptions": {
"target": "esnext",
"module": "esnext",
"strict": true,
"sourceMap": true,
"importHelpers": true,
"downlevelIteration": true,
"moduleResolution": "node",
"experimentalDecorators": true,
"allowSyntheticDefaultImports": true,
"esModuleInterop": true,
"lib": ["esnext"],
"types": ["node"]
},
"include": ["src/**/*.ts"],
"exclude": ["node_modules"]
}
files
src/tools.ts
export function myFn() {
console.log('Hello World!');
}
src/main.ts
import { myFn } from './tools';
console.log(myFn());
plugin output
dist/my-tools.js OK
function myFn() {
console.log('Hello World!');
}
export { myFn };
dist/my-lib.js WRONG
function myFn() {
console.log('Hello World!');
}
console.log(myFn());
expected output
dist/my-lib.js
import { myFn } from './my-tools.js';
console.log(myFn());
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Webpack code splitting not working as intended #397 - GitHub
Webpack code splitting not working as intended #397 ... I checked the source code, and the plugin is properly exporting different modules.
Read more >Browser extension is not working with code-splitting
However clicking the browser action icon do nothing. No error messages will show up in background script. No login window or popup will...
Read more >Code Splitting - webpack
Code splitting is one of the most compelling features of webpack. This feature allows you to split your code into various bundles which...
Read more >Tree shaking and code splitting in webpack - LogRocket Blog
Here, we'll explain tree shaking and code splitting in webpack and discuss how to combine them for the most optimal bundle possible.
Read more >How to fix ChunkLoadError in your ReactJS application
If you use code splitting and dynamic imports, old code can cause this issue. Here's how to fix it in React.lazy() with a...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I see the problem, rollup doesn’t normalize paths when using them as keys for code splitting. Workaround is to add
rollupCommonJSResolveHack: true
to rpt2 options (solves a similar problem with another plugin, they fixed it in recent release actually).I’ll open rollup bug.
@igisev can you use
rollupCommonJSResolveHack: true
as a workaround?