Skip to content

Replace rollup-plugin-license with rolldown-license-plugin#37130

Merged
silverwind merged 22 commits intogo-gitea:mainfrom
silverwind:remove-rollup-plugin-license
Apr 9, 2026
Merged

Replace rollup-plugin-license with rolldown-license-plugin#37130
silverwind merged 22 commits intogo-gitea:mainfrom
silverwind:remove-rollup-plugin-license

Conversation

@silverwind
Copy link
Copy Markdown
Member

@silverwind silverwind commented Apr 7, 2026

Replace rollup-plugin-license and wrap-ansi with rolldown-license-plugin, a zero-dependency plugin with async parallel I/O and built-in word wrapping.

  • Removes rollup-plugin-license (pulls in lodash, moment) and wrap-ansi from the dependency tree
  • License build time reduced by ~40% (370ms vs 640ms)
  • Added e2e test for licenses.txt

This PR was written with the help of Claude Opus 4.6

Remove the `rollup-plugin-license` dependency and replace it with a lightweight
inline Vite plugin that walks bundle chunks to collect third-party license info.

This eliminates `lodash` and `moment` as transitive production dependencies
(~10MB), and the custom plugin also discovers 7 additional bundled packages that
the old plugin was missing.

Co-Authored-By: Claude (Opus 4.6) <noreply@anthropic.com>
@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Apr 7, 2026
silverwind and others added 3 commits April 7, 2026 13:46
Co-Authored-By: Claude (Opus 4.6) <noreply@anthropic.com>
Co-Authored-By: Claude (Opus 4.6) <noreply@anthropic.com>
Co-Authored-By: Claude (Opus 4.6) <noreply@anthropic.com>
Co-Authored-By: Claude (Opus 4.6) <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR removes the rollup-plugin-license dependency and replaces it with a small inline Vite plugin that scans the build bundle to generate licenses.txt, aiming to reduce dependency surface area and address reported security issues in the rollup-based solution.

Changes:

  • Removed rollup-plugin-license from package.json and lockfile.
  • Added a custom licensesPlugin() in vite.config.ts that walks bundle modules, finds package roots, and writes public/assets/licenses.txt.
  • Updated pnpm-lock.yaml to reflect dependency graph changes after removing the rollup plugin (and related transitive updates).

Reviewed changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated 3 comments.

File Description
vite.config.ts Replaces rollup-based license generation with a custom Vite plugin that collects license text from bundled node_modules and Go license JSON.
package.json Drops the rollup-plugin-license dependency.
pnpm-lock.yaml Removes rollup-related packages and updates transitive dependencies after lockfile re-resolution.
Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread vite.config.ts Outdated
Comment thread vite.config.ts Outdated
Comment thread vite.config.ts Outdated
Extract to constant and align with Go regex `licenseRe` in
build/generate-go-licenses.go. Also matches UNLICENSE and COPYING.

Co-Authored-By: Claude (Opus 4.6) <noreply@anthropic.com>
@silverwind silverwind force-pushed the remove-rollup-plugin-license branch from 1840301 to d068779 Compare April 7, 2026 11:58
silverwind and others added 3 commits April 7, 2026 14:00
Co-Authored-By: Claude (Opus 4.6) <noreply@anthropic.com>
Co-Authored-By: Claude (Opus 4.6) <noreply@anthropic.com>
Co-Authored-By: Claude (Opus 4.6) <noreply@anthropic.com>
@GiteaBot GiteaBot added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels Apr 7, 2026
@silverwind
Copy link
Copy Markdown
Member Author

I'm considering extracting this to its own repo/npm module, given that I also have the same need in other projects and there's no suitable 0-dependency module available yet.

@silverwind silverwind marked this pull request as draft April 7, 2026 17:16
@silverwind silverwind marked this pull request as draft April 7, 2026 17:16
Replace inline license collection and wrap-ansi with rolldown-license-plugin
which provides async parallel I/O and a built-in word-wrap function. This
reduces license build time by ~40% (370ms vs 640ms).

Co-Authored-By: Claude (Opus 4.6) <noreply@anthropic.com>
@silverwind silverwind changed the title Replace rollup-plugin-license with custom Vite plugin Replace rollup-plugin-license with rolldown-license-plugin Apr 7, 2026
@silverwind silverwind marked this pull request as ready for review April 7, 2026 19:31
@silverwind
Copy link
Copy Markdown
Member Author

silverwind commented Apr 7, 2026

Done, extracted https://github.com/silverwind/rolldown-license-plugin. Build time is ~60% faster then on main branch, while producing more licenses in the output. wrap-ansi was also removed because we are not wrapping text with ansi escape codes, and it was a cause for slowness.

Notably, modules where no license files was found still render with empty text into licenses.txt, but that is the same behaviour as on main branch, so I kept it.

Add license validation matching main branch behavior. Use wrap()
directly in onDone callback instead of wrapText option.

Co-Authored-By: Claude (Opus 4.6) <noreply@anthropic.com>
Co-Authored-By: Claude (Opus 4.6) <noreply@anthropic.com>
Comment thread vite.config.ts Outdated
silverwind and others added 4 commits April 8, 2026 18:13
Signed-off-by: silverwind <me@silverwind.io>
Co-Authored-By: Claude (Opus 4.6) <noreply@anthropic.com>
Update to 2.2.0 which adds failOnViolation and failOnUnlicensed options
and warns on violations via console.warn (matching rollup-plugin-license
behavior). Remove anchors from allow regex that rejected compound SPDX
expressions like (MIT OR Apache-2.0).

Co-Authored-By: Claude (Opus 4.6) <noreply@anthropic.com>
…license

* origin/main:
  Update go dependencies (go-gitea#37141)
  Update javascript dependencies (go-gitea#37142)
  Bump min go version to 1.26.2 (go-gitea#37139)
  Add bulk repository deletion for organizations (go-gitea#36763)
  [skip ci] Updated translations via Crowdin

# Conflicts:
#	package.json
#	pnpm-lock.yaml
@silverwind
Copy link
Copy Markdown
Member Author

silverwind commented Apr 8, 2026

Fixed the regex and implemented license violation options in the plugin. Did not enable them, so violations will only produce warnings like it did before in webpack and with the previous plugin.

@silverwind silverwind removed backport/v1.26 This PR should be backported to Gitea 1.26 labels Apr 8, 2026
@GiteaBot GiteaBot added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Apr 9, 2026
@silverwind silverwind enabled auto-merge (squash) April 9, 2026 09:00
@silverwind silverwind added reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. backport/v1.26 This PR should be backported to Gitea 1.26 labels Apr 9, 2026
@silverwind
Copy link
Copy Markdown
Member Author

Backport so we eliminate the rollup dependency (less dependency vulns).

@silverwind silverwind merged commit 04fb6f1 into go-gitea:main Apr 9, 2026
26 checks passed
@silverwind silverwind deleted the remove-rollup-plugin-license branch April 9, 2026 09:31
@GiteaBot GiteaBot added this to the 1.27.0 milestone Apr 9, 2026
@GiteaBot GiteaBot removed the reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. label Apr 9, 2026
@GiteaBot
Copy link
Copy Markdown
Collaborator

GiteaBot commented Apr 9, 2026

I was unable to create a backport for 1.26. @silverwind, please send one manually. 🍵

go run ./contrib/backport 37130
...  // fix git conflicts if any
go run ./contrib/backport --continue

@GiteaBot GiteaBot added the backport/manual No power to the bots! Create your backport yourself! label Apr 9, 2026
Copilot AI added a commit that referenced this pull request Apr 9, 2026
Backport of #37130 to v1.26.

Co-Authored-By: Copilot <175728472+Copilot@users.noreply.github.com>
Co-Authored-By: Claude Sonnet 4 (claude-sonnet-4)

Co-authored-by: silverwind <115237+silverwind@users.noreply.github.com>
silverwind added a commit to silverwind/gitea that referenced this pull request Apr 9, 2026
…tea#37130)

Cherry-pick of 04fb6f1.

Co-Authored-By: silverwind <me@silverwind.io>
Co-Authored-By: Claude (Opus 4.6) <noreply@anthropic.com>
zjjhot added a commit to zjjhot/gitea that referenced this pull request Apr 10, 2026
* main:
  Make Markdown fenced code block work with more syntaxes (go-gitea#37154)
  Remove unneeded doctor sub-commands (go-gitea#37156)
  Report structurally invalid workflows to users (go-gitea#37116)
  Replace `rollup-plugin-license` with `rolldown-license-plugin` (go-gitea#37130)
  Clean up and improve non-gitea js error filter (go-gitea#37148)
silverwind added a commit that referenced this pull request Apr 10, 2026
… (#37158)

Backport #37130. Only one merge conflict in lockfile.

---
This PR was written with the help of Claude Opus 4.6

Co-authored-by: Claude (Opus 4.6) <noreply@anthropic.com>
@lunny lunny added the backport/done All backports for this PR have been created label Apr 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport/done All backports for this PR have been created backport/manual No power to the bots! Create your backport yourself! backport/v1.26 This PR should be backported to Gitea 1.26 lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants