I'm trying to bundle and run a TypeScript project using Webpack. One of the TypeScript files requires and external node depenedency. Webpack bundles the file without problem, but when I try to run it on the browser it gives me the following error.
webpack.config.js
const path = require('path');
const nodeExternals = require('webpack-node-externals');
module.exports = {
entry: './src/index.ts',
resolve: {
extensions: [
'.js',
'.jsx',
'.json',
'.ts',
'.tsx'
]
},
externals: [nodeExternals()],
output: {
libraryTarget: 'commonjs',
path: path.join(__dirname, '.webpack'),
filename: '[name].js',
},
target: 'web',
module: {
loaders: [
{ test: /\.ts(x?)$/, loader: 'ts-loader' },
],
},
};
External node dependency aws-iot-device-sdk
Can someone help me with this?
Update: Found that the following line in the TypeScript file causes the issue. is there a work-around for this?
const client = new IoTClient(true, IoTClientOptions);

libraryTarget: "umd"?./src/index.ts?index.ts, I have no idea what IoTClient and IoTClientOptions are.