Automattic / Automattic/kue

Can't resolve dependencies when bundling with webpack

Open
#1,191 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
9.4k
Forks
858
PR merge metrics
No merged PRs in 30d

Description

Hi!

Im having troubles when compiling with webpack. The following is the webpack config:

```javascript
const path = require('path');

module.exports = {
mode: 'development',
entry: ['./src/app.js'],
output: {
path: path.resolve(__dirname, 'dist'),
filename: 'driver.js'
},
module: {
rules: [
{
test: /\.jsx?$/,
loader: 'babel-loader',
options: {
presets: ['env']
}
},
{
test: /\.node$/,
loader: 'node-loader'
}
]
},
resolve: {
modules: [
path.resolve(__dirname, 'node_modules')
],
extensions: ['.js', '.jsx']
},
devtool: 'source-map',
context: __dirname,
target: 'node',
externals: []
};
```

An the following is the webpack output:

```
[BABEL] Note: The code generator has deoptimised the styling of "/Users/throoze/dev/com.chattigo.driver.generic/node_modules/lodash/lodash.js" as it exceeds the max of "500KB".
Hash: 50ba02433ba0abe6ce2f
Version: webpack 4.12.0
Time: 25265ms
Built at: 06/20/2018 6:07:48 PM
Asset Size Chunks Chunk Names
driver.js 4.08 MiB main [emitted] main
driver.js.map 6.29 MiB main [emitted] main
[./src/Adapters/Inbound/TwilioSMS/index.js] 2.76 KiB {main} [built]
[./src/Adapters/Outbound/OutboundAdapter.js] 1.74 KiB {main} [built]
[./src/Adapters/Outbound/index.js] 784 bytes {main} [built]
[./src/Adapters/index.js] 381 bytes {main} [built]
[./src/Enqueuer/index.js] 1.44 KiB {main} [built]
[./src/Resolver/index.js] 1.48 KiB {main} [built]
[0] multi ./src/app.js 28 bytes {main} [built]
[./src/app.js] 1.98 KiB {main} [built]
[events] external "events" 42 bytes {main} [built]
[net] external "net" 42 bytes {main} [built]
[os] external "os" 42 bytes {main} [built]
[path] external "path" 42 bytes {main} [built]
[querystring] external "querystring" 42 bytes {main} [built]
[util] external "util" 42 bytes {main} [built]
[zlib] external "zlib" 42 bytes {main} [built]
+ 841 hidden modules

WARNING in ./node_modules/source-map/lib/source-map/source-node.js 10:43-50
Critical dependency: require function is used in a way in which dependencies cannot be statically extracted
@ ./node_modules/source-map/lib/source-map.js
@ ./node_modules/stylus/lib/visitor/sourcemapper.js
@ ./node_modules/stylus/lib/renderer.js
@ ./node_modules/stylus/lib/stylus.js
@ ./node_modules/stylus/index.js
@ ./node_modules/kue/lib/http/index.js
@ ./node_modules/kue/lib/kue.js
@ ./node_modules/kue/index.js
@ ./src/app.js
@ multi ./src/app.js

WARNING in ./node_modules/source-map/lib/source-map/source-map-generator.js 10:43-50
Critical dependency: require function is used in a way in which dependencies cannot be statically extracted
@ ./node_modules/source-map/lib/source-map.js
@ ./node_modules/stylus/lib/visitor/sourcemapper.js
@ ./node_modules/stylus/lib/renderer.js
@ ./node_modules/stylus/lib/stylus.js
@ ./node_modules/stylus/index.js
@ ./node_modules/kue/lib/http/index.js
@ ./node_modules/kue/lib/kue.js
@ ./node_modules/kue/index.js
@ ./src/app.js
@ multi ./src/app.js

WARNING in ./node_modules/source-map/lib/source-map/source-map-consumer.js 10:43-50
Critical dependency: require function is used in a way in which dependencies cannot be statically extracted
@ ./node_modules/source-map/lib/source-map.js
@ ./node_modules/stylus/lib/visitor/sourcemapper.js
@ ./node_modules/stylus/lib/renderer.js
@ ./node_modules/stylus/lib/stylus.js
@ ./node_modules/stylus/index.js
@ ./node_modules/kue/lib/http/index.js
@ ./node_modules/kue/lib/kue.js
@ ./node_modules/kue/index.js
@ ./src/app.js
@ multi ./src/app.js

WARNING in ./node_modules/pug-filters/lib/run-filter.js 14:11-105
Critical dependency: the request of a dependency is an expression
@ ./node_modules/pug-filters/index.js
@ ./node_modules/pug/lib/index.js
@ ./node_modules/kue/lib/http/index.js
@ ./node_modules/kue/lib/kue.js
@ ./node_modules/kue/index.js
@ ./src/app.js
@ multi ./src/app.js

WARNING in ./node_modules/nib/lib/nib.js 36:18-66
Critical dependency: the request of a dependency is an expression
@ ./node_modules/kue/lib/http/index.js
@ ./node_modules/kue/lib/kue.js
@ ./node_modules/kue/index.js
@ ./src/app.js
@ multi ./src/app.js

WARNING in ./node_modules/stylus/lib/utils.js 136:15-48
Critical dependency: the request of a dependency is an expression
@ ./node_modules/stylus/lib/stylus.js
@ ./node_modules/stylus/index.js
@ ./node_modules/kue/lib/http/index.js
@ ./node_modules/kue/lib/kue.js
@ ./node_modules/kue/index.js
@ ./src/app.js
@ multi ./src/app.js

WARNING in ./node_modules/stylus/lib/functions/use.js 31:11-39
Critical dependency: the request of a dependency is an expression
@ ./node_modules/stylus/lib/functions/index.js
@ ./node_modules/stylus/lib/stylus.js
@ ./node_modules/stylus/index.js
@ ./node_modules/kue/lib/http/index.js
@ ./node_modules/kue/lib/kue.js
@ ./node_modules/kue/index.js
@ ./src/app.js
@ multi ./src/app.js

WARNING in ./node_modules/uglify-js/tools/node.js 13:11-32
Critical dependency: the request of a dependency is an expression
@ ./node_modules/pug-filters/lib/run-filter.js
@ ./node_modules/pug-filters/index.js
@ ./node_modules/pug/lib/index.js
@ ./node_modules/kue/lib/http/index.js
@ ./node_modules/kue/lib/kue.js
@ ./node_modules/kue/index.js
@ ./src/app.js
@ multi ./src/app.js

WARNING in ./node_modules/bindings/bindings.js 82:43-53
Critical dependency: the request of a dependency is an expression
@ ./node_modules/hiredis/hiredis.js
@ ./node_modules/redis-parser/lib/hiredis.js
@ ./node_modules/redis-parser/lib/parser.js
@ ./node_modules/redis-parser/index.js
@ ./node_modules/redis/index.js
@ ./node_modules/kue/lib/redis.js
@ ./node_modules/kue/lib/kue.js
@ ./node_modules/kue/index.js
@ ./src/app.js
@ multi ./src/app.js

WARNING in ./node_modules/bindings/bindings.js 82:22-40
Critical dependency: the request of a dependency is an expression
@ ./node_modules/hiredis/hiredis.js
@ ./node_modules/redis-parser/lib/hiredis.js
@ ./node_modules/redis-parser/lib/parser.js
@ ./node_modules/redis-parser/index.js
@ ./node_modules/redis/index.js
@ ./node_modules/kue/lib/redis.js
@ ./node_modules/kue/lib/kue.js
@ ./node_modules/kue/index.js
@ ./src/app.js
@ multi ./src/app.js

WARNING in ./node_modules/express/lib/view.js 79:13-25
Critical dependency: the request of a dependency is an expression
@ ./node_modules/express/lib/application.js
@ ./node_modules/express/lib/express.js
@ ./node_modules/express/index.js
@ ./src/app.js
@ multi ./src/app.js

WARNING in ./node_modules/natural/lib/natural/wordnet/wordnet.js
Module not found: Error: Can't resolve 'WNdb' in '/Users/throoze/dev/com.chattigo.driver.generic/node_modules/natural/lib/natural/wordnet'
@ ./node_modules/natural/lib/natural/wordnet/wordnet.js
@ ./node_modules/natural/lib/natural/index.js
@ ./node_modules/reds/lib/reds.js
@ ./node_modules/reds/index.js
@ ./node_modules/kue/lib/queue/job.js
@ ./node_modules/kue/lib/kue.js
@ ./node_modules/kue/index.js
@ ./src/app.js
@ multi ./src/app.js

WARNING in ./node_modules/nib/lib/nib.js
Module not found: Error: Can't resolve 'canvas' in '/Users/throoze/dev/com.chattigo.driver.generic/node_modules/nib/lib'
@ ./node_modules/nib/lib/nib.js
@ ./node_modules/kue/lib/http/index.js
@ ./node_modules/kue/lib/kue.js
@ ./node_modules/kue/index.js
@ ./src/app.js
@ multi ./src/app.js

WARNING in ./node_modules/sylvester/lib/node-sylvester/matrix.js
Module not found: Error: Can't resolve 'lapack' in '/Users/throoze/dev/com.chattigo.driver.generic/node_modules/sylvester/lib/node-sylvester'
@ ./node_modules/sylvester/lib/node-sylvester/matrix.js
@ ./node_modules/sylvester/lib/node-sylvester/index.js
@ ./node_modules/apparatus/lib/apparatus/clusterer/kmeans.js
@ ./node_modules/apparatus/lib/apparatus/index.js
@ ./node_modules/natural/lib/natural/classifiers/bayes_classifier.js
@ ./node_modules/natural/lib/natural/index.js
@ ./node_modules/reds/lib/reds.js
@ ./node_modules/reds/index.js
@ ./node_modules/kue/lib/queue/job.js
@ ./node_modules/kue/lib/kue.js
@ ./node_modules/kue/index.js
@ ./src/app.js
@ multi ./src/app.js

ERROR in ./node_modules/stylus/lib/stylus.js
Module not found: Error: Can't resolve '../package' in '/Users/throoze/dev/com.chattigo.driver.generic/node_modules/stylus/lib'
@ ./node_modules/stylus/lib/stylus.js 27:18-39
@ ./node_modules/stylus/index.js
@ ./node_modules/kue/lib/http/index.js
@ ./node_modules/kue/lib/kue.js
@ ./node_modules/kue/index.js
@ ./src/app.js
@ multi ./src/app.js

ERROR in ./node_modules/stylus/index.js
Module not found: Error: Can't resolve './lib-cov/stylus' in '/Users/throoze/dev/com.chattigo.driver.generic/node_modules/stylus'
@ ./node_modules/stylus/index.js 3:42-69
@ ./node_modules/kue/lib/http/index.js
@ ./node_modules/kue/lib/kue.js
@ ./node_modules/kue/index.js
@ ./src/app.js
@ multi ./src/app.js

ERROR in ./node_modules/nib/lib/nodes/gradient.js
Module not found: Error: Can't resolve 'canvas' in '/Users/throoze/dev/com.chattigo.driver.generic/node_modules/nib/lib/nodes'
@ ./node_modules/nib/lib/nodes/gradient.js 8:13-30
@ ./node_modules/nib/lib/nib.js
@ ./node_modules/kue/lib/http/index.js
@ ./node_modules/kue/lib/kue.js
@ ./node_modules/kue/index.js
@ ./src/app.js
@ multi ./src/app.js

ERROR in ./node_modules/nib/lib/nodes/color-image.js
Module not found: Error: Can't resolve 'canvas' in '/Users/throoze/dev/com.chattigo.driver.generic/node_modules/nib/lib/nodes'
@ ./node_modules/nib/lib/nodes/color-image.js 8:13-30
@ ./node_modules/nib/lib/nib.js
@ ./node_modules/kue/lib/http/index.js
@ ./node_modules/kue/lib/kue.js
@ ./node_modules/kue/index.js
@ ./src/app.js
@ multi ./src/app.js

npm ERR! Darwin 17.6.0
npm ERR! argv "/Users/throoze/.nvm/versions/node/v7.7.3/bin/node" "/Users/throoze/.nvm/versions/node/v7.7.3/bin/npm" "run" "build"
npm ERR! node v7.7.3
npm ERR! npm v4.1.2
npm ERR! code ELIFECYCLE
npm ERR! chattigo-generic-driver@1.0.0 build: `webpack --config webpack.config.js`
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the chattigo-generic-driver@1.0.0 build script 'webpack --config webpack.config.js'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the chattigo-generic-driver package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! webpack --config webpack.config.js
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs chattigo-generic-driver
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls chattigo-generic-driver
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR! /Users/throoze/dev/com.chattigo.driver.generic/npm-debug.log
```

Any idea why is it happening? most of these errors/warnings are introduced when adding the kue library.

If any extra info is needed to help, please let me know. Thanks for your help!

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by running npm run build with webpack.config.js and inspect the dependency chain from src/app.js through kue, especially stylus, nib, natural, and redis. Compare the reported missing modules and dynamic-require warnings with the bundling configuration; done means the cause and a reproducible resolution for the webpack errors are documented.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, node.js, redis, webpack
Domain
backend, build-system
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.