-
Notifications
You must be signed in to change notification settings - Fork 822
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
fix(amplify-cli-core): use build script properly for overrides #14093
fix(amplify-cli-core): use build script properly for overrides #14093
Conversation
Updated the TypeScript compilation of overrides so that it doesn't require `node_modules/.bin/tsc`. Instead, it simply relies on the `build` script to execute `tsc`. This is more flexible and can support alternative setups w/ hoisting (e.g. via Yarn workspaces). This is an override corollary fix to #11854, which is for custom resources. This is an improvement over my previous PR in #13858 in that it works with any package manager by ensuring the `--project` and `tsconfig.json` files are passed through to the `tsc` script. The previous implementation didn't work with `npm` because it doesn't pass through additional args like `yarn` does. The fix was easy: simply separate the build run with `--` so that the remaining args are treated as positional for the `tsc` script. I've confirmed the fix works with both `yarn` and `npm` 💪 #11889
@sobolk it's working now with It's worth noting that #11854 does not have the same issue because it doesn't pass a custom If there's anything else I can help with, please let me know! Thank you 🙏 |
Tweaked the implementation slightly so that the `--` arg is only passed for `npm` since it doesn't actually work with `yarn`. #11889
@brianlenz I have slightly different solution in mind for this. Where we do not have dependency on Package managers have a way to run executables (
Therefore what I would suggest is to
|
@sobolk thanks for sticking with me and the recommendations here 🙏 I like your suggestions, so I'll take a crack at it! |
Added a new `runner` field to the PackageManager interface. The key difference here is npm's runner is actually `npx`, whereas yarn and pnpm just use the same executable as the runner. Updated both the override and custom-resources to use the runner to run tsc now instead of only looking in `node_modules`. #11889
@sobolk done! Check it out and let me know if you think it needs further tweaking 🙏 Tested with |
I'll test it on my end and I'll get back to you. |
Updated the TypeScript compilation of overrides so that it doesn't require
node_modules/.bin/tsc
. Instead, it simply relies on thebuild
script to executetsc
. This is more flexible and can support alternative setups w/ hoisting (e.g. via Yarn workspaces).This is an override corollary fix to #11854, which is for custom resources.
This is an improvement over my previous PR in #13858 in that it works with any package manager by ensuring the
--project
andtsconfig.json
files are passed through to thetsc
script. The previous implementation didn't work withnpm
because it doesn't pass through additional args likeyarn
does. The fix was easy: simply separate the build run with--
so that the remaining args are treated as positional for thetsc
script.I've confirmed the fix works with both
yarn
andnpm
💪Description of changes
Remove hard-coded dependency on
node_modules/.bin/tsc
for overrides to instead use thebuild
script frompackage.json
, which is more flexible.Issue #11889
Description of how you validated changes
Ran
yarn test
and all pre-commit hooks without issue.Tested
amplify build --debug
andamplify push
locally with bothyarn
andnpm
. The commands were failing withyarn
prior to these changes, and it succeeds with these changes in place (viaamplify-dev
).Checklist
yarn test
passesBy submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.