import JUST typescript definitions in lazy files for LSP

I am bundling one main_bundle.js file for my web app. And also bundling many smaller lazy files that are separate from main_bundle. Most every view or component in my app is a lazy file that is dynamically imported only as needed. main_bundle contains utility functions (originally as separate ts files that are bundled all up at build time). These utility functions expose functions to a scoped namespace on window. These functions need to be available to every view on the app.

It’s no problem accessing the functions on each lazy view, since it is available in the scoped window namespace. But, I also need to have LSP support in my editor.

I can do this:

import { UtilityFunction, UtilityFunctionReturnType, etc, etc } from "../../utilfunction.js"

That works great for my LSP. But, when compiling and bundling with esbuild, that whole body of js is sucked in to my lazy file … which is very bad.

Is there a way, in esbuild, tsconfig, SWC or any other method, of only pulling in declarations for my LSP and disabling bundling on build?

I can hack it in my build script by removing the import lines, but if there is a more standard way of doing this Id rather go with that, as I want as least custom build tooling as I can get away with.