After reading an article about bundling ES2015 modules with TypeScript and Rollup, I decided to try it out myself.
In the example provided, there is a file named math.ts
export function square(x: number) {
return x ** 2;
}
export function cube(x: number) {
return x ** 3;
}
and another file named main.ts
import { square } from "./math";
console.log(square(3));
Following the command:
tsc -t ES5 -m es2015 && rollup -f es -o app.js -m -i main.js
A new file app.js is generated
function square(x) {
return Math.pow(x, 2);
}
console.log(square(3));
//# sourceMappingURL=app.js.map
The issue arises when the source map in .js
output file points to the compiled JavaScript files instead of the original TypeScript files. How can I fix this?