Monday, 9 July 2018

Webpack UglifyJS fall in error for production build because of MQTT.js existance

I have a react web app with server side rendering and I separate webpack configuration for development and production environment.

For each environment, I set two side configurations, first client and second server. these configs are so complete and work awesome, but

I need to have mqtt.js in this project, this library has #!/usr/bin/env node in first of its code sheet and using this library cause to running dev and build script fall in this error:

ERROR in ./node_modules/mqtt/mqtt.js
Module parse failed: Unexpected character '#' (1:0)
You may need an appropriate loader to handle this file type.
| #!/usr/bin/env node
| 'use strict'
| 
 @ ./src/app/App.jsx 23:12-27
 @ ./src/server.jsx

So I use shebang-loader to settle this issue and put in along side babel-loader in webpack configs and exclude the node_modules folder except mqtt folder, So this issue settled in development environment.

Then I run the build script and see this error:

ERROR in server.js from UglifyJs
Unexpected token: name (zlibLimiter) [server.js:1181,4]

I really need to use mqtt.js so I can not omit this or change it with any library like it.

If for analyzing need to see all configs or codes, This is the application Repository



from Webpack UglifyJS fall in error for production build because of MQTT.js existance

No comments:

Post a Comment