Frun1na opened a new pull request, #5083:
URL: https://github.com/apache/rocketmq-dashboard/pull/5083
### Which Issue(s) This PR Fixes
- Fixes #<issue-id>
### Brief Description
`npm run build` fails on every run at the `license:check` gate with `build
artifact verification failed: assets/index-*.js`. Two deterministic causes,
both rooted in the manifest being finalized too early:
1. `distributionLicenses()` records the output checksums in its own
`generateBundle`, but `vite:build-import-analysis` injects the
`__vite__mapDeps` preload map into the entry chunk in its own (later)
`generateBundle`, so the written entry chunk always differs from what was
hashed.
2. `checkDistribution` re-collects the license sources from
`manifest.modules` and compares the components. `legalFiles()` walks each
package directory without excluding the build output directory, so at check
time the just-written `dist/legal/licenses/**` files and `dist/NOTICE` are
picked up as new "license sources" of the app package, and the components
comparison always diverges.
Fixes:
- the manifest is now finalized in `writeBundle` (final chunk contents,
after all injections) and written straight into the build output directory; the
license materials themselves are still emitted during `generateBundle` as
before;
- `legalFiles()` skips `dist/` so build-time and check-time collections see
the same sources (no bundled dependency keeps its license under a `dist/`
directory, verified against the generated manifest).
The existing packaging test did not catch this because its fixture has no
dynamic import, so no preload map was ever injected; the updated test builds
with `write: true` and a new regression test adds a dynamic-import fixture that
reproduces the injection.
### How Did You Test This Change?
```
cd web && node --test scripts/licenses.test.mjs
# tests 5
# pass 5
# fail 0
```
The new regression test fails on the unpatched plugin:
```
# pass 4
# fail 1
✖ vitePackagingSurvivesDynamicImportPreloadInjectionTest
Error: dependency versions/license texts changed; a rebuild is required
```
and with only the `legalFiles` fix applied it fails with the original
symptom (`build artifact verification failed: assets/index-*.js`), which is
what every `npm run build` currently reports.
End-to-end on the app itself (failed before this change, passes now):
```
cd web && rm -rf dist && npm run build
> node scripts/licenses.mjs check
web license check passed: 133 actual components, 140 license files
```
### Checklist
- [x] One coherent change; unrelated modifications are not bundled in
- [x] Commit subject follows Conventional Commits (`feat:` / `fix:` /
`refactor:` / `chore:` / `docs:` / `perf:`)
- [x] Tests added or updated for non-trivial changes, test methods named
`...Test`
- [x] New UI text has both Chinese and English entries under `web/src/i18n/`
- [ ] Architecture constraints stay green (`mvn test` runs the ArchUnit
checks)
- [x] New source files carry the ASF license header
- [ ] Documentation touched where behaviour changed (README / `docs/` /
in-app help)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]