Repository navigation
Conversation
A stylesheet importing `calc` from `@vanilla-extract/css-utils` failed with "Cannot load '@vanilla-extract/css-utils' without a module resolver", and nothing aliased the package. - `@vanilla-extract/css-utils` joins the default import aliases; while it is aliased the build compiles `calc` itself - a `.css.ts` stylesheet evaluates the package's own `calc`, loaded without a resolver, so its operands may be anything the stylesheet computes (`vars.space.md`, `createVar()`); a `calc(x)` written as a CSS value without `.toString()` is a located error - any other module writes each `calc` call as the string the package builds: `calc.add/subtract/multiply/divide/negate`, chained `calc(x)` with `.toString()` or template interpolation, nested operations only parenthesized; operands must be literals, module-level `const`s holding a literal or other `calc` results, and anything else is a located error - `@devup-ui/react/compat/vanilla-extract-css-utils` declares the package - css-utils-literal-only reads `calc` calls as the build does - docs: the vanilla-extract migration page describes `calc` Refs #690 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
4 of 5 tasks
`bun test` aborted under the preloaded bun plugin with `index out of bounds: the len is 0 but the index is 19` while it compiled the ESLint plugin's own sources: - The alias pass analysed a module naming `@vanilla-extract/css-utils` to compile `calc`, which set the AST's reference IDs, but kept that table to itself: the pass's own lazy table stayed empty, so reading the module's calls for Emotion's `css` prop resolved those IDs against an empty table. The pass now builds one analysis and shares it. - The `undefined` absence proof analysed the program itself when the visit had no analysis, leaving IDs the visit's empty table could not resolve (pre-existing on main). It now analyses a copy. 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:
|
13 of 29 tasks
lib.rs keeps both module declarations and runs main's runtime_option_errors before this branch's calc errors. In the eslint plugin, main (#910) now reads the aliases from settings, so @vanilla-extract/css-utils joins its mirrored default table and calc bindings are recorded only while that alias is on, as the build does; import-settings.test.ts covers the alias turned off. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Pick up the #983 snapshot fix so CI runs against current main. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Bring in #963 (per-session engine state) and #928. The only conflict was the module list in libs/extractor/src/lib.rs, where main re-exports ExtractorCaches next to this branch's vanilla_extract_calc module; both are kept. The calc compiler adds no process-wide state, so nothing joins the session swap. 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
VE-05: nothing handled
calcfrom@vanilla-extract/css-utils, so importing it in a.css.tsstylesheet failed withCannot load '@vanilla-extract/css-utils' without a module resolver, and the package was not in the default alias table either. The build now compilescalcto the same strings the package (@vanilla-extract/css-utils0.1.6) produces.@vanilla-extract/css-utilstoDEFAULT_IMPORT_ALIASES(can be turned off withimportAliases: { '@vanilla-extract/css-utils': false }). Types come from@devup-ui/react/compat/vanilla-extract-css-utils, so the package does not need to be installed..css.tsstylesheets (module_loader/css_utils.rs): loads acalcimplementation identical to the package source as a module without a resolver and evaluates it as is. So operands can be any value the stylesheet computes, such asvars.space.mdorcreateVar(). Using acalc(x)chain as a CSS value without.toString()is an error with a location (a case that silently breaks in VE).vanilla_extract_calc.rs): in modules that are not evaluated, the alias pass replaces eachcalccall with a string literal and removes the import. Covered:calc.add/subtract/multiply/divide/negate, andcalc(x)chains +.toString()or template interpolation; nested operations dropcalcand keep only the parentheses, as the package does. Operands must be literals, module-levelconsts holding literals, or othercalcresults.file:line:col, cause, Fix): unreadable operands, readingcalcwithout calling it,calc(x)without.toString(), exports other thancalc, default imports, and namespace imports /require()/ re-exports in ordinary modules.ImportStoragerecords css-utilscalcbindings, andcss-utils-literal-onlyreadscalccalls as build-time values the same way the build does (following the@emotion/csspattern from PR fix(eslint-plugin): lint @emotion/css like the build #903).@vanilla-extract/css-utilssection to the vanilla-extract migration page and updated the rule README.Note: existing problem (out of scope for this PR)
If a
.css.tsstyle()contains the formg(f(1)).d(3).toString()(a call nested inside a chained call), the default test-thread stack (2 MiB) is not enough in debug builds and a stack overflow occurs, regardless ofcalc(it passes with 3 MiB). So this PR's tests extract on an 8 MiB thread. This needs to be looked into separately.Overlap with open PRs
style()naming. Text may overlap inmodule_loader.rsandimport_alias_visit.rs.DEFAULT_IMPORT_ALIASES/ the alias tests.Test plan
.css.tsimportingcalcfails withCannot load '@vanilla-extract/css-utils' without a module resolver, and an ordinary module fails withcss()"cannot usecalc.add(...)at build time"calc_gives_the_string_the_package_builds: compares 16 cases of strings returned by the real package in node, in both ordinary modules and.css.ts(nested, negate, chain, number/boolean operands,calcstring removal, constant operands)createThemevars,createVar) and namespace imports (insta snapshots)cargo test -p extractor --tests -j 2,cargo clippy -p extractor --all-targets -- -D warnings,cargo fmt --allbun testplugin-utils (merge-import-aliases, create-compat-types), next-plugin plugin.test, vite-plugin plugin.test (bunfig.vite.toml), eslint-plugin (import-storage / css-utils-literal-only 100% coverage)tsc --noEmit(eslint-plugin, plugin-utils),bun run test:types(react), prettier요약
VE-05:
@vanilla-extract/css-utils의calc를 처리하는 곳이 없어서,.css.ts스타일시트에서 import하면Cannot load '@vanilla-extract/css-utils' without a module resolver에러가 났고, 기본 alias 테이블에도 이 패키지가 없었습니다. 이제 빌드가calc를 패키지(@vanilla-extract/css-utils0.1.6)가 만드는 것과 같은 문자열로 컴파일합니다.@vanilla-extract/css-utils를DEFAULT_IMPORT_ALIASES에 추가했습니다 (importAliases: { '@vanilla-extract/css-utils': false }로 끌 수 있습니다). 타입은@devup-ui/react/compat/vanilla-extract-css-utils가 제공해서 패키지를 설치하지 않아도 됩니다..css.ts스타일시트(module_loader/css_utils.rs): 패키지 소스와 같은calc구현을 resolver 없이 모듈로 로드해서 그대로 평가합니다. 그래서 operand에vars.space.md,createVar()등 스타일시트가 계산하는 값을 무엇이든 쓸 수 있습니다..toString()없이calc(x)체인을 CSS 값으로 쓰면 위치가 붙은 에러가 납니다 (VE에서는 조용히 깨지는 경우).vanilla_extract_calc.rs): 평가하지 않는 모듈에서는 alias 패스에서 각calc호출을 문자열 리터럴로 바꾸고 import를 제거합니다. 대상은calc.add/subtract/multiply/divide/negate,calc(x)체인 +.toString()또는 템플릿 보간이고, 중첩 연산은 패키지처럼calc를 지우고 괄호만 남깁니다. operand는 리터럴, 리터럴을 담은 모듈 레벨const, 다른calc결과여야 합니다.file:line:col, 원인, Fix): 읽을 수 없는 operand, 호출하지 않은calc읽기,.toString()없는calc(x),calc외의 export, default import, 그리고 일반 모듈에서의 namespace import /require()/ re-export.ImportStorage가 css-utils의calc바인딩을 기록하고,css-utils-literal-only가 빌드와 같은 방식으로calc호출을 build-time 값으로 읽습니다 (PR #903의@emotion/css패턴을 따랐습니다).@vanilla-extract/css-utils섹션을 추가했고, 룰 README도 갱신했습니다.참고: 기존 문제 (이 PR 범위 밖)
.css.ts의style()안에g(f(1)).d(3).toString()형태(체인 호출 안에 호출이 들어간 경우)가 있으면,calc과 상관없이 debug 빌드에서 테스트 스레드 기본 스택(2 MiB)이 부족해 stack overflow가 납니다 (3 MiB면 통과합니다). 그래서 이 PR의 테스트는 8 MiB 스레드에서 추출합니다. 별도로 확인이 필요합니다.열린 PR과의 겹침
style()이름 처리를 건드리지 않습니다.module_loader.rs,import_alias_visit.rs에서 텍스트가 겹칠 수 있습니다.DEFAULT_IMPORT_ALIASES/ alias 테스트에서 충돌할 수 있습니다.테스트 계획
.css.ts가calc를 import하면Cannot load '@vanilla-extract/css-utils' without a module resolver, 일반 모듈은css()"cannot usecalc.add(...)at build time"으로 실패하는 것 확인calc_gives_the_string_the_package_builds: 실제 패키지가 node에서 반환한 문자열 16개 케이스를 일반 모듈과.css.ts양쪽에서 비교 (nested, negate, chain, number/boolean operand,calc문자열 제거, 상수 operand)createThemevars,createVar)와 namespace import (insta 스냅샷)cargo test -p extractor --tests -j 2,cargo clippy -p extractor --all-targets -- -D warnings,cargo fmt --allbun testplugin-utils (merge-import-aliases, create-compat-types), next-plugin plugin.test, vite-plugin plugin.test (bunfig.vite.toml), eslint-plugin (import-storage / css-utils-literal-only 100% 커버리지)tsc --noEmit(eslint-plugin, plugin-utils),bun run test:types(react), prettierRefs #690
🤖 Generated with Claude Code