Can't resolve 'vertx' in '~/node_modules/plotly.js/dist'
See original GitHub issueI get the above warning in development, although plotly appears to work just fine.
- Webpack 4.5.1
- React 16.3.1
- Plotly.js 1.35.1
- React-plotly.js 2.1.0
There seems to be a lot of mixed opinions on how to get react-plotly working in a webpack setup, in my case I’m not using ify-loader
Here’s my js webpack rules if it helps
module: {
// Make missing exports an error instead of warning
strictExportPresence: true,
rules: [
// Rules for JS / JSX
{
test: reScript,
include: [SRC_DIR, resolvePath('tools')],
loader: 'babel-loader',
options: {
// https://github.com/babel/babel-loader#options
cacheDirectory: isDebug,
// https://babeljs.io/docs/usage/options/
babelrc: false,
presets: [
// A Babel preset that can automatically determine the Babel plugins and polyfills
// https://github.com/babel/babel-preset-env
[
'@babel/preset-env',
{
targets: {
browsers: pkg.browserslist,
forceAllTransforms: !isDebug, // for UglifyJS
},
modules: false,
useBuiltIns: false,
debug: false,
},
],
// Experimental ECMAScript proposals
// https://babeljs.io/docs/plugins/#presets-stage-x-experimental-presets-
'@babel/preset-stage-2',
// Flow
// https://github.com/babel/babel/tree/master/packages/babel-preset-flow
'@babel/preset-flow',
// JSX
// https://github.com/babel/babel/tree/master/packages/babel-preset-react
['@babel/preset-react', { development: isDebug }],
],
plugins: [
// Treat React JSX elements as value types and hoist them to the highest scope
// https://github.com/babel/babel/tree/master/packages/babel-plugin-transform-react-constant-elements
...(isDebug ? [] : ['@babel/transform-react-constant-elements']),
// Replaces the React.createElement function with one that is more optimized for production
// https://github.com/babel/babel/tree/master/packages/babel-plugin-transform-react-inline-elements
...(isDebug ? [] : ['@babel/transform-react-inline-elements']),
// Remove unnecessary React propTypes from the production build
// https://github.com/oliviertassinari/babel-plugin-transform-react-remove-prop-types
...(isDebug ? [] : ['transform-react-remove-prop-types']),
],
},
},
Edit: I just realized that I can’t build production if I’m using UglifyJS, the build process just goes on forever. If I comment out uglifyjs the build completes in a few minutes and runs fine. Any ideas here?
// Move modules that occur in multiple entry chunks to a new entry chunk (the commons chunk).
optimization: {
minimizer: [
new UglifyJsPlugin({
cache: true,
parallel: true,
sourceMap: false // set to true if you want JS source maps
}),
new OptimizeCSSAssetsPlugin({})
],
splitChunks: {
cacheGroups: {
styles: {
name: 'styles',
test: /\.s?css$/,
chunks: 'all',
enforce: true,
},
commons: {
chunks: 'initial',
test: /[\\/]node_modules[\\/]/,
name: 'vendors',
},
},
},
},
Issue Analytics
- State:
- Created 5 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Can't resolve 'vertx' · Issue #305 · stefanpenner/es6-promise
I solved by changing the logic in fileA to inject the dependencies. so fileA looks like this: module.exports = ({some_lib}) => (params) =>...
Read more >vertx module not found when using webpack - Stack Overflow
To resolve the issue: Install @vertx/core ( npm i @vertx/core ). Edit the file ./node_modules/when/lib/env.js , and change line 32 from
Read more >plotly - Bountysource
[Webpack] Module not found: Error: Can't resolve 'vertx' in '/home/user/app/node_modules/plotly.js/dist'. plotly.
Read more >gwtproject/gwt - Gitter
onSuccess(Ljava/lang/String;)': unable to resolve method in class ... one of the options at https://github.com/plotly/plotly.js/#load-as-a-node-module etc.
Read more >Can't build react-plotly.js
js ", path : `${DST}/js/`, publicPath: "/js/", sourceMapFilename: "[file].[hash].map" }, module: { rules: [ { test : /\.less$/, include: [ SRC ], ...
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 FreeTop 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
Top GitHub Comments
Instructions aren’t super clear, are you saying to do this for a pre-compiled build?
Edit: This seems to be the best way to use Plotly, only include the charts you are actually using. Doing things this way greatly reduced my build times when uglifying/minifying my js + much smaller overall bundle
I used
IgnorePlugin
(new webpack.IgnorePlugin(/vertx/)
) to solve this issue, since the require tovertx
seems to be an unnecessary dependency check inside a Promise shim, if I recall correctly.