speedskater / babel-plugin-rewire

A babel plugin adding the ability to rewire module dependencies. This enables to mock modules for testing purposes.
843 stars 90 forks source link

TypeError: Property body[8] of Program expected node to be of a type ["Statement"] but instead got "Noop" #164

Closed yvele closed 7 years ago

yvele commented 7 years ago

Another error.

TypeError: packages/poosh-core/src/FileProvider.js: Property body[8] of Program expected node to be of a type ["Statement"] but instead got "Noop"
    at validate (/Users/me/my-project/node_modules/babel-types/lib/definitions/index.js:109:13)
    at validator (/Users/me/my-project/node_modules/babel-types/lib/definitions/index.js:57:7)
    at Object.validate (/Users/me/my-project/node_modules/babel-types/lib/definitions/index.js:190:10)
    at validate (/Users/me/my-project/node_modules/babel-types/lib/index.js:505:9)
    at Object.builder (/Users/me/my-project/node_modules/babel-types/lib/index.js:466:7)
    at PluginPass.exit (/Users/me/my-project/node_modules/babel-plugin-rewire/lib/babel-plugin-rewire.js:214:55)
    at newFn (/Users/me/my-project/node_modules/babel-traverse/lib/visitors.js:276:21)
    at NodePath._call (/Users/me/my-project/node_modules/babel-traverse/lib/path/context.js:76:18)
    at NodePath.call (/Users/me/my-project/node_modules/babel-traverse/lib/path/context.js:48:17)
    at NodePath.visit (/Users/me/my-project/node_modules/babel-traverse/lib/path/context.js:117:8)

Using :

"devDependencies": {
    "babel-cli": "^6.16.0",
    "babel-eslint": "^7.0.0",
    "babel-plugin-flow-comments": "^6.3.19",
    "babel-plugin-rewire": "^1.0.0",
    "babel-plugin-transform-builtin-extend": "^1.1.0",
    "babel-preset-es2015": "^6.9.0",
    "babel-preset-stage-0": "^6.5.0"
  }

This will be my last error, I'm moving back to rewire. This plugin drove me nuts :scream:. And I don't think a special transpillation (for testing) is a good idea anyway. Lot of overhead with a test build, a production build..

Thank you @speedskater for the plugin.. interesting, but well.. :bowtie:

speedskater commented 7 years ago

@yvele thanks for reporting all the issues and sorry that the plugin is not working in your environment. I added a fixture to the test suite containing the code of FileProvider.js which caused trouble for you. In the test case, the code could be transpiled without any error. Therefore I will close this issue. If you come back to using this plugin and still have this issue please provide a small sample or a PR to the existing test which reproduces your error.