babel / babel/minify

Build Failure with Liferay CLI on React Portlets Regardless of Node.js Version

Open
#1,053 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
4.4k
Forks
217
PR merge metrics
No merged PRs in 30d

Description

# Build Failure with Liferay CLI for React Portlets

## Issue Description
Attempting to build a new React Portlet using Liferay CLI fails irrespective of the Node.js version. This issue significantly hampers the development processes for teams using Liferay CLI to manage React Portlets.

## Steps to Reproduce
1. **Environment Setup**: Clone a standard Liferay CLI React Portlet project.
2. **Install Dependencies**: Run `npm install` to install necessary packages.
3. **Build Command**: Execute `npm run build` or `liferay build`.

## Actual Output
The build process fails, outputting the following error in the terminal:
\```
Error: ---\src\AppComponent.js: Binding not found for ReferencedIdentifier "AppComponent" present in "AssignmentExpression".
\```

## Expected Output
The build process should complete successfully without errors, indicating the project was built correctly.

## Debugging Steps Undertaken
- **Temporary Mitigation**: Replacing `package-lock.json` with a previous version bypasses the error temporarily.
- **Node.js Versions Tested**: Multiple, confirming the issue is not related to Node.js itself.

## Minimal Code to Reproduce the Bug
\```js
// Standard setup code for Liferay CLI React Portlet as generated by the CLI
\```

## Stack Trace
\```
Error: C:\Users\frederick.bosa\Downloads\failed-build\src\AppComponent.js: Binding not found for ReferencedIdentifier "AppComponent" present in "AssignmentExpression".
at ReferencedIdentifier (C:\Users\frederick.bosa\Downloads\failed-build\node_modules\babel-plugin-minify-mangle-names\lib\index.js:199:19)
\```

## Configuration
- **babel-minify configuration**: Default as configured by Liferay CLI.
- **.babelrc**: Not manually adjusted, uses Liferay CLI defaults.

## Use with Other Presets/Plugins
- No additional babel presets or plugins were manually included beyond the default Liferay setup.

## Environment
- **Build Tools**: Liferay CLI
- **Module Bundlers and Task Runners**: Utilized within Liferay's standard environment settings.

## Additional Details
- **File Links** (if applicable):
- [Success Terminal.txt](https://github.com/user-attachments/files/18025802/Success.Terminal.txt)
- [package-lock-success.json](https://github.com/user-attachments/files/18025803/package-lock-success.json)
- [Failed Terminal.txt](https://github.com/user-attachments/files/18025804/Failed.Terminal.txt)
- [package-lock-failed.json](https://github.com/user-attachments/files/18025805/package-lock-failed.json)

## Conclusion
The recurring issue points towards a potential compatibility or configuration problem within the minification process utilized by Liferay's build tools, possibly related to babel-plugin-minify. The replacement of `package-lock.json` suggests dependency conflicts or specific versions causing the failure.

Contributor guide

Open the contributing guide

Research direction

Reproduce the failure in a standard Liferay CLI React Portlet with npm install followed by npm run build or liferay build. Start at babel-plugin-minify-mangle-names/lib/index.js, especially the ReferencedIdentifier location in the stack trace, and compare the successful and failed package-lock.json files. Done means the reported project builds without the Binding not found error and the failure has a regression test.

Written by the indexing model from the issue text.

Assessment

Tech stack
babel, javascript, node.js
Domain
build-system, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.