Skip to content

Commit

Permalink
fix(amplify-cli-core): use build script for overrides (#13858)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
brianlenz authored Jan 31, 2025
1 parent 6715c82 commit 30c9f0c
Showing 1 changed file with 1 addition and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -93,17 +93,7 @@ export const buildOverrideDir = async (cwd: string, destDirPath: string): Promis
const tsConfigSampleFilePath = path.join(__dirname, '..', '..', 'resources', 'overrides-resource', 'tsconfig.resource.json');
fs.writeFileSync(tsConfigDestFilePath, fs.readFileSync(tsConfigSampleFilePath));

// get locally installed tsc executable

const localTscExecutablePath = path.join(cwd, 'node_modules', '.bin', 'tsc');

if (!fs.existsSync(localTscExecutablePath)) {
throw new AmplifyError('MissingOverridesInstallationRequirementsError', {
message: 'TypeScript executable not found.',
resolution: 'Please add it as a dev-dependency in the package.json file for this resource.',
});
}
execa.sync(localTscExecutablePath, [`--project`, `${tsConfigDestFilePath}`], {
execa.sync(packageManager.executable, [`run`, `build`, `--project`, `${tsConfigDestFilePath}`], {
cwd: tsConfigDir,
stdio: 'pipe',
encoding: 'utf-8',
Expand Down

0 comments on commit 30c9f0c

Please sign in to comment.