I am facing an issue with a third-party library that needs to be included in my TypeScript project. The library is added to the application through a CDN path in the HTML file, and it exports a window variable that is used in the code.
Unfortunately, this package is not available as an npm module. When I try to run the webpack build, I encounter the following error message:
error TS2304: Cannot find name 'CUSTOM_WINDOW_VARIABLE'.
In an attempt to resolve this issue, I added the following code snippet in the webpackconfig.js file:
externals: {
CUSTOM_WINDOW_VARIABLE: "CUSTOM_WINDOW_VARIABLE",
},
Despite adding this configuration, I continue to receive the same error. Can anyone advise on how to instruct webpack to ignore these global variables during the build process or convert them from CUSTOM_WINDOW_VARIABLE
to window.CUSTOM_WINDOW_VARIABLE
?