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

Update FatalErrorPage codemod to work with hybrid JS/TS projects #5366

Merged
merged 2 commits into from
May 2, 2022

Conversation

Tobbe
Copy link
Member

@Tobbe Tobbe commented Apr 30, 2022

This PR makes the fatalerrorpage codemod look for an existing FatalErrorPage.{js,tsx} file and replaces that, instead of looking for a tsconfig.json file.

Background

I just upgraded one of my RW projects from v0.45 to v0.48

I verified that it still worked after running yarn rw upgrade

Then I applied the FatalErrorPage codemod and got this

image

And in my terminal I see

web | ERROR in ./src/Routes.js 35:6
web | Module parse failed: Identifier 'FatalErrorPage' has already been declared (35:6)
web | File was processed with these loaders:
web |  * ../node_modules/@pmmmwh/react-refresh-webpack-plugin/loader/index.js
web |  * ../node_modules/babel-loader/lib/index.js
web | You may need an additional loader to handle the result of these loaders.
web | |   loader: () => import("./pages/FatalErrorPage/FatalErrorPage")
web | | };
web | > const FatalErrorPage = {
web | |   name: "FatalErrorPage",
web | |   loader: () => import("./pages/FatalErrorPage/FatalErrorPage")
web |  @ ./src/App.js 12:0-30 30:269-275
web |  @ ./src/index.js 9:0-24 29:53-56 31:52-55
web |
web | webpack 5.70.0 compiled with 1 error in 2696 ms

I noticed I had a new FatalErrorPage.tsx file. So now I had two error pages.

image

Deleting the old FatalErrorPage.js file makes everything work again.

This project of mine started its life as a JS RW project, but I've gradually been moving to TS, that's why I had a .js error page and a tsconfig.json file.

@netlify
Copy link

netlify bot commented Apr 30, 2022

Deploy Preview for redwoodjs-docs canceled.

Name Link
🔨 Latest commit 523af56
🔍 Latest deploy log https://app.netlify.com/sites/redwoodjs-docs/deploys/626fd9d0dffb650009aadfd4

@Tobbe Tobbe added the release:fix This PR is a fix label Apr 30, 2022
@Tobbe Tobbe requested a review from dthyresson April 30, 2022 21:23
@jtoar jtoar enabled auto-merge (squash) May 2, 2022 13:17
@jtoar jtoar merged commit 97b49a5 into redwoodjs:main May 2, 2022
@jtoar jtoar modified the milestones: next-release, v1.4.0 May 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release:fix This PR is a fix
Projects
No open projects
Status: Done
Development

Successfully merging this pull request may close these issues.

None yet

3 participants