Repository navigation
fix(cli): swizzle copies the private attribute owner modules a component imports - #10085
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
PR Analysis Report🔎 Preview ·
|
a5b1b4f to
58cd85d
Compare
|
/approve-spec 58cd85d |
58cd85d to
905cfc3
Compare
|
/approve-spec 905cfc3 |
There was a problem hiding this comment.
Changes requested. The owner-module copy works, and the swizzle tests pass. The spec record, the changeset and the CLI output still need to match what the copy now does.
spec:AST-110FR2, its Verification row and the Current-state impact bullet still say a helper that differs is never replaced, even with--overwrite, and that the result marks each helper as written, reused or version-suffixed; both contradict the new FR4 and the code for owner modules, so amend them to agree.- The changeset says swizzled
RadioListandTreeListcompile, but their copies still import@astryxdesign/core/utils/touchHitArea.stylexand@astryxdesign/core/motion, which core does not export, so drop "so it compiles". - The CLI prints
Copied N files to <component folder>/while some of those files land in siblingprivateAttributes/andmotion/folders, and--overwritereplaces a shared module another copy uses without saying so; name the shared modules written or replaced outside the component folder. - Minor: a failed shared-module write leaves the empty component folder and
privateAttributes/folder behind, unlike a failed component-file write, so remove the folders the run created.
The FR4 rule itself is approved for this head, so no spec decision is pending.
[Automated review]
| imports of modules the package exports are rewritten to their package | ||
| subpaths, as the component's own files are; unexported dependencies keep | ||
| their relative imports in the same layout. Re-swizzling skips an identical | ||
| existing copy and refuses a changed one without `--overwrite`. |
There was a problem hiding this comment.
FR4 now refuses a changed shared copy without --overwrite and replaces it with it, as the code does. FR2 (lines 77-81), its Verification row and the Current-state impact bullet (lines 165-170) still say a helper that differs is never overwritten, even with --overwrite, and that the result marks each helper as written, reused or version-suffixed. Owner modules are such helpers, so please amend those lines to agree, for example by exempting owner modules from FR2's rule.
| '@astryxdesign/cli': patch | ||
| --- | ||
|
|
||
| [fix] `astryx swizzle` now copies the private attribute owner modules a component imports, and the unexported style modules they need, beside the copy in the package's layout. A swizzled `Item`, `CheckboxList`, `RadioList` or `TreeList` no longer imports a `privateAttributes/*.stylex` subpath that `@astryxdesign/core` does not export, so it compiles. A second swizzle reuses an identical copy and refuses a changed one without `--overwrite`. The receipt's `files` and `filesCopied` include the modules it copied. |
There was a problem hiding this comment.
"so it compiles" overstates this for two of the four: a swizzled RadioList still imports @astryxdesign/core/utils/touchHitArea.stylex (from RadioListItem.tsx:37) and TreeList imports @astryxdesign/core/motion (from TreeList.tsx:40), and core exports neither. Suggest ending the sentence at "…that @astryxdesign/core does not export."
| // carries beside the component (spec:AST-110 FR4) are its files too. | ||
| files: [ | ||
| ...copiedFiles.map(f => f), | ||
| ...shared.map(m => path.relative(outputDir, m.dest).split(path.sep).join('/')), |
There was a problem hiding this comment.
These entries sit outside outputDir, and filesCopied counts them. The CLI renderer still prints [ok] Copied ${filesCopied} files to ${outputDir}/ (clients/cli/commands/swizzle.mjs:85). Swizzling Item reports 10 files in Item/ when two are in privateAttributes/ and motion/, and --overwrite replaces a shared module another copy uses without saying so. Please name the shared modules written or replaced in the human output.
| } catch (err) { | ||
| const unrestored = undoCopy(written); | ||
| throw writeFailed(module.dest, cwd, err, unrestored); | ||
| } |
There was a problem hiding this comment.
Minor: unlike the component loop above (lines 563-571), this failure path does not remove the component folder this run created, nor the privateAttributes/ folder it just made. A failed shared write leaves both behind, empty.
905cfc3 to
46009de
Compare
|
/approve-spec 46009de |
There was a problem hiding this comment.
Changes requested. The owner-module copy works: the swizzle tests pass, every owner-module import in the nine affected copies now resolves to a file the run wrote, and an engineering owner approved the spec:AST-110 changes for this head.
- Miss:
architecture:interaction-modalityINV3 still says "Swizzle does not yet carry an unexported owner module into an ejected copy" (docs/architecture/interaction-modality.md:150-151), which this change makes false, so please delete that sentence as you did for the FR4 gap inspec:AST-110.
Optional: swizzle()'s doc and both receipt descriptions still call files the written file names and say escaping imports are rewritten, and the text output still says relative imports were rewritten right above shared modules whose imports stay relative. A new commit needs a fresh /approve-spec for its head.
[Automated review]
| imports is copied whole and unedited, so callers, the copy included, still | ||
| never write the attribute by hand. | ||
| imports travels with the copy, so callers, the copy included, still never | ||
| write the attribute by hand. Swizzle copies an imported owner module, and any |
There was a problem hiding this comment.
Miss: with this rule in place, architecture:interaction-modality INV3 still says "Swizzle does not yet carry an unexported owner module into an ejected copy." (docs/architecture/interaction-modality.md:150-151). Please delete that sentence in this pull request, as you removed FR4's gap here.
…ent imports A swizzled Item, CheckboxList, RadioList or TreeList imported `@astryxdesign/core/privateAttributes/press.stylex`, which core does not export, so it failed to compile. Swizzle now copies each owner module the component imports, and the unexported style modules it imports, whole beside the copy in the package's layout, keeping those imports relative (spec:AST-110 FR4). A second swizzle reuses an identical copy and refuses a changed one without --overwrite.
46009de to
c035bc9
Compare
|
/approve-spec c035bc9 |
There was a problem hiding this comment.
Approved pending CI: CI has not run on this head yet because the pull request is a draft, and it runs once the pull request is marked ready for review.
The owner-module copy matches the spec:AST-110 changes an engineering owner approved for this head: the new tests fail on main and pass here, and every owner-module import in the nine affected copies resolves to a file the run wrote.
- Optional:
swizzle()'s doc (packages/cli/api/swizzle/swizzle.doc.mjs) still says escaping imports are rewritten to package subpaths; one clause on the carried owner modules would match the updated receipt description.
A new commit needs a fresh /approve-spec for its head.
[Automated review]
Rebuilds the recursive copy on main's swizzle, which since meta#10085 also carries the private attribute owner modules a component imports. - A Core component's nested folders are copied (Table's plugins/), and an integration's folder stays flat. One sorted file list drives the pre-flight, the copy and the receipt; the owner-module walk reads each nested file from its own folder. - Imports that stay inside the component (../types from plugins/) stay relative; imports that leave it are rewritten to the owner package. - __tests__ and __snapshots__ folders and *.spec.ts(x) browser harnesses are left out at every depth (Markdown's headingLinks chromium spec). - Destination symlinks follow spec:AST-017 FR1/FR5: a folder linked elsewhere inside the project is written through, as released; a link out of the project is still refused by the existing confinement check. The blanket refusal of every destination symlink is dropped. - A destination held by the wrong kind of entry is refused before any write, even with --overwrite; a failed copy removes the folders it made. - The rewriteImports depth parameter is not carried: main's keep predicate covers it, and the copy tests check the depth behaviour end to end.
User impact
This affects people who run
astryx swizzleon a component that imports a private data attribute's owner module, such asItem,CheckboxList,RadioListorTreeListtoday, andButtononce its touch press layer lands.../privateAttributes/press.stylexto@astryxdesign/core/privateAttributes/press.stylex.@astryxdesign/coredoesn't export that subpath (it is private byarchitecture:public-component-apiINV23), so the swizzled component fails to compile.<output>/privateAttributes/press.stylex.ts), with the unexported style modules it imports (<output>/motion/reducedMotion.stylex.ts). The component's import stays relative and resolves. The receipt'sfileslists them (relative to the component's folder, e.g.../privateAttributes/press.stylex.ts) andfilesCopiedcounts them, including an identical copy already in place. The text output adds one line,Shared modules: …, naming them.Buttononmain) copies exactly as before.Expected behavior and authority
spec:AST-110FR4: an owner module the component imports travels with the copy, whole. This pull request implements it and records the rule Specs & Decisions gave for it:It also removes FR4's known gap ("No private data-attribute owner module exists yet"): nine owner modules exist on
main. FR2, its Verification row and the Current-state impact bullet gain FR4's exception, as Specs & Decisions ruled: a differing helper is still never replaced, except an owner module and its unexported style modules, which FR4 governs. A version-suffixed second owner module would break INV23's single-owner guarantee.architecture:interaction-modalityINV3 drops its sentence "Swizzle does not yet carry an unexported owner module into an ejected copy", which this makes false. A new known gap records that the result doesn't yet say whether each shared module was written, reused or replaced; adding that receipt field is the CLI owner's call. Exporting the owner modules, or re-exporting their styles from a public module, would publish internals INV23 keeps private.Problem and solution fit
sharedModulesOfwalks the component's relative imports. It carries eachprivateAttributes/*.stylexmodule, then each carried module's imports of unexported.stylexmodules, transitively. Anything else keeps today's rewrite.rewriteImportstakes akeeppredicate, so imports of carried modules stay relative. Its default keeps every existing call unchanged.--overwrite, like the component's own files, and nothing is written. A failed write undoes the run's writes, shared modules included, and removes the folders the run created.Verification
copy.test.mjscases fail onmainand pass here.ItemcopiesprivateAttributes/press.stylex.tsandmotion/reducedMotion.stylex.ts, and keepsItem's import relative. Every@astryxdesign/core/*import in every copied file resolves in core's exports, and the owner module equals the package's except for its import specifiers.CheckboxList) reuses the identical owner module; an edited one is refused without--overwrite, with nothing written, and replaced with it.swizzle.test.mjs): it now swizzles Button and checks that every import in the copy resolves, either in core's exports or to a file the copy wrote. Before, it rewrote the source in memory, so a carried owner module counted as unresolved. It passes onmain's Button, and on Button with fix(core): a button's touch press release runs on the compositor #9783's touch press layer, which importsprivateAttributes/press.stylex.--overwritefails withERR_WRITE_FAILEDand leaves noItem/ormotion/folder behind. This fails on the previous head.swizzle.routing.test.mjsswizzles a fixture component with an owner module and an unexported style module, and checks theShared modules:line.swizzle()'s doc, theswizzle.copyreceipt description and the README table now callfilesthe copied file names, relative to the component folder, with owner modules beside it starting with../. TheShared modules:line notes that their imports between each other stay relative.json-apitype check, strict lint andcheck:changesets. The receipt's shape andapi-report.mdare unchanged.Scope
spec:AST-110FR4), in the CLI only.files.