gatsbyjs / gatsby

The best React-based framework with performance, scalability and security built in.
https://www.gatsbyjs.com
MIT License
55.28k stars 10.31k forks source link

Typescript: gatsby-browser not picked up after Gatsby Update #5317

Closed iv-mexx closed 5 years ago

iv-mexx commented 6 years ago

Description

I have a fully working project using Typescript and Gatsby 1.9.127. Now I wanted to update Gatsby to the newest version (1.9.259) but after doing so, gatsby-browser.tsx is not compiled anymore and so my site does not work anymore.

This also is the case if I use a fresh project based on this starter

Steps to reproduce

console.log('Hello');

exports.onInitialClientRender = () => {
  console.log('ReactDOM.render has executed!!!')
}

Expected result

Actual result

Note

If gatsby-browser is not written in typescript (gatsby-browser.js), it works as expected.

Environment

File contents (if changed):

gatsby-config.js: no changes from starter project package.json: no changes from starter project gatsby-node.js: no changes from starter project gatsby-browser.js: changed to .tsx gatsby-browser.tsx

console.log('Hello');

exports.onInitialClientRender = () => {
  console.log('ReactDOM.render has executed!!!')
}

gatsby-ssr.js: no changes from starter project

alvis commented 6 years ago

What was your setting to compile gatsby-browser.tsx in gatsby 1.9.127?

gatsby-plugin-typescript doesn't cover API files such as gatsby-config, gatsby-browser etc. To use typescript on these files, you need a transpiler placed in front of gatsby, e.g.

babel-node --presets @babel/preset-typescript --extensions '.ts,.tsx' gatsby develop

Disclaimer: I'm the author of another typescript starter (WIP) for gatsby: https://github.com/alvis/barebone-webapp

There are a few things broken at the moment, but it should work to some extent out of the box.

iv-mexx commented 6 years ago

Honestly - I don't know how it worked before. I've used the aforementioned starter and it just worked. I assumed that this was as intended and supported by Gatsby (or by gatsby-plugin-typescript).

I'll checkout your starter

calcsam commented 6 years ago

@iv-mexx -- were you able to resolve this?

iv-mexx commented 6 years ago

No, that project is only semi active, and I did not have the time to look into this further. Currently, I'm still using the old version of Gatsby where this still worked.

gatsbot[bot] commented 5 years ago

Hiya!

This issue has gone quiet. Spooky quiet. 👻

We get a lot of issues, so we currently close issues after 30 days of inactivity. It’s been at least 20 days since the last update here.

If we missed this issue or if you want to keep it open, please reply here. You can also add the label "not stale" to keep this issue open!

Thanks for being a part of the Gatsby community! 💪💜

gatsbot[bot] commented 5 years ago

Hey again!

It’s been 30 days since anything happened on this issue, so our friendly neighborhood robot (that’s me!) is going to close it.

Please keep in mind that I’m only a robot, so if I’ve closed this issue in error, I’m HUMAN_EMOTION_SORRY. Please feel free to reopen this issue or create a new one if you need anything else.

Thanks again for being part of the Gatsby community!