Skip to content

feat(loader): add webpack and Rspack loader#6

Merged
dangreen merged 3 commits into
mainfrom
add-loader
Jul 21, 2026
Merged

feat(loader): add webpack and Rspack loader#6
dangreen merged 3 commits into
mainfrom
add-loader

Conversation

@dangreen

Copy link
Copy Markdown
Member

Adds @srcset/loader: image imports become ES modules with url, src, srcSet, srcMap and placeholder exports. Name templates with content hashes, output/public path resolvers, import queries, tree-shakable codegen and the backend option; client type declarations via @srcset/loader/client. Tested against both webpack and Rspack, including tree-shaking specs.

@coveralls

coveralls commented Jul 21, 2026

Copy link
Copy Markdown

Coverage Report for CI Build 29859223679

Coverage decreased (-2.0%) to 87.201%

Details

  • Coverage decreased (-2.0%) from the base build.
  • Patch coverage: 13 uncovered changes across 4 files (33 of 46 lines covered, 71.74%).
  • No coverage regressions found.

Uncovered Changes

File Changed Covered %
packages/loader/src/paths.ts 10 5 50.0%
packages/loader/src/limit.ts 6 2 33.33%
packages/loader/src/loader.ts 18 15 83.33%
packages/loader/src/template.ts 12 11 91.67%

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 406
Covered Lines: 367
Line Coverage: 90.39%
Relevant Branches: 305
Covered Branches: 253
Branch Coverage: 82.95%
Branches in Coverage %: Yes
Coverage Strength: 123985.59 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

This PR introduces a new @srcset/loader package that integrates the existing @srcset/* image generation pipeline with webpack and Rspack, turning image imports into tree-shakable ES modules exporting url, src, srcSet, srcMap, and placeholder, with configurable filename templating and path resolution.

Changes:

  • Added packages/loader with loader implementation, option types, filename templating, path/publicPath resolvers, and shared concurrency limiting.
  • Added unit tests that exercise webpack + Rspack integration, including tree-shaking behavior and placeholder export behavior.
  • Added package metadata/config (package.json, tsconfigs, vitest config, oxlint config) and lockfile updates for new dependencies.

Reviewed changes

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

Show a summary per file
File Description
pnpm-lock.yaml Adds dependencies required by the new loader package (webpack, rspack, memfs, etc.).
packages/loader/vite.config.js Vitest configuration for the loader package.
packages/loader/tsconfig.json Typechecking config for loader sources/tests.
packages/loader/tsconfig.build.json Build-time TS config for emitting dist.
packages/loader/test/loader.shim.mjs Shim to allow bundlers to load the loader during tests.
packages/loader/test/bundler.mock.ts Test harness to compile/bundle with webpack/rspack in-memory FS.
packages/loader/src/types.ts Public loader option types and path resolver type.
packages/loader/src/template.ts Filename templating ([path], [name], [postfix], [hash], etc.).
packages/loader/src/template.spec.ts Unit tests for filename templating behavior.
packages/loader/src/paths.ts Output/public path resolution helpers.
packages/loader/src/loader.ts Webpack/Rspack loader entry that generates the image module + emits files.
packages/loader/src/loader.spec.ts Integration tests for webpack/rspack behavior and tree-shaking.
packages/loader/src/limit.ts Shared concurrency limiter for loader runs.
packages/loader/src/index.ts Package entry exports for loader and re-exported types.
packages/loader/README.md Usage docs and integration overview for consumers.
packages/loader/package.json New package definition, scripts, exports, deps/peers.
packages/loader/oxlint.config.ts Lint configuration for the new package.
packages/loader/client.d.ts Ambient client-side typings for image imports.
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/loader/src/template.ts Outdated
Comment thread packages/loader/src/loader.ts
Comment thread packages/loader/test/loader.shim.mjs

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 16 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/loader/src/template.ts
Comment thread packages/loader/src/loader.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 16 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/loader/src/limit.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 16 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 79a0a82 into main Jul 21, 2026
9 checks passed
@dangreen
dangreen deleted the add-loader branch July 21, 2026 19:12
@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