Analyzer not finding correct entry path with webpack-dev-server
See original GitHub issueHi. I tried to install css-blocks in our environment that has Flow-typed React 16 code running on Webpack 3 and Babel 6. We’re using webpack-dev-server for serving the app in dev. It seems the Analyzer plugin does not find the correct entry point but thinks the webpack-dev-server folder is the root folder (error below)
ERROR in [css-blocks] JSXParseError: Cannot read JSX entry point file /Users/myname/Documents/myapp/node_modules/webpack-dev-server/client/index.js?http:/localhost:3000: ENOENT: no such file or directory, open '/Users/myname/Documents/myapp/node_modules/webpack-dev-server/client/index.js?http:/localhost:3000' (/Users/myname/Documents/myapp/node_modules/webpack-dev-server/client/index.js?http:/localhost:3000)
Correct path would be:
/Users/myname/Documents/myapp/client/main.js
I have this config in webpack config:
const analyzerInstance = new CssBlocks.Analyzer('client/main.js', {
baseDir: '/Users/myname/Documents/myapp',
types: 'flow',
});
but it doesn’t seem to have effect.
ps. Both our app and webpack-dev-server happen to use client
folder as part of the path. So client/index.js
is not mistyped path to our entry but the actual entry point of the dev server. (I was confused by this myself for a second)
Issue Analytics
- State:
- Created 5 years ago
- Comments:11 (4 by maintainers)
Top GitHub Comments
I’m encountering this too! Although perhaps this issue is misnamed: the analyzer receives the correct entry point, but it also receives two bogus paths from webpack-dev-server.
webpack-dev-server automatically injects two paths into the entry config:
/ABSOLUTE/PATH/TO/YOUR/PROJECT/node_modules/webpack-dev-server/client/index.js?http://localhost:PORT_NUMBER
andwebpack/hot/dev-server
. Since neither of these paths represent files that actually exist, an error is thrown when the JSX analyzer runsfs.readFile
on them.Edit: I’m using webpack@^3.12.0
I updated the code.
running
yarn build
works w/o issues runningyarn dev
throws:(node:13154) UnhandledPromiseRejectionWarning: Error: [css-blocks] JSXParseError: Error parsing '/Users/felipetores/Github/fforres/css-blocks-webpack/node_modules/webpack-dev-server/client/index.js?http:/localhost:3000' Cannot read property '0' of undefined
and
ERROR in [css-blocks] JSXParseError: Cannot read JSX entry point file /Users/felipetores/Github/fforres/css-blocks-webpack/node_modules/webpack-dev-server/client/index.js?http:/localhost:3000: ENOENT: no such file or directory, open '/Users/felipetores/Github/fforres/css-blocks-webpack/node_modules/webpack-dev-server/client/index.js?http:/localhost:3000' (/Users/felipetores/Github/fforres/css-blocks-webpack/node_modules/webpack-dev-server/client/index.js?http:/localhost:3000)