Skip to content

feat(bundler-utils): add shared bundler machinery#5

Merged
dangreen merged 7 commits into
mainfrom
add-bundler-utils
Jul 21, 2026
Merged

feat(bundler-utils): add shared bundler machinery#5
dangreen merged 7 commits into
mainfrom
add-bundler-utils

Conversation

@dangreen

Copy link
Copy Markdown
Member

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).

@coveralls

coveralls commented Jul 21, 2026

Copy link
Copy Markdown

Coverage Report for CI Build 29837524643

Coverage increased (+2.2%) to 89.168%

Details

  • Coverage increased (+2.2%) from the base build.
  • Patch coverage: 3 uncovered changes across 3 files (92 of 95 lines covered, 96.84%).
  • No coverage regressions found.

Uncovered Changes

File Changed Covered %
packages/bundler-utils/src/module.ts 39 38 97.44%
packages/bundler-utils/src/placeholder.ts 12 11 91.67%
packages/bundler-utils/src/query.ts 24 23 95.83%
Total (4 files) 95 92 96.84%

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 360
Covered Lines: 334
Line Coverage: 92.78%
Relevant Branches: 277
Covered Branches: 234
Branch Coverage: 84.48%
Branches in Coverage %: Yes
Coverage Strength: 139825.21 hits per line

💛 - Coveralls

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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-utils with query parsing, placeholder generation, ES module code generation, and generateSrcSetModule + 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.

Comment thread packages/bundler-utils/src/query.ts
Comment thread packages/bundler-utils/src/query.ts
Comment thread packages/bundler-utils/src/query.ts Outdated
Comment thread packages/bundler-utils/src/generate.ts

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 17 out of 18 changed files in this pull request and generated 3 comments.

Files not reviewed (1)
  • pnpm-lock.yaml: Generated file

Comment thread packages/bundler-utils/src/module.ts Outdated
Comment thread packages/bundler-utils/src/generate.ts
Comment thread packages/bundler-utils/src/generate.types.ts

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Comment thread packages/bundler-utils/src/query.ts
Comment thread packages/bundler-utils/src/generate.ts Outdated

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 17 out of 18 changed files in this pull request and generated 3 comments.

Files not reviewed (1)
  • pnpm-lock.yaml: Generated file

Comment thread packages/bundler-utils/src/module.types.ts
Comment thread packages/bundler-utils/src/module.types.ts
Comment thread packages/bundler-utils/src/types.ts
@dangreen
dangreen requested a review from Copilot July 21, 2026 13:27

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

  • width currently accepts non-finite numbers (e.g. width=Infinity), because Number(value) > 0 is true for Infinity. 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
      }

Comment thread packages/bundler-utils/src/query.ts
Comment thread packages/bundler-utils/src/query.ts
@dangreen
dangreen requested a review from Copilot July 21, 2026 13:39

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Comment thread packages/bundler-utils/src/module.ts
Comment thread packages/bundler-utils/src/placeholder.ts

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 17 out of 18 changed files in this pull request and generated 1 comment.

Files not reviewed (1)
  • pnpm-lock.yaml: Generated file

Comment thread packages/bundler-utils/src/module.ts
@dangreen
dangreen requested a review from Copilot July 21, 2026 14:38

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 17 out of 18 changed files in this pull request and generated 1 comment.

Files not reviewed (1)
  • pnpm-lock.yaml: Generated file

Comment thread packages/bundler-utils/src/placeholder.ts

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 17 out of 18 changed files in this pull request and generated no new comments.

Files not reviewed (1)
  • pnpm-lock.yaml: Generated file

@dangreen
dangreen merged commit fd072e6 into main Jul 21, 2026
10 checks passed
@dangreen
dangreen deleted the add-bundler-utils branch July 21, 2026 14:58
@github-actions github-actions Bot mentioned this pull request Jul 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants