codemix / babel-plugin-typecheck

Static and runtime type checking for JavaScript in the form of a Babel plugin.
MIT License
886 stars 44 forks source link

Object typecheck has no method 'apply' #4

Closed winkler1 closed 9 years ago

winkler1 commented 9 years ago

Hi- I'm getting this error when "typecheck" is one of the webpack plugins. Any ideas?

13:25:13 web.1 | /Users/jeff.winkler/repos/project/node_modules/webpack/node_modules/tapable/lib/Tapable.js:164 13:25:13 web.1 | arguments[i].apply(this); 13:25:13 web.1 | ^ 13:25:13 web.1 | TypeError: Object typecheck has no method 'apply' 13:25:13 web.1 | at Tapable.apply (/Users/jeff.winkler/repos/project/node_modules/webpack/node_modules/tapable/lib/Tapable.js:164:16) 13:25:13 dashv1.1 | 13:25:13 web.1 | at OptionsApply.WebpackOptionsApply.process (/Users/jeff.winkler/repos/project/node_modules/webpack/lib/WebpackOptionsApply.js:64:18) 13:25:13 dashv1.1 | /Users/jeff.winkler/repos/project/node_modules/webpack/node_modules/tapable/lib/Tapable.js:164 13:25:13 web.1 | at webpack (/Users/jeff.winkler/repos/project/node_modules/webpack/lib/webpack.js:22:48) 13:25:13 dashv1.1 | arguments[i].apply(this); 13:25:13 web.1 | at Object. (/Users/jeff.winkler/repos/project/server.js:8:22) 13:25:13 dashv1.1 | ^ 13:25:13 web.1 | at Module._compile (module.js:456:26) 13:25:13 web.1 | at Object.Module._extensions..js (module.js:474:10) 13:25:13 web.1 | at Module.load (module.js:356:32) 13:25:13 web.1 | at Function.Module._load (module.js:312:12) 13:25:13 web.1 | at Function.Module.runMain (module.js:497:10) 13:25:13 web.1 | at startup (node.js:119:16) 13:25:13 web.1 | exited with code 8

bebraw commented 9 years ago

What does your configuration look like? Easier to repro if you can provide some.

winkler1 commented 9 years ago

Hey @bebraw!

webpack_config:

var babelOptions = require('./babelOptions'),
  path = require('path'),
  webpack = require('webpack');

var port = JSON.parse(process.env.npm_package_config_port || 1337),
  url = 'http://localhost:' + port;

module.exports = {
  // If it gets slow on your project, change to 'eval':
  devtool: 'eval', // was source-map
  entry: [
    'webpack-dev-server/client?' + url,
    'webpack/hot/only-dev-server',
    './components/poc/CCPOCIndex'
  ],
  output: {
    path: path.join(__dirname, 'dist'),
    filename: 'bundle.js'
  },
  externals: {
    // require('react') is external and available
    // on the global var React. Ditto for jquery.
    'react': 'React',
    'jquery': 'jQuery',
    'lodash': '_'
  },
  plugins: [
    new webpack.DefinePlugin({
      'process.env': {
        'NODE_ENV': JSON.stringify('development')
      }
    }),
    new webpack.HotModuleReplacementPlugin(),
    'typecheck',
    new webpack.NoErrorsPlugin()
  ],
  resolve: {
    extensions: ['', '.js']
  },
  module: {
    loaders: [
      {test: /\.css$/, loader: 'style!css'},
      {test: /\.scss$/, loader: 'style!css!sass'},

      {test: /\.js$/, loaders: ['react-hot', 'babel?' + JSON.stringify(babelOptions)], exclude: /node_modules/}
    ]
  }
};

babelOptions:

module.exports = {
  cacheDirectory: true,
  optional: [
    'utility.inlineExpressions', // http://babeljs.io/docs/usage/transformers/utility/inline-expressions/

    'runtime'
  ]
};
winkler1 commented 9 years ago

package.json... time to upgrade things :)

"devDependencies": {
    "babel-core": "^5.1.11",
    "babel-eslint": "^3.0.1",
    "babel-loader": "^5.0.0",
    "babel-plugin-typecheck": "0.0.3",
    "chai": "^1.10.0",
    "css-loader": "^0.9.0",
    "eslint": "^0.19.0",
    "eslint-loader": "^0.10.0",
    "eslint-plugin-react": "^2.1.1",
    "handlebars": "^2.0.0",
    "json-loader": "^0.5.1",
    "jsx-loader": "^0.12.2",
    "karma": "^0.12.28",
    "karma-chai": "^0.1.0",
    "karma-chrome-launcher": "^0.1.6",
    "karma-clear-screen-reporter": "0.0.1",
    "karma-cli": "0.0.4",
    "karma-firefox-launcher": "^0.1.3",
    "karma-growl-reporter": "^0.1.1",
    "karma-mocha": "^0.1.9",
    "karma-mocha-reporter": "^0.3.1",
    "karma-phantomjs-launcher": "^0.1.4",
    "karma-requirejs": "^0.2.2",
    "karma-safari-launcher": "^0.1.1",
    "karma-webpack": "^1.3.1",
    "mocha": "^2.0.1",
    "raw-loader": "^0.5.1",
    "react-hot-loader": "^0.5.0",
    "react-render-visualizer": "^0.2.2",
    "sass-loader": "^0.3.1",
    "style-loader": "^0.8.2",
    "webpack": "^1.9.7",
    "webpack-dev-server": "1.7.0"
  },
  "dependencies": {
    "babel-runtime": "^5.1.11",
    "jsonschema": "^1.0.0",
    "lodash": "^2.4.1",
    "react": "^0.12.1",
    "react-bootstrap": "^0.13.2",
    "react-diff": "0.0.4",
    "react-dnd": "^0.6.2",
    "react-router": "^0.11.4",
    "react-zeroclipboard": "^0.4.1"
  }
bebraw commented 9 years ago

'typecheck' shouldn't be within Webpack plugin configuration given it's a Babel plugin. It should go to .babelrc.

winkler1 commented 9 years ago

Dope! That makes sense, thx :)