mirror of
https://github.com/4gray/iptvnator.git
synced 2026-10-08 17:06:15 -08:00
perf(web): keep lazy-only services and SafePipe out of main.js
The eager shell imported barrels that re-export Angular injectables and a pipe it never uses, and their static definitions keep those modules in main.js: PlaylistFileImportService came with PlaylistContextFacade, normalizeDateLocale with SafePipe, and the workspace-shell-util barrel with SettingsContextService, which #1714 grew with match counts. That growth put master 108 bytes over the renderer.initialBytes baseline #1712 had measured on a branch without #1714. Add file-level entries for the three modules and use them from the eager and settings code: renderer.initialBytes 1,626,127 -> 1,619,993 bytes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
254d1fd922
commit
3aa036d460
12 files changed
+40
-16
No files matched your search
@@ -2,7 +2,7 @@ import { registerLocaleData } from '@angular/common';
|
||||
import localeEn from '@angular/common/locales/en';
|
||||
import { inject, Injectable } from '@angular/core';
|
||||
import { TranslateService } from '@ngx-translate/core';
|
||||
import { normalizeDateLocale } from '@iptvnator/pipes';
|
||||
import { normalizeDateLocale } from '@iptvnator/pipes/date-format';
|
||||
import { createDevLogger } from '@iptvnator/shared/interfaces';
|
||||
|
||||
type LocaleDataModule = { default: unknown };
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Injectable, inject } from '@angular/core';
|
||||
import { MatSnackBar } from '@angular/material/snack-bar';
|
||||
import { TranslateService } from '@ngx-translate/core';
|
||||
import { PlaylistFileImportService } from '@iptvnator/playlist/shared/util';
|
||||
import { PlaylistFileImportService } from '@iptvnator/playlist/shared/util/playlist-file-import';
|
||||
import type { ElectronBridgePlaylistOpenRequest } from '@iptvnator/shared/interfaces';
|
||||
|
||||
type PlaylistOpenRequestBridge = {
|
||||
|
||||
@@ -12,7 +12,7 @@ import {
|
||||
import { toSignal } from '@angular/core/rxjs-interop';
|
||||
import { ActivatedRoute } from '@angular/router';
|
||||
import { TranslateService } from '@ngx-translate/core';
|
||||
import { SettingsContextService } from '@iptvnator/workspace/shell/util';
|
||||
import { SettingsContextService } from '@iptvnator/workspace/shell/util/settings-context';
|
||||
import {
|
||||
SettingsRevealRequest,
|
||||
SettingsSearchEntry,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
|
||||
import { Router } from '@angular/router';
|
||||
import { SettingsContextService } from '@iptvnator/workspace/shell/util';
|
||||
import { SettingsContextService } from '@iptvnator/workspace/shell/util/settings-context';
|
||||
import {
|
||||
SETTINGS_SEARCH_ENTRIES,
|
||||
SettingsSearchEntry,
|
||||
|
||||
@@ -16,7 +16,7 @@ import { MatButtonModule } from '@angular/material/button';
|
||||
import { MatDialog } from '@angular/material/dialog';
|
||||
import { MatIconModule } from '@angular/material/icon';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
import { SettingsContextService } from '@iptvnator/workspace/shell/util';
|
||||
import { SettingsContextService } from '@iptvnator/workspace/shell/util/settings-context';
|
||||
import { TranslateModule, TranslateService } from '@ngx-translate/core';
|
||||
import {
|
||||
EpgSourceReconciliationError,
|
||||
|
||||
@@ -235,18 +235,25 @@ and value-imports those two dependency-free modules directly.
|
||||
`@iptvnator/workspace/shell/util/settings-search` exists for the opposite
|
||||
reason: the main `workspace-shell-util` barrel is imported eagerly, and the
|
||||
settings search index must stay in the lazy settings and shell chunks.
|
||||
`@iptvnator/workspace/shell/util/settings-context` keeps
|
||||
`SettingsContextService`, which only the lazy settings page and settings
|
||||
context panel use, out of that barrel for the same reason.
|
||||
|
||||
The web app's root shell (`app.component.ts`, `app.config.ts` and the services
|
||||
they construct) is on the renderer's initial path, where a barrel costs its
|
||||
whole library: esbuild keeps every Angular component module a barrel
|
||||
re-exports, because their static definitions count as side effects. Importing
|
||||
re-exports, because their static definitions count as side effects (so do an
|
||||
`@Injectable` service's and a pipe's). Importing
|
||||
`WindowControlsComponent` and `DialogService` from `@iptvnator/ui/components`
|
||||
once put the channel lists, EPG views, `@angular/forms`, `date-fns` and the
|
||||
Stalker data layer into `main.js`. The root shell therefore uses file-level
|
||||
entries: `@iptvnator/ui/components/window-controls`,
|
||||
`@iptvnator/ui/components/confirm-dialog` and
|
||||
`@iptvnator/playlist/shared/ui/stalker-connection-editor` (like the existing
|
||||
`@iptvnator/ui/epg/progress-panel`), and loads anything used only on demand
|
||||
`@iptvnator/ui/components/confirm-dialog`,
|
||||
`@iptvnator/playlist/shared/ui/stalker-connection-editor`,
|
||||
`@iptvnator/playlist/shared/util/playlist-file-import` (the barrel would add
|
||||
`PlaylistContextFacade`) and `@iptvnator/pipes/date-format` (the barrel would
|
||||
add `SafePipe`; the eager EPG progress panel uses it too), like the existing
|
||||
`@iptvnator/ui/epg/progress-panel`, and loads anything used only on demand
|
||||
through a local file it imports dynamically (the Stalker connection editor,
|
||||
the release-notes dialog, the external-player info dialog). A local file,
|
||||
not the library alias, is the dynamic-import target because
|
||||
|
||||
@@ -273,6 +273,17 @@ the first measurements was otherwise `package.json` text embedded in
|
||||
`main.js`, which moved with every script edit; #1692 fixed that by importing
|
||||
only the version.)
|
||||
|
||||
Two effects make the exact counter move for reasons outside a PR's own diff.
|
||||
A baseline lowered on a branch that predates a concurrent `master` merge can
|
||||
sit below what the merged code measures: #1712 lowered it on a branch without
|
||||
#1714, so `master` measured 108 bytes over and every later PR failed the job
|
||||
until a follow-up moved lazy-only modules out of `main.js`. Re-run the job on
|
||||
an up-to-date branch before merging a baseline change. And the bundler's
|
||||
chunk-level identifier renaming shifts when a module enters or leaves
|
||||
`main.js`: moving one service out once renamed an imported identifier at 162
|
||||
call sites, eating about 320 of the bytes saved. Judge a small change by the
|
||||
`--stats-json` input sizes, not only by the counter.
|
||||
|
||||
The job also refuses a weakened baselines file:
|
||||
`tools/performance/check-baseline-direction.mjs` compares
|
||||
`journey-baselines.json` with the revision the change is measured against
|
||||
|
||||
@@ -20,7 +20,7 @@ import {
|
||||
EpgProgressService,
|
||||
} from '@iptvnator/epg/data-access';
|
||||
import { ELECTRON_BRIDGE_SECURITY_ERROR_CODES } from '@iptvnator/shared/interfaces';
|
||||
import { normalizeDateLocale } from '@iptvnator/pipes';
|
||||
import { normalizeDateLocale } from '@iptvnator/pipes/date-format';
|
||||
import { formatEpgImportDisplayUrl } from './epg-import-display-url';
|
||||
|
||||
interface EpgTrustConfirmDialogData {
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@ import { TestBed } from '@angular/core/testing';
|
||||
import { provideRouter } from '@angular/router';
|
||||
import { TranslateService } from '@ngx-translate/core';
|
||||
import { of } from 'rxjs';
|
||||
import { SettingsContextService } from '@iptvnator/workspace/shell/util';
|
||||
import { SettingsContextService } from '@iptvnator/workspace/shell/util/settings-context';
|
||||
import { WorkspaceSettingsContextPanelComponent } from './workspace-settings-context-panel.component';
|
||||
|
||||
describe('WorkspaceSettingsContextPanelComponent', () => {
|
||||
|
||||
+2
-4
@@ -3,10 +3,8 @@ import { Component, inject, ChangeDetectionStrategy } from '@angular/core';
|
||||
import { MatIconModule } from '@angular/material/icon';
|
||||
import { RouterLink, RouterLinkActive } from '@angular/router';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
import {
|
||||
WorkspaceShellContextDrawerService,
|
||||
SettingsContextService,
|
||||
} from '@iptvnator/workspace/shell/util';
|
||||
import { WorkspaceShellContextDrawerService } from '@iptvnator/workspace/shell/util';
|
||||
import { SettingsContextService } from '@iptvnator/workspace/shell/util/settings-context';
|
||||
|
||||
@Component({
|
||||
selector: 'app-workspace-settings-context-panel',
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
export * from './lib/settings-context.service';
|
||||
export * from './lib/workspace-shell-context-drawer.service';
|
||||
export * from './lib/navigation/workspace-shell-route.utils';
|
||||
export * from './lib/navigation/workspace-search-capability';
|
||||
|
||||
@@ -43,6 +43,9 @@
|
||||
"@iptvnator/playlist/shared/util": [
|
||||
"libs/playlist/shared/util/src/index.ts"
|
||||
],
|
||||
"@iptvnator/playlist/shared/util/playlist-file-import": [
|
||||
"libs/playlist/shared/util/src/lib/playlist-file-import.service.ts"
|
||||
],
|
||||
"@iptvnator/ui/epg": ["libs/ui/epg/src/index.ts"],
|
||||
"@iptvnator/ui/epg/date": ["libs/ui/epg/src/lib/epg-date.ts"],
|
||||
"@iptvnator/ui/epg/progress-panel": [
|
||||
@@ -79,10 +82,16 @@
|
||||
"@iptvnator/workspace/shell/util": [
|
||||
"libs/workspace/shell/util/src/index.ts"
|
||||
],
|
||||
"@iptvnator/workspace/shell/util/settings-context": [
|
||||
"libs/workspace/shell/util/src/lib/settings-context.service.ts"
|
||||
],
|
||||
"@iptvnator/workspace/shell/util/settings-search": [
|
||||
"libs/workspace/shell/util/src/lib/settings-search/index.ts"
|
||||
],
|
||||
"@iptvnator/pipes": ["libs/ui/pipes/src/index.ts"],
|
||||
"@iptvnator/pipes/date-format": [
|
||||
"libs/ui/pipes/src/lib/date-format.util.ts"
|
||||
],
|
||||
"@iptvnator/ui/components": ["libs/ui/components/src/index.ts"],
|
||||
"@iptvnator/ui/components/confirm-dialog": [
|
||||
"libs/ui/components/src/lib/confirm-dialog/dialog.service.ts"
|
||||
|
||||
Reference in new issue
Block a user