Skip to content

🔧 chore: use utility function to build webpack config#187

Closed
SimonShiki wants to merge 11 commits into
feat/bundle-optfrom
feat/infra
Closed

🔧 chore: use utility function to build webpack config#187
SimonShiki wants to merge 11 commits into
feat/bundle-optfrom
feat/infra

Conversation

@SimonShiki
Copy link
Copy Markdown
Member

@SimonShiki SimonShiki commented Mar 10, 2026

Depends #182

Description

This PR maintains a universal set of webpack configuration rules and exposes a config builder to enable other packages to rapidly construct webpack configuration files.

Proposed Changes

  1. Add clipcc-infra package that used to infrastructure-related jobs, such as making webpack configuration.
  2. A utility function has been added to simplify the construction of webpack configurations.
  3. Automatic aliasing & rule merging for workspace packages. I introduced webpack.manifest.js to support this.

Test Coverage

See /packages/infra/tests

Additional Context

None

@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages Bot commented Mar 10, 2026

Deploying clipcc-preview with  Cloudflare Pages  Cloudflare Pages

Latest commit: 7af8f23
Status: ✅  Deploy successful!
Preview URL: https://58de5e4b.clipcc-preview.pages.dev
Branch Preview URL: https://feat-infra.clipcc-preview.pages.dev

View logs

Signed-off-by: SimonShiki <sinangentoo@gmail.com>
Signed-off-by: SimonShiki <sinangentoo@gmail.com>
Signed-off-by: SimonShiki <sinangentoo@gmail.com>
Signed-off-by: SimonShiki <sinangentoo@gmail.com>
Signed-off-by: SimonShiki <sinangentoo@gmail.com>
Signed-off-by: SimonShiki <sinangentoo@gmail.com>
Signed-off-by: SimonShiki <sinangentoo@gmail.com>
@SimonShiki SimonShiki marked this pull request as ready for review March 12, 2026 01:59
@SimonShiki SimonShiki requested a review from Copilot March 12, 2026 01:59
Copy link
Copy Markdown

Copilot AI left a comment

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 shared WebpackConfigBuilder utility (new packages/infra) and migrates multiple package-level webpack configs to a manifest-driven setup to reduce duplication and centralize defaults.

Changes:

  • Add packages/infra with a manifest-based webpack configuration builder and initial unit tests/docs.
  • Refactor webpack configurations for vm/storage/render/paint/l10n/gui/block/audio to use webpack.manifest.js + the shared builder.
  • Update workspace scripts/dependencies/lockfile to build and use the new infra package.

Reviewed changes

Copilot reviewed 30 out of 31 changed files in this pull request and generated 17 comments.

Show a summary per file
File Description
yarn.lock Updates lockfile for new/updated build dependencies.
packages/vm/webpack.manifest.js Adds VM webpack manifest consumed by the shared builder.
packages/vm/webpack.config.js Refactors VM webpack config to use WebpackConfigBuilder and the manifest.
packages/vm/package.json Adjusts VM dependencies/peerDependencies (incl. sb1 converter bump).
packages/storage/webpack.manifest.js Adds storage webpack manifest (incl. target/plugins).
packages/storage/webpack.config.js Refactors storage webpack config to use shared builder and generate multiple targets.
packages/render/webpack.manifest.js Adds render webpack manifest.
packages/render/webpack.config.js Refactors render webpack config to use shared builder.
packages/paint/webpack.manifest.js Adds paint webpack manifest (React/TS + asset rules).
packages/paint/webpack.config.js Refactors paint webpack config to use shared builder.
packages/l10n/webpack.manifest.js Adds l10n webpack manifest.
packages/l10n/webpack.config.js Refactors l10n webpack config to use shared builder.
packages/infra/tsconfig.dts.json Adds TS config to emit d.ts from JS for the infra package.
packages/infra/test/targets.test.js Adds initial tests for infra builder behavior.
packages/infra/src/index.js Implements WebpackConfigBuilder and manifest normalization/defaults.
packages/infra/package.json Defines new workspace package clipcc-webpack-configuration.
packages/infra/README.md Documents intended infra package usage/API.
packages/infra/LICENSE Adds license for infra package.
packages/infra/.gitignore Adds infra package ignore rules.
packages/infra/.gitattributes Adds infra package attributes (LF normalization).
packages/infra/.editorconfig Adds infra package editor configuration.
packages/gui/webpack.manifest.js Adds GUI webpack manifest (plugins/rules/workspacePackages).
packages/gui/webpack.config.js Refactors GUI webpack config to use shared builder + manifest.
packages/block/webpack.manifest.js Adds block webpack manifest (devtool, TS + extra rules).
packages/block/webpack.config.js Refactors block webpack config to use shared builder + manifest.
packages/block/eslint.config.mjs Updates eslint config to include webpack.manifest.js.
packages/audio/webpack.manifest.js Adds audio webpack manifest.
packages/audio/webpack.config.js Refactors audio webpack config to use shared builder + manifest.
packages/audio/package.json Updates audio main entry path to match new dist output structure.
package.json Ensures infra build runs as part of build:full and adds an infra workspace script alias.
UPSTREAM Records upstream reference for scratch-webpack-configuration.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Comment thread packages/storage/webpack.config.js
Comment thread packages/gui/webpack.config.js
Comment thread packages/infra/src/index.js
Comment thread packages/infra/README.md Outdated
Comment thread packages/paint/webpack.manifest.js
Comment thread packages/infra/src/index.js
Comment on lines +304 to +313
shouldSplitChunks: manifest.shouldSplitChunks ?? false,
rules: (manifest.rules ?? []).map(rule => normalizeRule(rootPath, rule)),
alias: normalizeAlias(rootPath, manifest.alias ?? {}),
plugins: manifest.plugins ?? [],
snapshot: normalizeSnapshot(rootPath, manifest.snapshot) ?? {},
target: manifest.target ?? 'web',
playground: manifest.playground ?? false,
workspacePackages: manifest.workspacePackages ?? [],
externals: manifest.externals ?? {}
};
Copy link

Copilot AI Mar 12, 2026

Choose a reason for hiding this comment

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

normalizeManifest() forces a default target: 'web', so get() will always emit a target field even when callers did not specify one. This contradicts the new unit test expectation for a "generic" config without a target, and can change webpack defaults/behavior. Consider leaving target undefined unless explicitly provided (or update the tests/docs to match the intended behavior).

Copilot uses AI. Check for mistakes.
Comment thread packages/l10n/webpack.config.js Outdated
Comment thread packages/block/webpack.config.js Outdated
Comment thread packages/storage/webpack.config.js
Signed-off-by: SimonShiki <sinangentoo@gmail.com>
Signed-off-by: SimonShiki <sinangentoo@gmail.com>
@SimonShiki SimonShiki requested a review from alexcui03 March 12, 2026 04:46
Signed-off-by: SimonShiki <sinangentoo@gmail.com>
@SimonShiki SimonShiki added the feature New feature or request label Mar 12, 2026
@SimonShiki SimonShiki self-assigned this Mar 12, 2026
@SimonShiki
Copy link
Copy Markdown
Member Author

Since we now use rules-inheritance-webpack-plugin, seems this pr becomes unnecessary now

@SimonShiki SimonShiki closed this Apr 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants