-
Notifications
You must be signed in to change notification settings - Fork 799
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
Restore Webpack loader (and use it for TS) #1039
Comments
Is there any estimate for when this will be done? I am currently trying to upgrade a project from Webpack 3 to Webpack 4 (and React Hot Loader 3 -> 4). This new requirement to use Babel for TS is a major hurdle because Babel has some limitations with processing TS. Specifically, Babel does not support namespaces, and this project uses namespaces. Changing the project to not use namespaces is not practical. Therefore, I simply cannot use Babel to process my Typescript code, and I cannot use React Hot Loader :( Even if there wasn't this issue with namespaces, it's quite obnoxious to setup babel to process Typescript for the sole purpose of React Hot Loader when nothing else about this project requires Babel. |
You can always put babel loader after ts-loader |
I prefer to use babel 7 to compile typescript |
@theKashey with Babel 7 + Typescript, I think it is not a good idea. Better to keep it simple. |
I am seeing webpack loader as a good help for Meanwhile - we failed to migrate to babel 7 in our own work projects, and still stuck with TS-loader, waiting for all peers to update first (even RHL itself is not babel7 compatible yet). So
Will do the job |
While waiting for progress on this issue, I've been trying to get webpack 4 + typescript + react-hot-loader working in my project by using babel with minimal configuration to process the output of ts-loader. So the loaders for my .ts/.tsx files looks a bit like this: {
use: [
{
loader: "babel-loader",
options: {
cacheDirectory: true,
babelrc: false,
plugins: ["react-hot-loader/babel"]
}
},
{
loader: "ts-loader",
options: {
transpileOnly: true,
compilerOptions: {
sourceMap: isSourceMap,
isolatedModules: true,
noEmitOnError: false
}
}
}
]
} But I can't get HMR to work for react components. After enabling debug logging, I see output like this in the console:
So clearly, react-hot-loader is trying to apply the hot updates, but can't for some reason (the reason is not specified in plain human readable text, and I don't know how to analyze the complex structures in the logs to determine the reason). I am using the My suspicion is that my problem is caused by the use of 3rd party react components from |
Nevermind; I setup my project to run ALL node_modules code through babel, and I still have the problem. So my problem is unrelated to this issue. I'll create a new issue if I can narrow it down to something more specific than, "I can't get HMR to work" (it seems to be a limitation/bug related to some 3rd party react components; some hot react updates DO work just fine, but updates to my components that are presented within a BlueprintJS Dialog do not hot update correctly, for example). |
Could be React 15 portals. They are breaking normal update processing, but should still be more or less good. |
That seems likely. I only seem to encounter this problem when making code changes to a component that is rendered within a component that uses a portal. Are there any feasible plans to make react-hot-loader work better with Portals, or is this an unfortunate limitation we're stuck with forever? And back on topic... any news on reimplementing a webpack loader so that Babel is not required? |
Portals would be fixed by reactjs/rfcs#74, if it ever got implemented. webpack stuff was more or less finished a month ago, but not yet merged. |
4.6.0 with webpack and controlled type comparison went out |
Could you clarify how the webpack plugin "is not compatible with class-based components"? (quote from the README section about the webpack plugin) I assume a "class-based component" is any component that is a class that extends React.Component? What incorrect behavior will I experience with the webpack plugin if my project uses class-based components? |
Babel plugin would inject special member to update class methods, while webpack would do nothing. So - using only webpack plugin you will be unable to update non-prototype-based methods, especally the arrow functions, or any other "bind"ed callbacks. class MyComponent extends React.Component {
variable=1;// this can
onClick = () => this.setState() // this can NOT
render() { // this can
} |
Thanks for the explanation. I think it would be helpful to add an explanation like this to the README. |
Mee to :) |
Webpack-loader is restored. |
Then we have invented "cold API", and got reasons to get webpack loader back - just to register variables in node_modules as fast as possible.
Then we started thinking about better TypeScript support, and it's too many variants, and all are not "better" - as long they are about replacing TS by babel 7 or running babel before or after TS.
All those variants are or slow, or unacceptable by "hey, it's babel free zone here!" reasons.
Idea:
class
keyword used. If it will be found - inject RHL methodsResult:
The text was updated successfully, but these errors were encountered: