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

codemod(v2.3): Adds codemod to modify web/tsconfig.json to allow $api imports #6098

Merged
merged 4 commits into from
Aug 4, 2022

Conversation

dac09
Copy link
Collaborator

@dac09 dac09 commented Aug 1, 2022

Adds codemod for #5600

The codemod is required not because its a breaking change, but because you need it to "opt in" to new features. See description below.

Command for reference:

npx @redwoodjs/codemods@canary tsconfig-for-route-hooks

Modify TS Config For Route Hooks

Updates the web/tsconfig.json file to include a path alias for $api.

This allows you to import for example

import { db } from '$api/src/lib/db'
import { bazinga } from '$api/src/lib/bazinga'

Just like in scripts, in your *.routeHooks.ts files. This feature was enabled as part of Cell prerendering and dynamic path prerendering.

@nx-cloud
Copy link

nx-cloud bot commented Aug 1, 2022

☁️ Nx Cloud Report

CI is running/has finished running commands for commit 4d3bb17. As they complete they will appear below. Click to see the status, the terminal output, and the build insights.

📂 See all runs for this branch


✅ Successfully ran 4 targets

Sent with 💌 from NxCloud.

@netlify
Copy link

netlify bot commented Aug 1, 2022

Deploy Preview for redwoodjs-docs canceled.

Name Link
🔨 Latest commit 4d3bb17
🔍 Latest deploy log https://app.netlify.com/sites/redwoodjs-docs/deploys/62eb3a3501ec620008bbda70

@dac09 dac09 added the release:chore This PR is a chore (means nothing for users) label Aug 1, 2022
@dac09 dac09 requested a review from Tobbe August 1, 2022 17:40
@Tobbe Tobbe enabled auto-merge (squash) August 4, 2022 03:17
@dac09
Copy link
Collaborator Author

dac09 commented Aug 4, 2022

Thanks @Tobbe - just going to double check that it doesn't fail after the canary publish. I realised I'm using typescript without having it as a dependency in the codemods package - but maybe it'll use the locally installed version inside the project's folder

@Tobbe Tobbe merged commit 4f14016 into redwoodjs:main Aug 4, 2022
@redwoodjs-bot redwoodjs-bot bot added this to the next-release milestone Aug 4, 2022
@dac09 dac09 deleted the codemod/route-hooks-tsconfig branch August 4, 2022 13:43
@dac09
Copy link
Collaborator Author

dac09 commented Aug 4, 2022

Yup - was worried this might happen...

Error: Cannot find module 'typescript'
Require stack:
- /Users/dac09/.npm/_npx/6af5e84efc8d7cdf/node_modules/@redwoodjs/codemods/dist/codemods/v2.3.x/tsconfigForRouteHooks/tsconfigForRouteHooks.js
- /Users/dac09/.npm/_npx/6af5e84efc8d7cdf/node_modules/@redwoodjs/codemods/dist/codemods/v2.3.x/tsconfigForRouteHooks/tsconfigForRouteHooks.yargs.js
- /Users/dac09/.npm/_npx/6af5e84efc8d7cdf/node_modules/yargs/index.cjs
- /Users/dac09/.npm/_npx/6af5e84efc8d7cdf/node_modules/@redwoodjs/codemods/dist/codemods.js

Will create a followup PR to make sure ts is a dependency.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release:chore This PR is a chore (means nothing for users)
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

None yet

3 participants