Repository navigation
fix(plugin-utils): match include package names exactly - #914
Merged
Merged
Conversation
`createNodeModulesExcludeRegex` joined the `include` names into the regex unescaped and matched them anywhere after `node_modules`. `foo.bar` also compiled `node_modules/fooXbar`, `pkg` also compiled `@scope/pkg`, and `foo+bar` never matched itself. Escape each name and match it only as a whole package directory right under a `node_modules` directory. Vite and Rsbuild now build the matcher once per plugin instead of on every transformed module. Refs #686 (PLG-05, PLG-28) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ack rules Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…odules A dependency nested in an included package's own `node_modules` was compiled with it, because the name could match anywhere in the path. The package a file belongs to is the directory right under its innermost `node_modules` (pnpm and Bun stores included), so match the names only there. Refs #686 (PLG-05) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests.
🚀 New features to boost your workflow:
|
owjs3901
added a commit
that referenced
this pull request
Nov 15, 2026
The source onLoad filter accepted .js only under @devup-ui/, and the plugin had no include option, so a library that ships Devup UI components as uncompiled .js reached the runtime stubs. DevupUI and register take include, and the filter also accepts .js of each listed package. A package is the directory right under the innermost node_modules, so pnpm and Bun stores match, and names are escaped and matched whole, the same rules as createNodeModulesExcludeRegex in #914: pkg is not pkg-extra or @scope/pkg, foo.bar is not fooXbar, and the dependencies in an included package's own node_modules stay out. Refs #686 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Nov 15, 2026
owjs3901
added a commit
that referenced
this pull request
Nov 15, 2026
Conflicts in rsbuild-plugin/src/plugin.ts:
- writeDataFiles: kept main's sequential mkdir and stylesheet write
(the cold-start ENOENT fix) and returned this branch's
{ tailwindFiles, configFiles }.
- JS transform: kept main's hoisted excludeRegex (#914) and added this
branch's addMissingDependency and config-file dependencies.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
owjs3901
added a commit
that referenced
this pull request
Nov 15, 2026
Conflicts: - rsbuild-plugin/src/plugin.ts: kept this branch's shared extractModule handler for the source and MDX post transforms, using main's hoisted excludeRegex (#914) in it. - vite-plugin/src/plugin.ts: kept both extractModule (this branch) and main's removeSource (#951); extractModule uses main's excludeRegex, and the pre transform stays a SOURCE_FILE_RE check plus extractModule. - webpack-plugin/src/__tests__/plugin.test.ts (no textual conflict): the MDX post-rule test now expects #914's exact package exclude regex. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
owjs3901
added a commit
that referenced
this pull request
Nov 15, 2026
Conflicts: - webpack, Rsbuild and Vite plugin.ts imports: kept main's setupWarning (#945) next to this branch's SOURCE_FILE_REGEX. - Rsbuild transform: kept this branch's `environment` parameter, with main's hoisted excludeRegex (#914) in place of the per-call createNodeModulesExcludeRegex(include). - Vite transform: kept this branch's SOURCE_FILE_REGEX check, with main's hoisted excludeRegex. - Bun loadSourceFile: kept main's runtime sheet write, which writes only the sheet a module changed (#942), and this branch's withDependencyImports return. Dropped from this branch in favor of main: the per-call exclude regex in the Rsbuild and Vite transforms (#914) and the unconditional runtime sheet write in Bun (#942). Also updated the "Compiled Files" section that #949 added to the Bun README: `.mts`/`.cts` are compiled, and `Bun.build` compiles the project's own `.js`/`.cjs` outside node_modules. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
4 of 6 tasks
owjs3901
added a commit
that referenced
this pull request
Nov 17, 2026
The source onLoad filter accepted .js only under @devup-ui/, and the plugin had no include option, so a library that ships Devup UI components as uncompiled .js reached the runtime stubs. DevupUI and register take include, and the filter also accepts .js of each listed package. A package is the directory right under the innermost node_modules, so pnpm and Bun stores match, and names are escaped and matched whole, the same rules as createNodeModulesExcludeRegex in #914: pkg is not pkg-extra or @scope/pkg, foo.bar is not fooXbar, and the dependencies in an included package's own node_modules stay out. Refs #686 Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
#686의 PLG-05, PLG-28을 고칩니다.
createNodeModulesExcludeRegex가include이름을 escape하지 않고 정규식에 넣었고,node_modules뒤 어디에서든 이름이 나오면 포함으로 봤습니다.include: ['foo.bar']이node_modules/fooXbar도 컴파일했습니다.include: ['pkg']이node_modules/@scope/pkg,node_modules/pkg-extra도 컴파일했습니다.include: ['foo+bar']는 자기 자신과 맞지 않았습니다.node_modules에 있는 의존성(node_modules/@devup-ui/react/node_modules/lodash)도 함께 컴파일했습니다.node_modules바로 아래 디렉터리로 보고, 이름을 escape한 뒤 그 디렉터리 전체와 일치할 때만 포함합니다. Windows 경로와 pnpm·Bun store 경로(node_modules/.pnpm/pkg@1.0.0/node_modules/pkg/...)는 그대로 포함됩니다.#755와 겹치는 부분
#755(fix/plugin-core, 병합되지 않음)도 같은 함수를 고칩니다. 가장 안쪽
node_modules기준은 같은 방향입니다. 이 PR은 main에서 새로 만들었고, #755 브랜치는 건드리지 않았습니다.새로 생기는 오류
없음.
Test plan
plugin-utilsshared.test.ts:foo.bar/fooXbar,pkg/@scope/pkg/pkg-extra,foo+bar, 중첩node_modules, Windows·pnpm·Bun store 경로plugin.test.ts, viteplugin.test.ts로컬 통과. webpack·Turbopack rule의 정규식 기대값은 새 패턴으로 바꿨습니다.Refs #686
🤖 Generated with Claude Code