feat(bundler-utils): add shared bundler machinery#5
Merged
Conversation
Coverage Report for CI Build 29837524643Coverage increased (+2.2%) to 89.168%Details
Uncovered Changes
Coverage RegressionsNo coverage regressions found. Coverage Stats💛 - Coveralls |
There was a problem hiding this comment.
Pull request overview
Adds a new workspace package, @srcset/bundler-utils, to centralize shared implementation pieces used by bundler integrations (query parsing, module codegen, placeholder generation, and the backend contract), so integrations can reuse the same machinery and types.
Changes:
- Introduces
packages/bundler-utilswith query parsing, placeholder generation, ES module code generation, andgenerateSrcSetModule+ backend interfaces. - Adds unit tests (Vitest) covering query parsing, placeholder generation, module codegen, and module generation behavior.
- Registers the new package in the workspace lockfile and adds package-level build/lint/test configuration.
Reviewed changes
Copilot reviewed 17 out of 18 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| pnpm-lock.yaml | Adds the new packages/bundler-utils importer with dependencies (@srcset/core, sharp, p-limit). |
| packages/bundler-utils/tsconfig.json | Package TS config for dev/typechecking scope. |
| packages/bundler-utils/tsconfig.build.json | Build TS config emitting dist/ types/JS. |
| packages/bundler-utils/src/types.ts | Defines shared bundler-side types (SrcSetRule, backend image/url types). |
| packages/bundler-utils/src/query.ts | Implements import query parsing into rules/selection/placeholder options. |
| packages/bundler-utils/src/query.spec.ts | Unit tests for query parsing behavior. |
| packages/bundler-utils/src/placeholder.ts | Implements blur-up placeholder data-url generation via sharp. |
| packages/bundler-utils/src/placeholder.spec.ts | Unit tests for placeholder generation behavior. |
| packages/bundler-utils/src/module.types.ts | Types for generated module entries and selection/resource id formatting. |
| packages/bundler-utils/src/module.ts | Implements ES module code generation for image imports (createModuleString). |
| packages/bundler-utils/src/module.spec.ts | Unit tests for module code generation output. |
| packages/bundler-utils/src/index.ts | Package public exports surface. |
| packages/bundler-utils/src/generate.types.ts | Defines generateSrcSetModule options and backend contract types. |
| packages/bundler-utils/src/generate.ts | Implements variant generation orchestration and module output assembly. |
| packages/bundler-utils/src/generate.spec.ts | Unit tests for generation orchestration and backend behaviors. |
| packages/bundler-utils/README.md | Package documentation and usage overview. |
| packages/bundler-utils/package.json | Package metadata, exports, scripts, and dependencies. |
| packages/bundler-utils/oxlint.config.ts | Package lint configuration extending repo defaults. |
Files not reviewed (1)
- pnpm-lock.yaml: Generated file
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 17 out of 18 changed files in this pull request and generated 2 comments.
Files not reviewed (1)
- pnpm-lock.yaml: Generated file
Comments suppressed due to low confidence (1)
packages/bundler-utils/src/query.ts:65
widthcurrently accepts non-finite numbers (e.g.width=Infinity), becauseNumber(value) > 0is true forInfinity. This can propagate odd values into selection logic. Consider requiring a finite positive number.
case 'width': {
const width = Number(value)
if (width > 0) {
query.select = {
...query.select,
width
}
}
break
}
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds
@srcset/bundler-utils: the shared machinery of the bundler integrations - import query parsing, image module codegen (generateSrcSetModule/createModuleString), the blur-up placeholder, and the backend contract (SrcSetBackendFactory/SrcSetBackend,EmitImage/SrcSetImagePaths).