-
Notifications
You must be signed in to change notification settings - Fork 98
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
export all babel-compiled src/modules to fix #110 #111
base: master
Are you sure you want to change the base?
Conversation
The config for webpack(2.x): resolve: {
alias: {
'react': 'react-lite/lib',
'react-dom': 'react-lite/lib',
'create-react-class': 'react-lite/lib/createClass'
}
} |
If add an alias to webpack configuration can resolve the problem, it's better to build a custom module named // create-react-class.js
import React from 'react' // which is react-lite actually
export default React.createClass And the resolve: {
alias: {
'react': 'react-lite',
'react-dom': 'react-lite',
'create-react-class': './create-react-class'
}
} |
@Lucifier129 Cool! Works for meXD |
If someone was to use this solution, would all classes need to be replaced with es5 create-react-class? Does this mean that es6 is not compatible? |
@Bbooth4 this solution would not cause any code change, and es6 classes is compatible. |
I tried the above method out to try to solve this issue. Important to note, I am using electron, antd and webpack 3.0.0, webpack-bundle-analyzer: 2.8.2, webpack-dev-server: 2.5.0, webpack-merge: 4.1.0. The following error and warning resulted:
Alternatively, I tried this in webpack because of the earlier error:
The new error:
|
resolve: {
extensions: ['.js', '.jsx', '.json'],
modules: [
path.join(__dirname, 'app'),
'node_modules',
],
alias: {
'react': 'react-lite',
'react-dom': 'react-lite',
'create-react-class': './create-react-class', // here must be a path string, not an export of module
}
}, |
If I add in the alias as a filepath, then the below error appears, breaking my antd. The error you see below appearsfor a number of calendar node_modules packages and the antd form. In the past, it has broken all of antd but the most recent instance only broke the calendar and the Form import from antd.
The final error after the several 'Module not found' errors is the line below.
That dot (.) error is why I originally tried to import the small create-react-class file, since it only appeared when the alias had a filepath. If I remove the Could be important to note, that I upgraded to react 15.6.0. |
@Bbooth4 'create-react-class': path.join(__dirname, './create-react-class') // use absolute file path |
@Lucifer129 Thanks, that at least solved the breaking antd and calendar components. However, now I am exactly where I started. |
@Bbooth4 I have no idea now. Can you add a simple code example to reproduce the problem here? |
@Lucifier129 Thank you so much for your help. In the process of creating the simple code example, I it worked for the first time (first time even the simplest thing had worked) and I slowly built up my app from there. It works now but seems somewhat fragile since I am not 100% sure what solved the problem within the code that was unrelated to what was discussed here. Thanks again and I really appreciated the time you took to answer my questions. |
The drop-in package 'create-react-class' will trigger #110 . I tried to use wepback alias to force 'create-react-class' resolving to react-lite.createClass but found it's hard to do this if rolling up react-lite as a commonjs module. So I babel all src to lib. I don't know whether it's a good idea for the project specifications of react-lite.