aws-amplify / aws-amplify/amplify-hosting

Monorepo create react app build fails on re deploy

Open
#3,197 4 comments 0 reactions 0 assignees View on GitHub
bug monorepo pending-triage
Dominant language
Dockerfile
Stars
481
Forks
123
PR merge metrics
No merged PRs in 30d

Description

### Before opening, please confirm:

- [X] I have checked to see if my question is addressed in the [FAQ](https://github.com/aws-amplify/amplify-hosting/blob/master/FAQ.md).
- [X] I have [searched for duplicate or closed issues](https://github.com/aws-amplify/amplify-hosting/issues?q=is%3Aissue+).
- [X] I have read the guide for [submitting bug reports](https://github.com/aws-amplify/amplify-hosting/blob/master/CONTRIBUTING.md).
- [X] I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.
- [X] I have removed any sensitive information from my code snippets and submission.

### App Id

d36ng4ja7wbcyq

### AWS Region

ap-south-1

### Amplify Hosting feature

Deployments, Frontend builds, Monorepo

### Describe the bug

We have a mono repo setup with react app and typescript. Example repo structure
```
Root
- web
- shared
```
`web` is built with react app and it has dependency on `shared` package as well. When we connect a branch in amplify console and deploy a build it works fine. But when we redeploy or push some code changes to the branch, the build fails with following error
```
Module parse failed: Unexpected token (2:34)
File was processed with these loaders:
* ../node_modules/source-map-loader/dist/cjs.js
You may need an additional loader to handle the result of these loaders.
| const DELIMITER = "---";
> export const stringToBase64 = (str: string): string =>
| Buffer.from(str).toString("base64");
|
```
The referenced file is in `shared` package and somehow after the first build, `web` is not able to resolve the typescript types from `shared` package.

### Expected behavior

Re build/deploy should work always

### Reproduction steps

Redeploy the successful build from [here](https://ap-south-1.console.aws.amazon.com/amplify/home?code=e3e56c6c68b2e33ad8e5®ion=ap-south-1#/d36ng4ja7wbcyq/main/2)
Fails to deploy

### Build Settings

_No response_

### Log output

```
# Put your logs below this line

```

### Additional information

_No response_

Contributor guide

Open the contributing guide

Research direction

Start with the reported Root/web/shared monorepo structure and reproduce the successful deployment followed by a redeploy using the linked Amplify deployment. Trace why the shared package's TypeScript source reaches the web build and compare the build behavior across deployments; done means repeated deployments succeed without the reported Module parse failed error.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, react, typescript
Domain
build-system, ci-cd, cloud, frontend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.