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

Minification failed with error #890

Closed
pg-ey opened this issue Oct 26, 2023 · 15 comments
Closed

Minification failed with error #890

pg-ey opened this issue Oct 26, 2023 · 15 comments
Labels
help provided Consulting given or question answered

Comments

@pg-ey
Copy link

pg-ey commented Oct 26, 2023

Expected Behavior

Build successful with minification

Current Behavior

Error Message:
Minification failed with error: 'return' outside of function in file get-own-property-symbols.js (line 11, col 1, pos 255)

Steps to Reproduce the Issue

1.- name: ui5-task-minifier
afterTask: minify
configuration:
html: true
css: true
json: true

Context

  • UI5 Module Version (output of ui5 --version when using the CLI): 3.6.0
  • Node.js Version: 18.14.2
  • npm Version: 9.5.2
  • OS/Platform: Windows 10
  • Browser (if relevant): Chrome

Log Output / Stack Trace

Error: Minification failed with error: 'return' outside of function in file get-own-property-symbols.js (line 11, col 1, pos 255)
at AsyncFunction.execMinification (file:///home/user/projects/bre-v3/app/node_modules/@ui5/cli/node_modules/@ui5/builder/lib/processors/minifierWorker.js:63:9)

@pg-ey pg-ey added bug Something isn't working needs triage Needs to be investigated and confirmed as a valid issue that is not a duplicate labels Oct 26, 2023
@flovogt
Copy link
Member

flovogt commented Oct 26, 2023

Hi @pg-ey,
thanks for opening this issue here. From the input you provide above I expect a return statement in get-own-property-symbols.js which is not correctly placed. This file might be a custom js file located in your application and not provided by an UI5 library.
Could you please check this file?
If the issue still appears after you have fixed the return statement. Feel free to share the project with us, so we can have a deeper look.

@flovogt flovogt added information required Further information is required and removed needs triage Needs to be investigated and confirmed as a valid issue that is not a duplicate labels Oct 26, 2023
@pg-ey
Copy link
Author

pg-ey commented Oct 26, 2023

Hi @flovogt , thanks for your response.
I don't have any custom js file with the name get-own-property-symbols.js.
However, when I build my app excluding minify, it works fine.

I have a doubt that there is a reference to getOwnPropertySymbols in one of the @ui5/cli dependencies which is causing the issue at the time of minifying.

@flovogt
Copy link
Member

flovogt commented Oct 26, 2023

Could you share your ui5.yaml and package.json or even better the whole application?

@flovogt
Copy link
Member

flovogt commented Oct 26, 2023

Do you have included https://github.com/es-shims/get-own-property-symbols into your project?

@pg-ey
Copy link
Author

pg-ey commented Oct 26, 2023

Do you have included https://github.com/es-shims/get-own-property-symbols into your project?

No, I haven't included this.

@pg-ey
Copy link
Author

pg-ey commented Oct 26, 2023

Could you share your ui5.yaml and package.json or even better the whole application?

Adding package.json and ui5.yaml here
package (1).json
ui5.zip

@flovogt
Copy link
Member

flovogt commented Oct 26, 2023

  1. Remove the ui5 section in the package.json - not needed any longer with UI5 Tooling v3
  2. I wonder if you need @sap/ui5-builder-webide-extension at all. Could please remove this dependency and also the tasks used in the ui5.yaml and see if the build works as expected

@RandomByte
Copy link
Member

Also, could you please share the full build log? Ideally after adding the --verbose parameter.

@pg-ey
Copy link
Author

pg-ey commented Oct 26, 2023

  1. Remove the ui5 section in the package.json - not needed any longer with UI5 Tooling v3
  2. I wonder if you need @sap/ui5-builder-webide-extension at all. Could please remove this dependency and also the tasks used in the ui5.yaml and see if the build works as expected

Removing the 'ui5' section in the package.json has worked.
I will keep the @sap/ui5-builder-webide-extension till I figure out an alternative for my custom tasks.

Thanks @flovogt for the help.

@pg-ey pg-ey closed this as completed Oct 26, 2023
@flovogt flovogt added help provided Consulting given or question answered and removed bug Something isn't working information required Further information is required labels Oct 26, 2023
@VinayCh0wdary
Copy link

I'm having the same issue, I did try removing the ui5 section in the package.json getting the same error even doing that.
Screenshot 2024-08-06 at 6 02 13 PM

@flovogt
Copy link
Member

flovogt commented Aug 6, 2024

I'm having the same issue, I did try removing the ui5 section in the package.json getting the same error even doing that. Screenshot 2024-08-06 at 6 02 13 PM

@VinayCh0wdary Please open a new issue and share your project details with us, so we can have a deeper analysis.

@Vest
Copy link

Vest commented Jan 9, 2025

@VinayCh0wdary I think, I know where the error comes from. It seems that the builder is stupid, but straightforward - it scans all the *.js files in webapp/. If (by any chance) you have a node.js application there with node_modules/ inside, the minifier tries to process all *.js files. And if they don't meet minifier's rules (e.g., there must be no return; in the global scope), it crashes with a useless error.

The error handling will be better if it display me the file path and not just a file name. After I debugged it, I found out that you have to exclude node.js resources from the builder folder. I have fixed my error (there was a package has-symbols in /webapp/.../node_modules/...) with the following configuration in ui5.yaml:

builder:
    resources:
        excludes:
            - "**/node_modules/**"
            - "**/localService/**"

@flovogt
Copy link
Member

flovogt commented Jan 10, 2025

Thanks a lot @Vest for your input. I can confirm there should be no "node_modules" inside the "webapp" folder. In most scenarios I am aware of having a "node_modules" folder inside the "webapp" folder happens unintended. So, it should be removed.

RandomByte added a commit to SAP/ui5-builder that referenced this issue Jan 10, 2025
RandomByte added a commit to SAP/ui5-builder that referenced this issue Jan 10, 2025
…or messsage

As suggested by Vest in SAP/ui5-tooling#890 (comment)

This should make it easier to identify the resource that is causing an error in the minify task.
RandomByte added a commit to SAP/ui5-builder that referenced this issue Jan 10, 2025
…or messsage

As suggested by Vest in SAP/ui5-tooling#890 (comment)

This should make it easier to identify the resource that is causing an error in the minify task.
@RandomByte
Copy link
Member

The error handling will be better if it display me the file path and not just a file name.

@Vest thanks for the suggestion, we'll fix this in one of the next releases via SAP/ui5-builder#1102 👍

@Vest
Copy link

Vest commented Jan 10, 2025

@flovogt I didn't know this, before I executed ui5 build. I have created a nodejs module in webapp/ because I developed a small proxy as a part of localService/ (it contained sample data for JS-based MockServer). That's why I decided to simply have my pet-proxy there.
I know that it doesn't sound right to have node_modules inside... otherwise, I wouldn't help you with this bug 😄

@RandomByte thanks for the feature. The more verbose error is, the easier will it be to solve it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help provided Consulting given or question answered
Projects
None yet
Development

No branches or pull requests

5 participants