Skip to content

Conversation

@UnschooledGamer
Copy link
Member

This pull Request attempts to migrate away from webpack, instead it's using rspack.

Pull Request follows https://rspack.rs/guide/migration/webpack for migration guidance.

A significant amount of code was written by AI, including the utils/custom-loaders/html-tag-jsx-loader.js Loader to improve the performance and outputs.

The code was 100% tested on my device.

With the dev mode compilation having (initial run):

webpack 5.103.0 - 28743 ms
rspack - 11.60s-13.00s (secs) 
(gh codespaces): 6.37s (secs)

Runs after the initial run are much faster, i.e 6s, 8s, etc.

@gemini-code-assist
Copy link

Summary of Changes

Hello @UnschooledGamer, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request focuses on a major overhaul of the project's build infrastructure by transitioning from Webpack to Rspack. The primary goal is to achieve substantial improvements in development compilation speed. This migration involves updating dependencies, configuring Rspack with new module rules, and implementing a custom loader to handle JSX transformations specifically for the html-tag-js library, leveraging modern tools like SWC for efficient code transpilation.

Highlights

  • Build System Migration: The project has been migrated from Webpack to Rspack, a Rust-based bundler, following the official Rspack migration guide.
  • Performance Improvement: Dev mode compilation time has significantly improved. Initial runs decreased from ~28 seconds with Webpack to 11-13 seconds with Rspack, and subsequent runs are even faster, averaging 6-8 seconds.
  • Custom JSX Transformation: A new custom Rspack loader, html-tag-jsx-loader.js, has been introduced. This loader transforms JSX syntax into html-tag-js tag() function calls using Babel's parser and transformer, optimizing for the html-tag-js library.
  • SWC Integration: The build process now utilizes builtin:swc-loader for efficient transpilation of TypeScript, TSX, and ES6+ JavaScript files, replacing previous Babel/TS-loader configurations.
  • AI-Assisted Development: A significant portion of the new code, including the custom html-tag-jsx-loader.js, was generated with the assistance of AI to enhance performance and output quality.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request successfully migrates the build system from Webpack to Rspack, which should yield significant performance improvements as noted in the description. The new rspack.config.js and the custom JSX loader are well-structured. However, I've identified a few issues that need attention. There's a critical bug in the Rspack configuration regarding loader order for .tsx files that will likely break the build. Additionally, there are some opportunities for cleanup and correctness improvements in the Rspack config and the custom loader. I also noticed an unrelated dependency removal in package.json that could have unintended side effects and should be clarified.

"babel-loader": "^10.0.0",
"com.foxdebug.acode.rk.auth": "file:src/plugins/auth",
"com.foxdebug.acode.rk.customtabs": "file:src/plugins/custom-tabs",
"com.foxdebug.acode.rk.exec.proot": "file:src/plugins/proot",

Choose a reason for hiding this comment

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

high

The dependency com.foxdebug.acode.rk.exec.proot has been removed from devDependencies. This change seems unrelated to the migration to Rspack. This plugin appears to be related to proot execution, and removing it might break functionality for non-F-Droid builds. Was this removal intentional? If so, it would be beneficial to mention it in the pull request description with a justification.

Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

Greptile Overview

Greptile Summary

This PR migrates the build system from webpack to rspack for improved build performance. The changes include:

  • New rspack configuration replacing webpack.config.js with rspack.config.js
  • Custom JSX loader (html-tag-jsx-loader.js) using Babel's parser API to transform JSX to tag() calls for html-tag-js
  • Build script update to invoke rspack instead of webpack
  • Performance improvement from ~28s (webpack) to 6-13s (rspack) for initial builds

The rspack configuration uses builtin SWC loader for TypeScript/JavaScript transpilation and a custom loader to transform JSX syntax to html-tag-js tag() function calls. Module CSS files are processed differently from regular CSS using the .m. prefix pattern.

Critical Issues Found:

  1. TypeScript loader order will cause JSX to be transformed by SWC before the custom loader can process it
  2. Invalid Babel parser plugin names will cause the parser to fail

These issues indicate the code was not successfully tested as claimed, since both would cause build failures.

Confidence Score: 0/5

  • Not safe to merge - contains critical bugs that will cause build failures
  • Two P0 bugs will definitely cause the build to fail: (1) TypeScript/TSX files will have JSX transformed by SWC before the custom loader can process it, breaking the html-tag-js transformation; (2) Invalid Babel parser plugin names will cause parsing errors. The PR description claims "100% tested" but these bugs prove otherwise - the build cannot succeed with this code.
  • rspack.config.js (loader ordering), utils/custom-loaders/html-tag-jsx-loader.js (parser plugins)

Important Files Changed

File Analysis

Filename Score Overview
rspack.config.js 1/5 Migration from webpack to rspack with new build configuration. Contains critical loader ordering bug in TypeScript/TSX processing that will cause JSX to be transformed before the custom loader can process it.
utils/custom-loaders/html-tag-jsx-loader.js 2/5 Custom loader using Babel API to transform JSX to tag() calls. Contains bug with invalid parser plugin names that will cause parsing to fail.
utils/scripts/build.sh 5/5 Updated build script to use rspack command instead of webpack. Change is minimal and correct - only script2 variable updated from 'webpack' to 'rspack'.
package.json 4/5 Added rspack packages, kept webpack for compatibility. Removed proot plugin from devDependencies (matches build.sh conditional logic).
package-lock.json 5/5 Lockfile updated to reflect dependency changes including rspack packages and their transitive dependencies.

Sequence Diagram

sequenceDiagram
    participant Build as Build Script
    participant Rspack as Rspack
    participant SWC as SWC Loader
    participant Custom as html-tag-jsx-loader
    participant Babel as Babel Parser/Transform
    
    Build->>Rspack: rspack --mode development
    Rspack->>Rspack: Load rspack.config.js
    
    Note over Rspack: Process .tsx files
    Rspack->>SWC: Load file (executes FIRST)
    SWC->>SWC: Parse TypeScript + JSX (tsx: true)
    SWC->>SWC: Transform JSX ❌ (should preserve)
    SWC->>Custom: Pass transformed code
    Custom->>Babel: Parse with Babel
    Babel-->>Custom: Invalid parser plugins ❌
    
    Note over Rspack: Process .js files
    Rspack->>Custom: Load file (executes FIRST)
    Custom->>Babel: Parse with invalid plugins ❌
    Babel-->>Custom: Error
    
    Note over Rspack: Expected flow for .tsx
    Rspack->>SWC: Should preserve JSX
    SWC->>Custom: Pass TypeScript→JS with JSX intact
    Custom->>Babel: Transform JSX to tag()
    Babel->>Custom: Return transformed code
    Custom->>Rspack: JavaScript output
Loading

@UnschooledGamer
Copy link
Member Author

@greptileai

@greptile-apps
Copy link

greptile-apps bot commented Jan 10, 2026

Greptile Overview

Greptile Summary

This PR migrates the build system from Webpack to Rspack for improved build performance. The changes add Rspack dependencies, create a new rspack.config.js configuration, implement a custom html-tag-jsx-loader.js to transform JSX to html-tag-js tag() calls using Babel's parser/transformer, and update the build script.

Critical Issues

Build-Breaking Syntax Errors:

  • rspack.config.js has duplicate opening braces on lines 14-15 and 65-66, causing immediate JavaScript parsing errors that will prevent the build from running at all.

Functional Logic Errors:

  • JSXText whitespace handling: The custom loader doesn't trim whitespace from JSX text nodes (line 292), which will include all newlines and indentation from source code in string literals, breaking the output.
  • Incorrect SWC parser configuration: TypeScript files are configured with tsx: true in SWC (line 21), but the custom loader runs first and already transforms JSX. This causes SWC to try parsing already-transformed code as JSX, leading to incorrect output or failures.
  • Import detection too narrow: The check for existing tag imports only handles exact string matches of import tag from 'html-tag-js', missing variations like named imports, aliases, or require() syntax. This will cause duplicate import errors.
  • JSX detection false positives: The regex pattern /<[A-Z][\w]*[\s/>]|<[a-z]+[\s\/>]/ matches comparison operators like x < A and generic types like Map<Array<string>>, causing unnecessary parsing attempts.

Performance & Architecture

The migration from Webpack to Rspack with SWC should provide significant performance improvements (PR description shows ~50% faster initial builds). The custom loader approach is reasonable for the html-tag-js transformation, though it would benefit from more robust edge case handling.

The loader chain order (custom loader → SWC) is correct (loaders execute right-to-left), but the SWC configuration doesn't account for receiving already-transformed JSX, which needs to be fixed.

Confidence Score: 0/5

  • This PR cannot be merged - it contains critical syntax errors that prevent the build from running at all, plus multiple logic errors that will cause runtime failures.
  • Score of 0 (critical issues) is given because: (1) rspack.config.js has duplicate opening braces causing immediate JavaScript parsing errors - the build will not even start; (2) JSXText whitespace handling bug will corrupt all JSX text content; (3) SWC parser misconfiguration will cause transformation failures or incorrect output; (4) Import detection logic will create duplicate imports. These are not minor issues - they are fundamental problems that make the code non-functional.
  • Critical attention needed: rspack.config.js (syntax errors on lines 14-15, 65-66, and parser misconfiguration on lines 10-40) and utils/custom-loaders/html-tag-jsx-loader.js (whitespace handling on line 292, import detection on lines 44-46)

Important Files Changed

File Analysis

Filename Score Overview
rspack.config.js 0/5 Critical syntax errors: duplicate opening braces on lines 14-15 and 65-66 will cause immediate build failure. Also missing CodeMirror exclusion that was in original webpack config.
utils/custom-loaders/html-tag-jsx-loader.js 2/5 JSXText handling doesn't trim whitespace (line 292), causing incorrect output. JSX detection regex (line 25) may have false positives. Otherwise functional custom loader implementation.
utils/scripts/build.sh 5/5 Simple change from webpack to rspack command on line 83. No issues found.
package.json 5/5 Adds @rspack/cli and @rspack/core dependencies. Clean addition, no issues.

Sequence Diagram

sequenceDiagram
    participant Dev as Developer
    participant Script as build.sh
    participant Config as rspack.config.js
    participant Rspack as Rspack Bundler
    participant CustomLoader as html-tag-jsx-loader.js
    participant SWC as SWC Loader
    participant Output as www/build/

    Dev->>Script: Run build.sh
    Script->>Script: Parse arguments (mode, app, etc)
    Script->>Script: Configure fdroid settings
    Script->>Config: node ./utils/config.js
    Script->>Rspack: rspack --mode [development|production]
    
    Rspack->>Config: Load configuration
    Config->>Rspack: Return module rules & plugins
    
    Note over Rspack: Process .tsx? files
    Rspack->>CustomLoader: Pass .tsx? source (right-to-left)
    CustomLoader->>CustomLoader: Check for JSX syntax
    alt Has JSX
        CustomLoader->>CustomLoader: Parse with @babel/parser
        CustomLoader->>CustomLoader: Transform JSX to tag() calls
        CustomLoader->>CustomLoader: Add import tag if needed
        CustomLoader->>SWC: Return transformed code
    else No JSX
        CustomLoader->>SWC: Pass through unchanged
    end
    
    SWC->>SWC: Parse TypeScript (tsx: true)
    SWC->>SWC: Transform to ES2015
    SWC->>Rspack: Return transpiled code
    
    Note over Rspack: Process .m?js files
    Rspack->>Rspack: Check oneOf rules
    alt In node_modules
        Rspack->>SWC: Process with SWC only
        SWC->>Rspack: Return transpiled code
    else Source files
        Rspack->>CustomLoader: Pass source
        CustomLoader->>CustomLoader: Transform JSX to tag()
        CustomLoader->>SWC: Return transformed code
        SWC->>Rspack: Return transpiled code
    end
    
    Note over Rspack: Process CSS/SCSS, assets, etc
    Rspack->>Rspack: Apply remaining loaders
    Rspack->>Output: Write bundled files
    
    Script->>Script: cordova build android
Loading

Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

6 files reviewed, 6 comments

Edit Code Review Agent Settings | Greptile

UnschooledGamer and others added 8 commits January 11, 2026 20:28
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
@UnschooledGamer
Copy link
Member Author

@greptileai

Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

7 files reviewed, 7 comments

Edit Code Review Agent Settings | Greptile

UnschooledGamer and others added 4 commits January 11, 2026 22:21
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
@UnschooledGamer
Copy link
Member Author

@greptileai All seems good now.

@greptile-apps
Copy link

greptile-apps bot commented Jan 11, 2026

Great to hear! 🎉 The migration from webpack to rspack looks solid - that's a significant performance improvement you're seeing (28+ seconds down to 6-13 seconds). The custom HTML tag JSX loader and the overall rspack configuration appear to be working well.

Thanks for thoroughly testing this on your device and providing those performance benchmarks. The improvement should make development much more pleasant for the team.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant