Skip to content

refactor(webpack-plugin): refactor QiankunPlugin webpack for more bundler support later#3103

Merged
kuitos merged 9 commits intonextfrom
claude
Jan 15, 2026
Merged

refactor(webpack-plugin): refactor QiankunPlugin webpack for more bundler support later#3103
kuitos merged 9 commits intonextfrom
claude

Conversation

@kuitos
Copy link
Copy Markdown
Member

@kuitos kuitos commented Jan 10, 2026

  • Remove type assertion, use proper Webpack types with compatibility check
  • Fix Webpack 5 deprecated API usage
  • Add Webpack 5 processAssets hook to avoid deprecation warning
  • Preserve regex flags when appending 'g' flag
  • Reset lastIndex to avoid global regex stateful matching issues
  • Improve error handling by returning error objects instead of throwing
  • Remove unused PackageJson type fields
  • Add 6 unit tests for addEntryAttributeToScripts core logic

- Remove `as any` type assertion, use proper Webpack types with compatibility check
- Fix Webpack 5 deprecated `jsonpFunction` API usage (only use `chunkLoadingGlobal`)
- Fix Webpack 4 does not support `chunkLoadingGlobal` (only use `jsonpFunction`)
- Add Webpack 5 processAssets hook to avoid deprecation warning
- Preserve regex flags when appending 'g' flag
- Reset lastIndex to avoid global regex stateful matching issues
- Improve error handling by returning error objects instead of throwing
- Remove unused PackageJson type fields
- Add 6 unit tests for addEntryAttributeToScripts core logic

BREAKING CHANGE: None - maintains Webpack 4 and 5 compatibility
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Jan 10, 2026

🦋 Changeset detected

Latest commit: 29e3445

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@qiankunjs/bundler-plugin Patch
create-qiankun Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@vercel
Copy link
Copy Markdown

vercel Bot commented Jan 10, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
qiankun Error Error Jan 15, 2026 3:16pm

- Use feature detection instead of version detection for Webpack 4/5 compatibility
- Remove `as any` type assertion, use proper Webpack types with compatibility check
- Fix Webpack 5 deprecated `jsonpFunction` API usage (only use `chunkLoadingGlobal`)
- Fix Webpack 4 does not support `chunkLoadingGlobal` (only use `jsonpFunction`)
- Add Webpack 5 processAssets hook to avoid deprecation warning
- Preserve regex flags when appending 'g' flag
- Reset lastIndex to avoid global regex stateful matching issues
- Improve error handling by returning error objects instead of throwing
- Remove unused PackageJson type fields
- Add 6 unit tests for addEntryAttributeToScripts core logic

BREAKING CHANGE: None - maintains Webpack 4 and 5 compatibility
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 refactors the webpack plugin package with a significant architectural change: renaming from @qiankunjs/webpack-plugin to @qiankunjs/bundler-plugin, and rewriting the plugin implementation to use html-webpack-plugin hooks instead of cheerio for HTML manipulation. The plugin is renamed from QiankunPlugin to QiankunWebpackPlugin.

Changes:

  • Complete rewrite of the plugin using html-webpack-plugin hooks for better webpack integration
  • Improved entry script detection using webpack's compilation.entrypoints API
  • Removed regex-based pattern matching in favor of automatic detection
  • Better error handling with graceful fallbacks instead of throwing errors
  • Updated all templates, examples, and references across the codebase

Reviewed changes

Copilot reviewed 32 out of 39 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
packages/bundler-plugin/src/webpack/index.ts Complete rewrite of the webpack plugin with improved entrypoint detection
packages/bundler-plugin/package.json Package renamed, version reset, exports field added, webpack marked as optional
packages/bundler-plugin/tests/plugin.test.ts Replaced cheerio-based tests with integration tests using fixtures
packages/bundler-plugin/README.md New documentation focusing on webpack entrypoints approach
packages/bundler-plugin/CHANGELOG.md Changelog retained from old package
tsconfig.eslint.json Updated test path reference
packages/create-qiankun/template//.ejs Updated import and class names in all templates
examples/*/webpack.config.js Updated import and class names in examples
docs/ecosystem/bundler-plugin.md New concise documentation
docs/ecosystem/webpack-plugin.md Old detailed documentation removed
AGENTS.md New knowledge base file added
packages/*/AGENTS.md New knowledge base files for packages
Comments suppressed due to low confidence (2)

packages/bundler-plugin/package.json:40

  • Webpack is marked as optional in peerDependenciesMeta, but the plugin is specifically a webpack plugin and will not function without it. This might cause confusion. If the intention is to support other bundlers in the future (as suggested by the package name "bundler-plugin"), consider keeping webpack optional, but document this clearly. Otherwise, webpack should be a required peer dependency.
    packages/bundler-plugin/package.json:3
  • The version has been reset from "0.0.1-rc.4" to "0.0.1-rc.0". This appears to be a regression as the CHANGELOG shows versions up to rc.4. The version should likely be "0.0.1-rc.5" or higher to maintain version progression.

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

Comment thread packages/bundler-plugin/src/webpack/index.ts
Comment thread packages/bundler-plugin/src/webpack/index.ts
Comment thread packages/bundler-plugin/src/webpack/index.ts Outdated
Comment thread AGENTS.md Outdated
Comment thread packages/bundler-plugin/src/webpack/index.ts Outdated
Comment thread packages/bundler-plugin/src/webpack/index.ts
Comment thread packages/bundler-plugin/src/webpack/index.ts
Comment thread packages/bundler-plugin/src/webpack/index.ts Outdated
@kuitos kuitos changed the title fix: improve QiankunPlugin webpack compatibility and error handling refactor(webpack-plugin): refactor QiankunPlugin webpack for more bundler support later Jan 14, 2026
# Conflicts:
#	packages/create-qiankun/template/react18-webpack-sub/config-overrides.js
#	packages/create-qiankun/template/react18-webpack-sub/package.json.ejs
#	packages/create-qiankun/template/vue2-webpack-sub/package.json.ejs
#	packages/create-qiankun/template/vue2-webpack-sub/vue.config.js.ejs
#	packages/create-qiankun/template/vue3-webpack-sub/package.json.ejs
#	packages/create-qiankun/template/vue3-webpack-sub/vue.config.js.ejs
#	pnpm-lock.yaml
@kuitos kuitos merged commit fa128ee into next Jan 15, 2026
6 of 7 checks passed
@kuitos kuitos deleted the claude branch January 15, 2026 15:50
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.

2 participants