Notes for Webpack users

Webpack is a popular module bundler, used to package JavaScript and Node.js applications. Webpack is designed primarily to take a group of large interdependent modules and bundle them into a smaller set of output artifacts, thus improving the performance of applications.

Webpack attempts to determine dependencies between modules, and removes module functions that it cannot find clear dependencies on. As a result, for a Node application that is using tCell agents, webpack often accidentally removes the tcell-agent dependency. It is therefore important to manage tcell-agent explicitly as an external dependency.

The webpack externals configuration option allows an application to tell webpack explicitly to load node dependencies as standard node external dependencies, rather than try to "inline" only the dependent functions. The accompanying example webpack.config.js webpack bundle has an existing external, express, and an added external tcell-agent. You should always use the externals format shown in the example.

Example: webpack.config.js file
1
const path = require('path');
2
3
module.exports = {
4
target: 'node',
5
entry: './src/start.ts',
6
module: {
7
rules: [
8
{
9
test: /\.tsx?$/,
10
use: 'ts-loader',
11
}
12
]
13
},
14
resolve: {
15
extensions: [ ".tsx", ".ts", ".js" ]
16
},
17
externals: {
18
"tcell-agent": "require('tcell-agent')",
19
"express": "require('express')"
20
},
21
output: {
22
filename: 'bundle.js',
23
path: path.resolve(__dirname, 'dist')
24
}
25
};

Troubleshooting

If the Node agent is not connecting to the tCell cloud and communicating events, do the following:

  1. Verify that in the output main server file there is an exported tcell-agent require. A simple way to verify is to use the standard grep tool. For example, if the output file is dist/bundle.js, then run:
    Using grep to verify a tcell-agent require
    1
    grep "tcell-agent" dist/bundle.js
    This should return a hit with require('tcell-agent') as an export.
  2. Check the webpack.config.js file to make sure target is 'node'.
  3. Some complex build and deployment systems have multiple webpack.config.js files. Check to make sure ALL webpack.config.js files for node application(s) have tcell-agent in the externals list.