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

fix(amplify-cli-core): use build script for overrides #13858

Merged
merged 4 commits into from
Jan 31, 2025

Conversation

brianlenz
Copy link
Contributor

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.

Description of changes

Remove hard-coded dependency on node_modules/.bin/tsc for overrides to instead use the build script from package.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 and amplify push locally. The commands were failing on Amplify CLI 12.12.4, and it succeeds with these changes in place (via amplify-dev).

Checklist

  • PR description included
  • yarn test passes

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

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.

#11889
@brianlenz
Copy link
Contributor Author

@josefaidt sorry to pester, but any chance this can get some attention? Would love to be able to stop using custom builds of the CLI! Thanks! 🙏

@brianlenz
Copy link
Contributor Author

@sobolk any chance this can get visibility? I believe it's a straight-forward and sensible change, but I'm happy to update if there's an alternative approach that would be preferred by the team. Thank you 🙏

@brianlenz
Copy link
Contributor Author

Thanks, @sobolk! If you want to add feature parity, there is #11854 which has a nearly identical fix for custom-resources.

@sobolk
Copy link
Member

sobolk commented Jan 31, 2025

Thanks, @sobolk! If you want to add feature parity, there is #11854 which has a nearly identical fix for custom-resources.

I did see that. The #11854 is a bit out of date, we'll need to rebase it or open new PR.

@sobolk sobolk merged commit 30c9f0c into aws-amplify:dev Jan 31, 2025
6 checks passed
@brianlenz brianlenz deleted the fix_override_tsc_script branch January 31, 2025 21:00
sobolk added a commit to sobolk/amplify-cli that referenced this pull request Jan 31, 2025
sobolk added a commit that referenced this pull request Jan 31, 2025
brianlenz added a commit to brianlenz/amplify-cli that referenced this pull request Feb 1, 2025
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 aws-amplify#11854, which is for custom resources.

This is an improvement over my previous PR in aws-amplify#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` 💪

aws-amplify#11889
sobolk added a commit that referenced this pull request Feb 3, 2025
* fix(amplify-cli-core): use build script properly for overrides

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

* fix(amplify-cli-core): only include -- for npm

Tweaked the implementation slightly so that the `--` arg is only
passed for `npm` since it doesn't actually work with `yarn`.

#11889

* fix(amplify-cli-core): new packageManner runner

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

* fix: update api

---------

Co-authored-by: Kamil Sobol <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants