Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: support compileDependencies in speedup mode #6925

Merged
merged 1 commit into from
Aug 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/popular-buttons-behave.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@ice/rspack-config': patch
---

fix: support compileDendencies in speedup mode
11 changes: 10 additions & 1 deletion packages/rspack-config/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,16 @@ const getConfig: GetConfig = async (options) => {
if (!compileIncludes || compileIncludes?.length === 0) {
excludeRule = 'node_modules';
} else if (!compileIncludes?.includes('node_modules') && compileIncludes?.length > 0) {
excludeRule = `node_modules[\\/](?!${compileIncludes.map((pkg: string) => {
const flattenIncludes = [];
compileIncludes.forEach((pkg) => {
if (typeof pkg === 'string') {
flattenIncludes.push(pkg);
} else {
// The RegExp type of pkg may include multiple source paths.
flattenIncludes.push(...pkg.source.split('|'));
Copy link
Collaborator

Choose a reason for hiding this comment

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

如果是 \| 该如何应对?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

pkg 的原始数据是多个 npm 包 join 在一起的,不会存在这种场景,并且 speedup 模式不支持配置正则,参考

if (speedupMode) {
throw new Error('speedup mode does not support config compileDependencies as RegExp');
}
return dep.source;
} else if (typeof dep === 'string') {
// add default prefix of node_modules
const matchStr = speedupMode ? dep : `node_modules/?.+${dep}/`;
return matchStr;
}
return false;
})
.filter(Boolean)
.join('|'),

Copy link
Collaborator

Choose a reason for hiding this comment

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

ok

}
});
excludeRule = `node_modules[\\/](?!${flattenIncludes.map((pkg: string) => {
return `${pkg}[\\/]|_${pkg.replace('/', '_')}@[^/]+[\\/]`;
}).join('|')}).*`;
}
Expand Down
Loading