i have rails app includes number of react components on front end , while attempting add things started break because of multiple versions of react.
going , updating old code can on react@15.x
decided use peerdependencies every feature wasn't loading in it's own instance of react library.
in development peerdependencies
working fine when attempting build production error:
cannot resolve module 'react' in /users/path/to/project/lib/toaster @ ...
what missing?
package.json:
{ "name": "my-package", // ... omitted ... "scripts": { "test": "node_env=development testem ci", "testem": "testem -g", "start": "webpack --watch", "build": "webpack -p --config ./webpack.production.config.js --progress --profile --colors --preserve-symlinks" }, "repository": { // ... omitted ... }, "devdependencies": { "babel-core": "^6.4.5", "babel-loader": "^6.2.1", "babel-preset-es2015": "^6.3.13", "babel-preset-react": "^6.23.0", "browser-sync": "^2.17.2", "browser-sync-webpack-plugin": "^1.1.3", "bundle-collapser": "^1.1.1", "del": "^1.1.1", "envify": "^3.2.0", "es6-promise": "^2.0.1", "tape": "^4.0.0", "testem": "^0.6.35", "webpack": "^1.13.2" }, "peerdependencies": { "react": "^15.3.2", "react-dom": "^15.3.2" }, "dependencies": { "empty": "^0.10.0", "lodash": "^3.9.1", "react-addons-css-transition-group": "^15.4.2" } }
webpack.production.config.js
var path = require('path'); var webpack = require('webpack'); module.exports = { entry: [ ... ], devtool: 'eval', output: { path: path.join(__dirname, "output"), filename: 'index.js', library: 'my-package', librarytarget: 'umd' }, resolveloader: { modules: ['..', 'node_modules'] }, plugins: [ new webpack.defineplugin({ // has effect on react lib size. "process.env": { node_env: json.stringify("production") } }), new webpack.ignoreplugin(/vertx/), new webpack.ignoreplugin(/configs/), new webpack.ignoreplugin(/un~$/), new webpack.optimize.dedupeplugin(), new webpack.optimize.uglifyjsplugin(), ], resolve: { extensions: ['.js', '.jsx'] }, module: { loaders: [ { test: /.jsx?$/, loader: 'babel-loader', exclude: /node_modules/, query: { presets: ['es2015', 'react'] } } ] } };
i figured out...
this had nothing peerdependencies
. problem in webpack.production.config.js file under resolve
resolve: { extensions: ['.js', '.jsx'] }
needed
resolve: { extensions: ['', '.js', '.jsx'] }
which in normal webpack.config.js file
Comments
Post a Comment