I'm trying to use webpack to compile (typescript files) and bundle up my source code. Here is my current webpack.config.js file:
const path = require('path')
module.exports = {
devtool: 'eval-source-map',
entry: './src/main.ts',
module: {
rules: [
{
test: /\.ts$/,
use: 'ts-loader',
include: [
path.resolve(__dirname, 'src'),
]
}
]
},
resolve: {
extensions: ['.ts', '.js']
},
output: {
filename: 'bundle.js',
path: path.resolve(__dirname, 'dist')
}
}
I also have big.js installed as a node module. However, when I run webpack and bundle all the files into bundle.js. It runs the bundled code (known by console.log messages printing to console), but I get the following error in the browser:
Uncaught Error: Cannot find module 'big.js'
and it points to the following line of code:
import Big from "big.js";
I know big.js is included because looking in the bundle.js file, the top of the file has the big.js bundled (shown as below):
(()=>{var __webpack_modules__={302:function(module,exports,__webpack_require__){eval("var __WEBPACK_AMD_DEFINE_RESULT__;/*\r\n * big.js v6.1.1\r\n * A small, fast, easy-to-use library for arbitrary-precision decimal arithmetic.\r\n * Copyright (c) 2021 Michael Mclaughlin\r\n * https://github.com/MikeMcl/big.js/LICENCE.md\r\n */\r\n;(function (GLOBAL) {\r\n 'use strict';\r\n var Big,\r\n\r\n\r\n/...
This is my first time using webpack and big.js so the solution is hopefully simple, but if someone knew what the issue was, your help would be appreciated. If any further information is needed, let me know.