Can't build with my Webpack/Babel bundled React app
See original GitHub issueMy React app fails to build whenever I import mssql. It’s important that I do this on the client side, since I won’t be running on an Node/Express server. It seems that executing in Webpack browser bundle requires additional configuration. Some kind of Polyfill maybe? I can’t find any help on this anywhere – I could really use some advice.
The build errors and warning are:
WARNING in ./~/mssql/lib/tds-fix.js
Module not found: Error: Cannot resolve module 'tds/package.json' in /Users/hills/upload-covers/node_modules/mssql/lib
@ ./~/mssql/lib/tds-fix.js 6:8-35
WARNING in ./~/mssql/lib/tds-fix.js
Module not found: Error: Cannot resolve module 'tds/lib/tds-constants.js' in /Users/hills/upload-covers/node_modules/mssql/lib
@ ./~/mssql/lib/tds-fix.js 13:4-39
WARNING in ./~/mssql/lib/tds-fix.js
Module not found: Error: Cannot resolve module 'tds' in /Users/hills/upload-covers/node_modules/mssql/lib
@ ./~/mssql/lib/tds-fix.js 14:4-18
ERROR in ./~/mssql/lib/msnodesql.js
Module not found: Error: Cannot resolve module 'msnodesql' in /Users/hills/upload-covers/node_modules/mssql/lib
@ ./~/mssql/lib/msnodesql.js 9:14-34
ERROR in ./~/mssql/lib/msnodesqlv8.js
Module not found: Error: Cannot resolve module 'msnodesqlv8' in /Users/hills/upload-covers/node_modules/mssql/lib
@ ./~/mssql/lib/msnodesqlv8.js 9:14-36
ERROR in ./~/mssql/lib/tds.js
Module not found: Error: Cannot resolve module 'tds' in /Users/hills/upload-covers/node_modules/mssql/lib
@ ./~/mssql/lib/tds.js 9:8-22
ERROR in ./~/tedious/lib/connection.js
Module not found: Error: Cannot resolve module 'net' in /Users/hills/upload-covers/node_modules/tedious/lib
@ ./~/tedious/lib/connection.js 25:13-27
ERROR in ./~/tedious/lib/instance-lookup.js
Module not found: Error: Cannot resolve module 'dgram' in /Users/hills/upload-covers/node_modules/tedious/lib
@ ./~/tedious/lib/instance-lookup.js 3:12-28
ERROR in ./~/tedious/lib/message-io.js
Module not found: Error: Cannot resolve module 'tls' in /Users/hills/upload-covers/node_modules/tedious/lib
@ ./~/tedious/lib/message-io.js 11:10-24
Here is my webpack config:
var path = require('path');
var webpack = require('webpack');
var HtmlWebpackPlugin = require('html-webpack-plugin');
module.exports = {
devtool: 'eval-source-map',
entry: [
'webpack-hot-middleware/client?reload=true',
path.join(__dirname, 'app/main.js')
],
output: {
path: path.join(__dirname, '/dist/'),
filename: '[name].js',
publicPath: '/'
},
plugins: [
new HtmlWebpackPlugin({
template: 'app/index.tpl.html',
inject: 'body',
filename: 'index.html'
}),
new webpack.optimize.OccurenceOrderPlugin(),
new webpack.HotModuleReplacementPlugin(),
new webpack.NoErrorsPlugin(),
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify('development')
})
],
module: {
loaders: [{
test: /\.js?$/,
exclude: /node_modules/,
loader: 'babel',
query: {
"presets": ["react", "es2015", "stage-0", "react-hmre"]
}
}, {
test: /\.json?$/,
loader: 'json'
}, {
test: /\.css$/,
loader: 'style!css?modules&localIdentName=[name]---[local]---[hash:base64:5]'
}]
}
};
Thanks.
Issue Analytics
- State:
- Created 7 years ago
- Comments:17
Top Results From Across the Web
How to set up & deploy your React app from scratch using ...
You are likely good with React and you want to learn how to use tools like webpack and Babel on your own. These...
Read more >Setup react with webpack and babel - Medium
Guide to setup react from scratch, without using create-react-app and by configuring webpack and ... Add the bundled js file to the HTML...
Read more >Setup Webpack And Babel for a React JS Application
I'm very excited to run our application and check if it is working properly. Run below command and it will open your application...
Read more >webpack not bundling with babel-loader and react
You're missing some presets: First do npm install: npm install babel-core babel-preset-es2015 babel-preset-react --save-dev. Also make a ...
Read more >Creating a React app with Webpack - JavaScript Ramblings
Tip: If npx serve public fails for you with Must use import to load ES Module error, check your Node version and make...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

I’m having trouble with figuring this out to work with webpack still. You mention to use
const sql = require('mssql/msnodesqlv8')instead ofconst sql = require('mssql')but I still get an error during bundling. Are we required to use this driver instead of Tedious?Implemented in v4 alpha. Drivers are no longer loaded dynamically so the library is now compatible with Webpack. To use
msnodesqlv8driver, useconst sql = require('mssql/msnodesqlv8')syntax.