Skip to content
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

Hot Module Replacement is buggy with TS #23776

Closed
ScreamZ opened this issue Mar 5, 2019 · 10 comments
Closed

Hot Module Replacement is buggy with TS #23776

ScreamZ opened this issue Mar 5, 2019 · 10 comments
Labels
Bug Ran Commands One of our bots successfully processed a command. Resolution: Duplicate Resolution: Locked This issue was locked by the bot.

Comments

@ScreamZ
Copy link

ScreamZ commented Mar 5, 2019

🐛 Bug Report

Hello,

I'm getting a HMR issue with ts barrels, along my styled-component styling…

To Reproduce

https://snack.expo.io/@screamz/hmr-issue

Download this expo project on local and run npm i && npm i -g expo-cli && expo start

Activate HMR by shaking device, then go to assetExample and change color: green to color: blue.

See that the app is crashing with HMR enabled saying « Attempting to change the getter of an unconfigurable object ». This is an issue with the barrel index.ts but i can't get it why ?

Expected Behavior

This shoumd HMR correctly

Code Example

https://snack.expo.io/@screamz/hmr-issue

Environment

React native > 57 and / or expo @ latest
Typescript (didn't tested without specifically but what I do is ESM compliant)

@react-native-bot
Copy link
Collaborator

Can you run react-native info and edit your issue to include these results under the Environment section?

If you believe this information is irrelevant to the reported issue, you may write [skip envinfo] under Environment to let us know.

@ScreamZ
Copy link
Author

ScreamZ commented Mar 5, 2019

Done

@hramos
Copy link
Contributor

hramos commented Mar 5, 2019

Are you certain this is an issue with React Native? It looks like you're using Expo.

@react-native-bot react-native-bot added Ran Commands One of our bots successfully processed a command. Resolution: Needs More Information labels Mar 5, 2019
@facebook facebook deleted a comment from react-native-bot Mar 5, 2019
@ScreamZ
Copy link
Author

ScreamZ commented Mar 6, 2019

I'm certain this is related to React-native, I'm not using an expo project for my real project.

What I'm not certain is :

  • Is it a typescript compiler issue ?
  • Is it a babel transpiler issue ? A babel with TS issue ?
  • Is it React Native HMR issue ?

The thing is it works as long you don't patch the file and it get hot reloaded.

Once you patch, this is yelling that you are doing some kind of redeclaration which is not allowed.

If you're not re-exporting everything goes fine…

@itsjgf
Copy link

itsjgf commented Mar 6, 2019

I think this issue is the same as the one explained in #22592.

It started happening after 0.56 (when react-native / metro were upgraded to Babel 7) was released and it affects .js files as well.

@ScreamZ
Copy link
Author

ScreamZ commented Mar 6, 2019

@itsjgf Yep, looks really like this…

@hramos
Copy link
Contributor

hramos commented Mar 6, 2019

Duplicate of #22592

@hramos hramos marked this as a duplicate of #22592 Mar 6, 2019
@hramos
Copy link
Contributor

hramos commented Mar 6, 2019

I added the previous comment in order to link this issue to #22592. Let me know if we should close this.

@ScreamZ
Copy link
Author

ScreamZ commented Mar 6, 2019

I don't know… You're the ticket manager ahah

Looks like it's the same issue yeah, i'll try the wordaround given

import C from './Currency;

const CurrencyHelper = C;

export {
  CurrencyHelper
}

In order to await

EDIT: seems related to #22592

@amed
Copy link

amed commented Mar 19, 2019

Create an index wrapper for components is apparently the issue.
As @ScreamZ has given, this was a workaround to fix it.

@facebook facebook locked as resolved and limited conversation to collaborators Mar 6, 2020
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Mar 6, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug Ran Commands One of our bots successfully processed a command. Resolution: Duplicate Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

No branches or pull requests

5 participants