IK-2197 Astro Integration for Imagekit#1
Conversation
There was a problem hiding this comment.
Pull request overview
Adds an Astro-based monorepo setup for @imagekit/astro, including core components/helpers and a Playwright-driven test app to validate generated ImageKit URLs and rendered markup.
Changes:
- Introduces
@imagekit/astropackage withIKImage,IKVideo,IKAstroImage,IKOgImage, shared config resolution, and agetImagekitUrlhelper. - Adds a
test-appAstro project with component demo pages and Playwright E2E tests + snapshots. - Adds CI workflows for building, packing, running E2E tests, and publishing on release.
Reviewed changes
Copilot reviewed 38 out of 43 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| pnpm-workspace.yaml | Defines monorepo packages (imagekit-astro, test-app). |
| package.json | Adds monorepo scripts for build and E2E. |
| .npmrc | pnpm hoisting configuration. |
| .gitignore | Ignores build/test/env artifacts at repo root. |
| .github/workflows/nodejs.yml | CI build + pack + E2E execution. |
| .github/workflows/npmpublish.yml | Release publish workflow with pack + E2E gate. |
| README.md | New top-level SDK documentation and usage examples. |
| LICENSE | Adds MIT license. |
| imagekit-astro/package.json | Defines package exports/scripts/deps for @imagekit/astro. |
| imagekit-astro/index.ts | Public package entrypoint exporting components, helper re-exports, and types. |
| imagekit-astro/tsup.config.ts | tsup build config (helpers bundle + dts). |
| imagekit-astro/tsconfig.json | TS config for package typing/emit settings. |
| imagekit-astro/src/env.d.ts | Astro client type references. |
| imagekit-astro/src/lib/imagekit.ts | Env/prop-based config resolution. |
| imagekit-astro/src/helpers/getImagekitUrl.ts | Programmatic ImageKit URL builder helper. |
| imagekit-astro/src/helpers/index.ts | Helper barrel export. |
| imagekit-astro/src/types/index.ts | Component prop types. |
| imagekit-astro/src/constants/sizes.ts | OG image default dimensions. |
| imagekit-astro/src/components/IKImage.astro | Responsive/non-responsive <img> wrapper around ImageKit URL generation. |
| imagekit-astro/src/components/IKVideo.astro | <video> wrapper around ImageKit URL generation. |
| imagekit-astro/src/components/IKAstroImage.astro | Uses astro:assets <Image> with ImageKit URL/transformation integration. |
| imagekit-astro/src/components/IKOgImage.astro | Generates OG/Twitter meta tags with ImageKit URLs. |
| imagekit-astro/helpers/package.json | Helpers subpath package metadata. |
| imagekit-astro/imagekit-astro-1.0.0.tgz | Packed artifact added to repo. |
| test-app/package.json | Test app scripts/deps for Astro + Playwright. |
| test-app/tsconfig.json | Astro strict TS config for test app. |
| test-app/src/env.d.ts | Astro client type references for test app. |
| test-app/astro.config.mjs | Astro config (remote image domains). |
| test-app/src/pages/index.astro | Test app landing page navigation. |
| test-app/src/pages/images.astro | IKImage demo/test cases. |
| test-app/src/pages/videos.astro | IKVideo demo/test cases. |
| test-app/src/pages/astro-images.astro | IKAstroImage demo/test cases. |
| test-app/playwright.config.ts | Playwright config with web server + snapshot template. |
| test-app/e2e/images.spec.ts | E2E snapshot test for /images. |
| test-app/e2e/videos.spec.ts | E2E snapshot test for /videos. |
| test-app/e2e/astro-images.spec.ts | E2E assertions for /astro-images (attributes + URL behavior). |
| test-app/e2e/snapshot/* | Stored Playwright snapshots for the E2E tests. |
| test-app/README.md | Test app usage + covered test cases. |
| test-app/.gitignore | Ignores test-app build/test artifacts. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
2. Move types to common place 3. Build fixes
Co-authored-by: Copilot <copilot@github.com>
Co-authored-by: Copilot <copilot@github.com>
Co-authored-by: Copilot <copilot@github.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 48 out of 54 changed files in this pull request and generated 6 comments.
Files not reviewed (1)
- imagekit-astro/package-lock.json: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <copilot@github.com>
| height?: number; | ||
|
|
||
| /** Image format override */ | ||
| format?: 'auto' | 'webp' | 'jpg' | 'jpeg' | 'png' | 'gif' | 'svg' | 'mp4' | 'webm' | 'avif' | 'orig'; |
There was a problem hiding this comment.
Either Transformation['format'] (consistency) or a narrower OG-image-only union (correctness for use case not video formats), what do you think?
| type Props = RemoteImageProps & ImageProps; | ||
|
|
||
| const { | ||
| class: className, | ||
| ...props | ||
| } = Astro.props; |
There was a problem hiding this comment.
[MINOR] type Props defined above is not used while destructuring.
There was a problem hiding this comment.
That is the structure that needs to be followed in .astro files. Astro automatically applies the Props type to Astro.props. Even I felt that it is weird 😅, but that's the standard.
| width: Math.round(width * scaleFactor), | ||
| height: Math.round(height * scaleFactor), | ||
| }; | ||
| } |
There was a problem hiding this comment.
Hardcoding a 25MP clamp in the SDK feels too opinionated, since ImageKit supports >25MP depending on plan.
Can we remove this cap (or make it configurable) if Astro functionality remains unaffected?
Co-authored-by: Copilot <copilot@github.com>
|
Few doubts:
|
| * Dynamically imports `inferRemoteSize` from `astro:assets`. | ||
| * Available since Astro 4.12. Returns `undefined` on older versions. | ||
| */ | ||
| async function tryInferRemoteSize(url: string): Promise<{ width: number; height: number } | undefined> { |
There was a problem hiding this comment.
This will be called at build time if width is not passed. Correct?
Wouldn't it be better to make width and height mandatory like Astro and ignore inferSize property?
There was a problem hiding this comment.
Yes, this is called at build time.
I kept it to keep the interface as close to the astro Image component as possible, to make it more seamless to use as a drop-in replacement for the astro image component.
No description provided.