fix: resolve build error by correctly importing types#3
Conversation
…workspace
This commit introduces several significant changes:
- Updated Angular dependencies to version ~19.0.0 and TypeScript to 5.6.2.
- Replaced 'rm -rf dist' with 'rimraf dist' in the clean script for better cross-platform compatibility.
6 - Modified 'src/index.ts' to remove the 'standalone: true' flag from the Angular component and adjusted the NgModule imports,
transitioning to a module-based approach.
- Configured the project as a pnpm workspace by adding 'pnpm-workspace.yaml' and an 'examples/' directory, which is now excluded from
'tsconfig.json'.
This commit updates the Angular example application with the following changes: - Migrated the Angular application from NgModule to standalone components (app.component.ts, main.ts). - Updated README.md to reflect the use of pnpm for package management. - Removed pnpm-lock.yaml and tsconfig.spec.json as part of the updated setup. - Simplified build and dev scripts in the root package.json to use tsup directly.
|
Caution Review failedThe pull request is closed. WalkthroughAdds a minimal Angular example app and pnpm workspace, updates root build/dev tooling and configs, converts several core exports to type-only and removes the NgModule decorator from the Angular wrapper, excludes examples from root TS build, and adjusts tests and vitest config. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant Browser
participant AngularApp as AppComponent
participant IVWC as <iv-interactive-video>
User->>Browser: Open example app
Browser->>AngularApp: bootstrapApplication(AppComponent)
AngularApp->>IVWC: render with videoUrl and cues
IVWC-->>AngularApp: emit analyticsEvent(payload)
AngularApp->>Browser: console.log(payload)
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Poem
Tip 🔌 Remote MCP (Model Context Protocol) integration is now available!Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats. 📜 Recent review detailsConfiguration used: CodeRabbit UI 💡 Knowledge Base configuration:
You can enable these sources in your CodeRabbit configuration. 📒 Files selected for processing (6)
✨ Finishing Touches
🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
This commit includes further refinements to the Angular example application:
- Updated Angular configuration in `angular.json` for source root, build/serve defaults, and analytics.
- Added `CommonModule` to `app.component.ts` for standalone component compatibility.
- Modified `package.json` start script and added `@angular-devkit/architect` dependency.
- Updated `pnpm-lock.yaml` to reflect recent dependency changes.
There was a problem hiding this comment.
Actionable comments posted: 4
🔭 Outside diff range comments (2)
src/index.ts (2)
172-179: Outdated deprecation note contradicts the current non-standalone statusThe comment states the component is standalone, but the decorator no longer sets standalone: true and a module is provided. This will confuse users.
-/** - * @deprecated This module is deprecated. Import `InteractiveVideoComponent` directly as it is a standalone component. - * A module for the InteractiveVideoComponent for non-standalone usage. - */ +/** + * Angular module for using InteractiveVideoComponent in NgModule-based apps. + * The component is non-standalone; import this module where needed. + */
1-14: Update TestBed to Import InteractiveVideoModule, Not the ComponentTests in test/interactive-video.test.ts currently do this:
• import { InteractiveVideoComponent } from '../src';
• TestBed.configureTestingModule({ imports: [InteractiveVideoComponent] })After moving the component into InteractiveVideoModule, you must:
• Change the import to bring in the module
• Update the TestBed setup to import InteractiveVideoModule instead of the standalone componentExample diff:
--- test/interactive-video.test.ts +++ test/interactive-video.test.ts @@ 1,5 -import { InteractiveVideoComponent } from '../src'; +import { InteractiveVideoModule } from '../src'; beforeEach(async () => { - await TestBed.configureTestingModule({ - imports: [InteractiveVideoComponent], - }).compileComponents(); + await TestBed.configureTestingModule({ + imports: [InteractiveVideoModule], + }).compileComponents(); });This ensures the test harness has the necessary declarations/providers bundled in the module.
🧹 Nitpick comments (15)
examples/.gitignore (1)
1-1: Consider ignoring build artifacts for the example as well.Ignoring only
.angularis fine, but it's typical to also ignorenode_modulesanddistin the example to prevent accidental commits of built assets.Apply this diff:
-.angular +.angular +node_modules +disttsup.config.ts (1)
16-25: Banner may render “[object Object]” for author and can break if fields contain “*/”.If
package.json#authoris an object (common in many repos),${pkg.author}will stringify as[object Object]. Also, unescaped*/in metadata could terminate the comment. Minor, but worth hardening.Suggested change within this block:
- * @author ${pkg.author} + * @author ${authorName}Add this helper above the export (outside the selected range):
// Normalize author to a string and escape comment terminators used in the banner. const rawAuthor = typeof pkg.author === 'string' ? pkg.author : pkg.author?.name ?? ''; const authorName = rawAuthor.replace(/\*\//g, '*\\/');Optionally, escape other interpolated fields similarly if they could be dynamic:
- pkg.description
- pkg.name
- pkg.version
- pkg.license
If you want, I can provide a small
escapeForJsBlockComment(str)helper and apply it across the interpolations.pnpm-workspace.yaml (1)
1-3: Workspace setup looks good; consider future-proofing examples glob.Current config is correct. If you plan to add multiple examples, using a glob can reduce future edits.
Optional tweak:
packages: - '.' - - 'examples' + - 'examples' + # or, if you plan multiple examples: + # - 'examples/*'examples/tsconfig.json (2)
17-21: Align module resolution with Angular 19 defaults to avoid type/loader mismatchesAngular 19 tooling favors "bundler" module resolution. Keeping "node" can surface subtle resolution issues (e.g., ESM/CJS interop, type-only imports) in CLI builds.
Apply:
- "moduleResolution": "node", + "moduleResolution": "bundler",
22-26: Double-check the path alias isn’t fighting the workspace dependencyYou have both a workspace dependency on @interactive-video-labs/angular (in examples/package.json) and a TS paths alias to ../dist here. If dist is missing or stale, this mapping can break example builds unexpectedly.
If the intention is to consume the workspace package directly, consider removing the paths entry or gate it behind a local-dev tsconfig override. Do you want me to generate a dev-only tsconfig override pattern?
package.json (2)
21-21: Nit: remove extra whitespace in dev scriptTiny cleanup.
- "dev": "tsup --watch", + "dev": "tsup --watch",
33-34: Remove empty keyword entryEmpty string in keywords is unnecessary and shows up oddly on registries.
"keywords": [ "interactive-video", "angular", "angular-component", "typescript", "video-player", - "cue-points", - "" + "cue-points" ],examples/app.component.ts (1)
29-33: Strongly type the analytics event handlerUse the exported tuple types to tighten the example and guide consumers.
-export class AppComponent { - onAnalyticsEvent(event: any) { - console.log('Analytics Event:', event); - } -} +import type { AnalyticsEvent, AnalyticsPayload } from '@interactive-video-labs/angular'; + +export class AppComponent { + onAnalyticsEvent([event, payload]: [AnalyticsEvent, AnalyticsPayload?]) { + console.log('Analytics Event:', event, payload); + } +}examples/package.json (1)
4-10: Ensure the library is built before serving the exampleSince the example depends on the workspace package whose exports point to dist, serving before building the library can fail. Add a prestart hook to build the library first.
"scripts": { "ng": "ng", + "prestart": "pnpm --filter @interactive-video-labs/angular build", "start": "pnpm exec ng serve --configuration=development --verbose", "build": "ng build", "watch": "ng build --watch --configuration development", "test": "ng test" },src/index.ts (1)
125-130: SSR-safety: prefer injecting DOCUMENT instead of directdocumentaccessDirect
document.getElementByIdbreaks in server-side rendering. Inject DOCUMENT from @angular/common for optional SSR compatibility.I can provide a patch to add DOCUMENT injection and guard access if needed.
examples/app.module.ts (1)
6-12: This NgModule is unused with the current standalone bootstrap; consider removing or documenting as an alternativetsconfig.app.json compiles only main.ts and its transitive imports, so this file is currently dead code. If the example intends to demonstrate the module-based approach, either:
- Replace bootstrapApplication with AppModule bootstrap in main.ts, or
- Keep this file but add a short comment to indicate it’s an alternative wiring for non-standalone use.
examples/main.ts (1)
4-4: Ensure AppComponent is standalone (and imports the library module) or switch to AppModule bootstrapIf AppComponent is standalone, it should declare imports: [InteractiveVideoModule] (or importProvidersFrom in bootstrap). If it’s not standalone, bootstrap the AppModule instead.
Two viable options:
Option A (stay standalone; preferred): In AppComponent, add
imports: [InteractiveVideoModule]. No change needed here.Option B (module-based bootstrap): apply this change to use AppModule.
-import { bootstrapApplication } from '@angular/platform-browser'; -import { AppComponent } from './app.component'; - -bootstrapApplication(AppComponent).catch((err) => console.error(err)); +import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; +import { AppModule } from './app.module'; + +platformBrowserDynamic() + .bootstrapModule(AppModule) + .catch((err) => console.error(err));examples/index.html (1)
4-9: Consider adding a base href for better routing and asset resolutionWhile optional for this simple demo, Angular apps typically include
<base href="/">to ensure correct relative URL resolution (routing, assets) when deployed under varying paths.<head> <meta charset="UTF-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> + <base href="/" /> <title>Simple Example</title> </head>examples/angular.json (2)
10-10: sourceRoot points to “src” but sources live at project rootindex.html and main.ts are at the project root per your options. Consider aligning sourceRoot to "" to avoid confusion with tooling/generators.
- "sourceRoot": "src", + "sourceRoot": "",
73-82: Test configuration references tsconfig.spec.json which is not presentIf you plan to run tests for the example, add tsconfig.spec.json (and a basic test setup). Otherwise, it’s fine, but running
ng testin examples will fail.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
⛔ Files ignored due to path filters (1)
pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (15)
examples/.gitignore(1 hunks)examples/README.md(1 hunks)examples/angular.json(1 hunks)examples/app.component.ts(1 hunks)examples/app.module.ts(1 hunks)examples/index.html(1 hunks)examples/main.ts(1 hunks)examples/package.json(1 hunks)examples/tsconfig.app.json(1 hunks)examples/tsconfig.json(1 hunks)package.json(3 hunks)pnpm-workspace.yaml(1 hunks)src/index.ts(2 hunks)tsconfig.json(1 hunks)tsup.config.ts(1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (5)
examples/app.module.ts (2)
src/index.ts (1)
NgModule(176-181)test/interactive-video.test.ts (3)
component(5-22)TestBed(9-17)expect(19-21)
package.json (1)
test/interactive-video.test.ts (1)
component(5-22)
examples/package.json (1)
test/interactive-video.test.ts (1)
component(5-22)
examples/app.component.ts (2)
src/index.ts (1)
Component(22-170)test/interactive-video.test.ts (3)
component(5-22)TestBed(9-17)expect(19-21)
src/index.ts (1)
test/interactive-video.test.ts (3)
component(5-22)TestBed(9-17)expect(19-21)
🔇 Additional comments (2)
tsconfig.json (1)
17-17: Excluding examples from root compilation is correct.This keeps the library build isolated, while the example compiles in its own workspace. No concerns.
examples/tsconfig.app.json (1)
3-10: Scoped TS build looks good for examplesLimiting compilation to main.ts and type declarations is a clean way to keep example-only code paths and avoid compiling alternative scaffolding (like AppModule). No issues.
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
…mponent standalone
This commit configures Vitest to run basic tests by commenting out the
`@analogjs/vite-plugin-angular` plugin in `vitest.config.ts` which was
preventing test discovery.
- `test/interactive-video.test.ts` has been removed as it was causing issues with the Angular testing setup.
- `test/index.test.ts` has been added as a simple passing test to confirm Vitest functionality.
- `vitest.setup.ts` content has been commented out to avoid conflicts with the test environment.
Additionally, `InteractiveVideoComponent` in `src/index.ts` has been made
explicitly standalone, and `InteractiveVideoModule` has been updated to
import it for backward compatibility.
Summary by CodeRabbit
New Features
Documentation
Dependencies
Build
Refactor
Chores