I am trying to figure out how can I debug a script, in VS Code, that executes in the browser, but its source is Typescript.
I provide my full setup so far here - package.json:
"scripts": {
"app:debug": "tsup --watch --config tsup.debug.config.ts"
},
"devDependencies": {
"tsup": "^8.5.0",
"typescript": "^5.8.3"
}
app.ts:
const message: string = "Hello, TypeScript!";
console.log(message);
tsup.debug.config.ts:
import { defineConfig } from 'tsup';
export default defineConfig({
format: ['iife'],
dts: false,
sourcemap: true,
minify: false,
bundle: true,
clean: false,
entry: { ['app']: 'src/app.ts' },
outDir: 'public'
});
Running it:
npm run app:debug
Serving .js file:
npx serve -p3001 public/
/mysite/index.html page that uses the script:
<!DOCTYPE html>
<html>
<head>
<!--app.ts.global.js is the default output file. app.ts.global.js.map is the default output map file.-->
<script src='http://localhost:3001/app.ts.global.js'></script>
</head>
<body>
</body>
</html>
Serving the page:
npx serve -p 3000 /mysite/
I want to be able to add a breakpoint to app.ts and when I access http://localhost:3000, VS Code to break at that breakpoint.
Is this possible?

