Skip to content

[Proposal] use rspack, pnpm to improve assets build time #85

@utnapischtim

Description

@utnapischtim

Motivation

Improve the time a invenio-cli assets build needs to build the assets.

Summary

  • create a create_cli app as small as possible to load as fast as possible
  • move from webpack to rspack to improve assets build time from around >50sec to <10sec
  • move from npm to pnpm to improve installation time from >60sec to <11sec
  • combined improvement from around 3 minutes to 22seconds

PR's

open problems

pdfjs

the invenio-previewer PR is not only necessary to fix bugs in the pdf viewer but also necessary because the current used version of pdfjs couldn't be build with rspack. Further upgrading to the newest version fixes the build error but doesn't produce a asset which works in the browser. (without testing i hope that this PR fixes both problems)

not yet a PR because it needs some discussion npm -> pnpm, webpack -> rspack

how could we move from npm to pnpm? https://github.com/inveniosoftware/pynpm/blob/1d16a60df39ca5ba23feeca9e3142be35cf69c92/pynpm/package.py#L31 chaning the default value for npm_bin seems the easiest solution but could irritate users of that package. the only other option is to give it to the construction: https://github.com/inveniosoftware/pywebpack/blob/fcb464a46bb88cbb7731689e9869354536fe4df8/pywebpack/project.py#L48 which is also not that easy, because we are in the webpack configuration, but we are moving from webpack to rspack. so should we only change from webpack to rspack and keep the whole pywebpack package, or should we implement that completely new to have the wording correct?

NOTE: pnpm install needs the --shamefully-hoist parameter otherwise the peer dependencies are not found by rspack

test out the configuration for invenio-cli assets watch

not yet tested

with_appcontext

most of the code copied over to the invenio-cli PR has been copied because of the with_appcontext problem. the code in the various packages are based on current_app which needs the app context. this has to be solved somehow to make the rewrite in invenio-cli possible

possible solutions (needs more thinking)

rename Webpack* classes to Asset* classes
move pynpm and pywebpack functionality to invenio-assets and rename the class to the problem they solve without the tool in its name. reason to move: the functionality is used exclusively there (to be proved)
add with_appcontext decorator to the invenio-cli assets build cli command to not have to refactor a lot of code

NOTE: replacing npm with pnpm is still a little bit difficult if pynpm should not be changed? the problem is the parameter --shamefully-hoist which is necessary that pnpm install works

big problem in my eyes at the moment

flask has to be installed by invenio-cli which is not the case at the moment!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Proposal: PendingProposal for new RFC, pending triage

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions