webpack-dev-server & jsxhint: const '$__0' has already been declared

164 views Asked by At

Somehow, it seems jsxhint is analysing the compiled files by webpack when I run the following command

 webpack-dev-server --devtool eval --colors --progress --content-base ./build

I get these warnings

const '$__0' has already been declared. @ line <n> char <m>

for about 30% of the files in the application.

It makes reference to line and character numbers that correspond with the (processed) files available in my chrome devtools when I go the the Sources Tab > webpack:// > . > relative-path-to-file. I attempted to find where those files were on disk to add them to the pre loader's list of exclusions, but it according to the webpack-dev-server documentation these files are served from memory.

I've tried completely deleting the application and all node modules and checking it out again from the repository, but this did not fix the problem.

The problem began after updating the node modules in the package.json file after deleting the node_modules folder. I've tried rolling back to the previous versions of all node modules, but the problem persists.

Contents of webpack.config.js

...

preLoaders: [
      {
        test: /\.jsx?$/,
        loader: 'jsxhint-loader?harmony',
        exclude: /node_modules/
      }
    ],
loaders: [
  {
    test: /\.jsx?$/,
    loader: "react-hot!babel",
    exclude: /node_modules/
  },

package.json

...

"devDependencies": {
  "autoprefixer-core": "^5.2.0",
  "babel-core": "^5.5.6",
  "babel-jest": "^5.2.0",
  "babel-loader": "^5.1.4",
  "css-loader": "^0.14.5",
  "file-loader": "^0.8.4",
  "html-webpack-plugin": "^1.5.0",
  "jest-cli": "^0.4.11",
  "json-loader": "^0.5.2",
  "jsx-loader": "^0.13.2",
  "jsxhint-loader": "^0.2.0",
  "less": "^2.5.1",
  "less-loader": "^2.2.0",
  "node-libs-browser": "^0.5.2",
  "postcss-loader": "^0.4.4",
  "react-hot-loader": "^1.2.7",
  "react-immutable-proptypes": "^1.0.0",
  "react-tools": "^0.13.3",
  "style-loader": "^0.12.3",
  "url-loader": "^0.5.6",
  "webpack": "^1.9.10",
  "webpack-dev-server": "^1.9.0"
},
1

There are 1 answers

0
Dr.Seuss On

Removing the ?harmony preloader argument seems to have resolved this issue. This argument was being sent internally to reactTools, which was performing transformations on the source code before it reached jsx-loader. It seems the two versions of the modules are not compatible ([email protected] and [email protected]) to be used in this fashion.

This has changed statements like var {foo} = this.props from being converted to $__0 = this.props; var foo = $__0.foo; to being converted to var _props = this.props; var foo = _props.foo; instead. I have found no naming collisions as of yet, like those occuring before removing the harmony parameter.