Open birkir opened 6 years ago
Thansk for the report! Can you post your tsconfig file?
Yessir
{
"compilerOptions": {
"target": "es2015",
"jsx": "react",
"baseUrl": "./src",
"noEmit": true,
"noImplicitAny": false,
"strictNullChecks": false,
"allowSyntheticDefaultImports": true,
"moduleResolution": "node",
"experimentalDecorators": true,
"sourceMap": true
},
"exclude": [
"node_modules"
]
}
Diff:
diff --git a/.babelrc b/.babelrc
index 08a4f73..5ed5558 100644
--- a/.babelrc
+++ b/.babelrc
@@ -1,6 +1,6 @@
{
"presets": [
- "react-native-stage-0/decorator-support"
+ "react-native"
],
"plugins": [
[
diff --git a/package.json b/package.json
index b2a30b8..3f07026 100644
--- a/package.json
+++ b/package.json
@@ -46,7 +46,7 @@
"mobx-state-tree": "2.0.5",
"prop-types": "15.6.1",
"react": "16.4.0",
- "react-native": "0.55.4",
+ "react-native": "0.56.0-rc.1",
"react-native-blur": "3.2.2",
"react-native-cheerio": "1.0.0-rc.4",
"react-native-code-push": "5.3.4",
@@ -81,7 +81,7 @@
"babel-eslint": "8.2.3",
"babel-jest": "23.0.1",
"babel-plugin-module-resolver": "3.1.1",
- "babel-preset-react-native": "4.0.0",
+ "babel-preset-react-native": "5.0.1",
"babel-preset-react-native-stage-0": "1.0.1",
"css-to-react-native-transform": "1.6.0",
"detox": "7.4.0",
I am trying to gather as much info as I can to help resolve the problem.
They seem to have moved hmrConfig to a separate file so I can't see the diff https://github.com/facebook/metro/blob/master/packages/metro/src/hmrConfig.js
Awesome, thanks!
As a first step, can you try this:
{
"compilerOptions": {
"target": "es2015",
+ "module": "es2015",
"jsx": "react",
"baseUrl": "./src",
"noEmit": true,
"noImplicitAny": false,
"strictNullChecks": false,
"allowSyntheticDefaultImports": true,
"moduleResolution": "node",
"experimentalDecorators": true,
"sourceMap": true
},
"exclude": [
"node_modules"
]
}
Thanks for the quick reply, setting the module property to es2015 didn't work for me. Also tried jsx from react to react-native without any luck.
Also to be clear, in my instance, the iOS app gets the update when I log:
if (module.hot) {
module.hot.accept(() => {
console.log('Got update');
});
}
But it doesn't get applied
Hmm looks like they added a plugins
field to the transform props
Maybe passing that along will help.
(I'll try this out later)
I too am suffering from this, though a bit worse; it doesn't even get as far as reported by @birkir.
I'm trying the released react-native 0.56
I'm getting nearly unending repeats of this:
transform[stderr]: Trace: The node type SpreadProperty has been renamed to SpreadElement
transform[stderr]: at Object.isSpreadProperty (/Users/fbarthelemy/Code/TRClient/node_modules/@babel/types/lib/validators/generated/index.js:4080:11)
transform[stderr]: at hasSpread (/Users/fbarthelemy/Code/TRClient/node_modules/babel-plugin-transform-object-rest-spread/lib/index.js:38:13)
transform[stderr]: at PluginPass.ObjectExpression (/Users/fbarthelemy/Code/TRClient/node_modules/babel-plugin-transform-object-rest-spread/lib/index.js:234:14)
transform[stderr]: at newFn (/Users/fbarthelemy/Code/TRClient/node_modules/@babel/traverse/lib/visitors.js:237:21)
transform[stderr]: at NodePath._call (/Users/fbarthelemy/Code/TRClient/node_modules/@babel/traverse/lib/path/context.js:65:20)
transform[stderr]: at NodePath.call (/Users/fbarthelemy/Code/TRClient/node_modules/@babel/traverse/lib/path/context.js:40:17)
transform[stderr]: at NodePath.visit (/Users/fbarthelemy/Code/TRClient/node_modules/@babel/traverse/lib/path/context.js:100:12)
transform[stderr]: at TraversalContext.visitQueue (/Users/fbarthelemy/Code/TRClient/node_modules/@babel/traverse/lib/context.js:142:16)
transform[stderr]: at TraversalContext.visitSingle (/Users/fbarthelemy/Code/TRClient/node_modules/@babel/traverse/lib/context.js:102:19)
transform[stderr]: at TraversalContext.visit (/Users/fbarthelemy/Code/TRClient/node_modules/@babel/traverse/lib/context.js:182:19)
I know that's not the most terse of reproduction details, but I'm happy to try out whatever to get us into shape.
You can just upgrade to 0.56, i have no issues with hot reloading on the actual release
@iRoachie would you mind sending me the general outline of your tsconfig, .babelrc, and Rn-cli.config files? I’d love to see the config for a working typescript with Rn 56. I’m not sure what I did wrong, above.
tsconfig.json
{
"compilerOptions": {
"target": "es2015",
"module": "es2015",
"jsx": "react-native",
"noEmit": true,
"moduleResolution": "node",
"strictPropertyInitialization": false,
"skipLibCheck": true,
"strict": true,
"allowSyntheticDefaultImports": true,
"baseUrl": "src",
"noUnusedLocals": true,
"suppressImplicitAnyIndexErrors": true,
"noUnusedParameters": true,
"paths": {
"@components": ["components"],
"@config": ["config"],
"@pages": ["pages"],
"@types": ["types"],
"@util": ["util"],
"@actions": ["actions"],
"@reducers": ["reducers"]
},
"lib": ["es2017", "dom"]
},
"exclude": ["node_modules"]
}
.babelrc
{
"presets": ["react-native"],
"plugins": [
[
"module-resolver",
{
"root": ["./src"],
"cwd": "babelrc",
"alias": {
"@components": "./src/components",
"@config": "./src/config",
"@pages": "./src/pages",
"@types": "./src/types",
"@util": "./src/util",
"@actions": "./src/actions",
"@reducers": "./src/reducers"
}
}
]
]
}
rn-cli.config.js
const blacklist = require('metro/src/blacklist')
module.exports = {
getTransformModulePath() {
return require.resolve('react-native-typescript-transformer')
},
getSourceExts() {
return ['ts', 'tsx']
},
getBlacklistRE() {
return blacklist([/react-native\/local-cli\/core\/__fixtures__.*/])
},
}
@iRoachie Oh! I didn't know anything about the 'metro/src/blacklist'
module.
For that matter, I didn't know about babelrc's alias mode either. Both of those are very neat!
I'm going to try the blacklist, maybe that's key to avoiding compiling things wrong for us.
Thanks for the update, will try and reporter back.
seems this might be the issue.. not sure how to fix
https://github.com/babel/babel/issues/7318
(On upgrading to 0.56, I also have the error: The node type SpreadProperty has been renamed to SpreadElement)
someone have a working package.json
(or shared project) for rn 0.56 or 0.57? im trying to upgrade but always fails for one o another reason
@dengue8830 https://github.com/iRoachie/channel-app
There is typescript support shipped with RN 56/57, HMR works fine.
@birkir You should know that it doesn't actually run your typescript through the typescript compiler, it only removes your types, similar to how it treats flow files.
I had to update react-native-typescript-transformer
from 1.2.5 to version 1.2.10. This line in particular seems to resolve the issue: https://github.com/ds300/react-native-typescript-transformer/blob/master/index.js#L20
I am also getting the same error , did u got any solution for this ? @fbartho react-native-cli: 2.0.1 react-native: 0.57.1 node: v8.11.3 npm: 5.6.0
HMR does not work with react-native@0.56.0-rc.1