Skip to content

fix: Check for changes in project frontend files#15992

Merged
mshabarov merged 21 commits into
mainfrom
rebudle-upon-changes-in-ts
Feb 27, 2023
Merged

fix: Check for changes in project frontend files#15992
mshabarov merged 21 commits into
mainfrom
rebudle-upon-changes-in-ts

Conversation

@mshabarov

@mshabarov mshabarov commented Feb 22, 2023

Copy link
Copy Markdown
Contributor

Extends logic for dev-bundle re-build: it detects any project's frontend files modifications (create or delete) and re-builds bundle if such, for instance if Lit templates are modified. Imported files are also checked for modification.

Fixes #15970

@github-actions

github-actions Bot commented Feb 22, 2023

Copy link
Copy Markdown

Test Results

   948 files  +1     948 suites  +1   55m 20s ⏱️ - 1m 19s
5 997 tests +5  5 962 ✔️ +5  35 💤 ±0  0 ±0 
6 251 runs  +3  6 209 ✔️ +3  42 💤 ±0  0 ±0 

Results for commit 43a5ab9. ± Comparison against base commit 92610a7.

♻️ This comment has been updated with latest results.

@vaadin-bot vaadin-bot added +0.0.1 and removed +1.0.0 labels Feb 22, 2023
@mshabarov mshabarov requested a review from Artur- February 23, 2023 08:08
var filename;
if(line.includes('?')) {
filename = line.substring(line.indexOf("generated"), line.lastIndexOf('?'));
generatedImports.filter((line: string) => line.startsWith("Frontend/")).forEach((line: string) => {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO this should not at all look at the generated imports file. It should look at which files were used in the compilation. Now it can only react to the files you have imported from Java and not at all to the files those files in turn import. E.g. if you have

import './another.ts';

in your index.ts, then no changes to another.ts will ever cause a rebuild

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, makes sense. I'm looking into it.

@mshabarov mshabarov Feb 24, 2023

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So I did it in the following way:

  • Frontend compiled TS/JS files are collected from modules in the statsExtracterPlugin() and placed into stats.json:frontendHashes during bundle build.
  • Flow takes files listed in frontendHashes and checks the presence of the files in the frontend folder, during app start-up.
  • Then it checks the hash of the file if it exists, otherwise it considered as deleted.

…in-ts

# Conflicts:
#	flow-server/src/main/java/com/vaadin/flow/server/frontend/TaskRunDevBundleBuild.java
#	flow-server/src/main/resources/vite.generated.ts
#	flow-server/src/test/java/com/vaadin/flow/server/frontend/TaskRunDevBundleBuildTest.java
for (Map.Entry<String, String> themeHash : packagedThemeHashes
.entrySet()) {
if (!hashesInStats.hasKey(themeHash.getKey())) {
getLogger().info(

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

7% of developers fix this issue

PATH_TRAVERSAL_IN: This API (java/io/File.(Ljava/io/File;Ljava/lang/String;)V) reads a file whose location might be specified by user input


ℹ️ Expand to see all @sonatype-lift commands

You can reply with the following commands. For example, reply with @sonatype-lift ignoreall to leave out all findings.

Command Usage
@sonatype-lift ignore Leave out the above finding from this PR
@sonatype-lift ignoreall Leave out all the existing findings from this PR
@sonatype-lift exclude <file|issue|path|tool> Exclude specified file|issue|path|tool from Lift findings by updating your config.toml file

Note: When talking to LiftBot, you need to refresh the page to see its response.
Click here to add LiftBot to another repo.


Help us improve LIFT! (Sonatype LiftBot external survey)

Was this a good recommendation for you? Answering this survey will not impact your Lift settings.

[ 🙁 Not relevant ] - [ 😕 Won't fix ] - [ 😑 Not critical, will fix ] - [ 🙂 Critical, will fix ] - [ 😊 Critical, fixing now ]

@mshabarov mshabarov requested a review from Artur- February 24, 2023 14:44
@mshabarov mshabarov requested a review from caalador February 27, 2023 07:18
…in-ts

# Conflicts:
#	flow-server/src/test/java/com/vaadin/flow/server/frontend/TaskRunDevBundleBuildTest.java
Comment thread flow-server/src/main/resources/vite.generated.ts Outdated
Comment thread flow-server/src/main/resources/vite.generated.ts Outdated
Comment thread flow-tests/test-express-build/pom.xml Outdated
@mshabarov mshabarov requested a review from caalador February 27, 2023 12:32
@sonarqubecloud

Copy link
Copy Markdown

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@sonatype-lift

sonatype-lift Bot commented Feb 27, 2023

Copy link
Copy Markdown

🛠 Lift Auto-fix

Some of the Lift findings in this PR can be automatically fixed. You can download and apply these changes in your local project directory of your branch to review the suggestions before committing.1

# Download the patch
curl https://lift.sonatype.com/api/patch/github.com/vaadin/flow/15992.diff -o lift-autofixes.diff

# Apply the patch with git
git apply lift-autofixes.diff

# Review the changes
git diff

Want it all in a single command? Open a terminal in your project's directory and copy and paste the following command:

curl https://lift.sonatype.com/api/patch/github.com/vaadin/flow/15992.diff | git apply

Once you're satisfied, commit and push your changes in your project.

Footnotes

  1. You can preview the patch by opening the patch URL in the browser.

@mshabarov mshabarov merged commit 8074511 into main Feb 27, 2023
@mshabarov mshabarov deleted the rebudle-upon-changes-in-ts branch February 27, 2023 13:04
vaadin-bot pushed a commit that referenced this pull request Feb 27, 2023
Extends logic for dev-bundle re-build: it detects any project's frontend files modifications (create or delete) and re-builds bundle if such, for instance if Lit templates are modified. Imported files are also checked for modification.

Fixes #15970
vaadin-bot added a commit that referenced this pull request Feb 27, 2023
Extends logic for dev-bundle re-build: it detects any project's frontend files modifications (create or delete) and re-builds bundle if such, for instance if Lit templates are modified. Imported files are also checked for modification.

Fixes #15970

Co-authored-by: Mikhail Shabarov <61410877+mshabarov@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Vaadin 24.0.0.beta2: Frontend bundle not rebuilt when changing .ts file

4 participants