Repository navigation
[experimental] export: a package linked from a folder inside the project is a package, so --reverse gives the page back - #12733
josephfarina wants to merge 7 commits into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
There was a problem hiding this comment.
Changes requested: one regression in which files the export carries.
The fix works for pages that import a linked package by its name: the three new tests fail on the base with ERR_RENDER_SOURCE_DAMAGED and pass here, and the markup, stylesheet and page script are unchanged.
Blocking
page-worker.mjs:1926-1935(and the same folder-only test at:786,:814and:866) drops a file that the page imports by a relative path from a linked folder, such as./vendor/badge/src/index.jswhilenode_modules/@acme/rellinksvendor/badge, without carrying it or recording it as not carried, so a page that came back exactly before now comes back withexact: falseand that file inmissing; carry such a target when a carried module imports it by a relative path, skip a linked stylesheet or JSON file only when its importer is not carried, and add a test for that layout.
Once that is fixed and tested, the rest of the change is ready.
Claims and files checked
Review mode: full; reason: no-earlier-review
Claims
- Changeset: a package that
node_moduleslinks into the project is treated as a package, and--reversegives the page back exactly: verified for imports by package name (the three new tests inrender.test.mjspass here and fail on the base); false for a page that imports the linked folder by a relative path (the blocking finding). - Changeset: the page looks and runs the same: verified; the stylesheet, page script and rendered markup are byte-identical between base and head for the linked layouts.
- Body: before the change,
--reverserefuses such a file as damaged: verified (ERR_RENDER_SOURCE_DAMAGEDon the base for all three layouts). - Body: Node gives the export the real path, so it carried those modules as page files: verified (
isLocalis path-based,page-worker.mjs:228; the base carries the package modules). - Body: the export still compiles and draws the package with the same styles, server render and script: verified (same comparison).
- Body: a linked package's modules are not carried or followed as page files: verified (
page-worker.mjs:1183,:1926). - Body: images a linked package imports stay carried: verified (
render.test.mjs:565expectsvendor/kit/src/parts/logo.png; the asset site atpage-worker.mjs:880is unchanged). - Body:
linkedPackageRoots()reads eachnode_modulesfolder (with@scope/*) from the page's folder up and keeps symlinks into the carried folder, outsidenode_modules, that do not hold the page: verified (page-worker.mjs:243-283). - Body: a file under such a root still compiles but is not carried or followed: verified; this is also the source of the blocking finding.
- Body: with no link, every path is as before: verified (an empty root list short-circuits at
page-worker.mjs:286; a no-link page renders the same on base and head). - Body: the pnpm workspace app, the pnpm store, a CommonJS package and a plain ES module package behave as before: verified (the head test passes; none of them links into the carried folder).
- Body: for the linked layouts only the embedded source block changes, and it is smaller: verified (it is about half the size; the note's list of carried files shrinks with it).
- Body: a second export gives the same file: verified for the rendered markup, which the tests compare.
- Body: one defect is restored, with no new public API and no internal context: verified.
- Body: the listed Vitest suite passes at this head, as do eslint and the CLI typechecks: verified (24 files and 860 tests passed, 3 skipped; eslint and both typecheck projects pass).
Files
.changeset/export-linked-package.md: clear (a patch for an experimental command; its claim holds for package-name imports).packages/cli/api/render/render.test.mjs: finding; no test covers a relative import into a linked folder.packages/cli/foundation/render/page-worker.mjs: finding; the blocking relative-import drop.
There was a problem hiding this comment.
Changes requested: two fixes before this can land.
The earlier relative-import regression is fixed: a page that imports a linked folder's files by a relative path now gets a file byte-identical to the base's and comes back exactly, and three of the new tests fail on the base and pass here.
Blocking
- Miss:
.changeset/export-linked-package.mdfailsnode scripts/check-changesets.mjs(run by the Lint workflow's repository guardrails step) because its body has no[category]tag and credits@josephfarinaon the headline instead of on its own line, so start it with[experimental]asspec:AST-017FR22 requires and move the credit to its own line. - When a page imports a linked package by name and a later module of its own reaches a stylesheet inside that package by a relative path (
own.jsimporting./vendor/kit/src/parts/badge.css, or a package file such aslabel.jsimporting./label.css),page-worker.mjs:901-903decides that stylesheet's carry only at its first import, so the file neither carries nor records it while its note says the page can come back exactly, and--reversereturnsexact: falsewith the stylesheet inmissing; carry such a stylesheet in the post-render walk (or take the decision out of the inline-once guard) and add a test where the package loads before the page's own module reaches its file.
Claims and files checked
Review mode: incremental; reason: none
- Claim: a package linked into the project (npm link, a file dependency, a workspace package) is treated as a package, so the reverse gives the page back exactly. Verified: red-first tests fail on the base with a damaged-source refusal and pass here; probes.
- Claim: the page looks and runs the same. Verified: stylesheet, page script and markup are byte-identical to the base's.
- Claim: the changeset is a valid release note. False: no category tag, credit not on its own line (changeset check exits 1).
- Claim: on the base, the reverse refuses these layouts as damaged. Verified: red-first runs for the npm link, styles/JSON/image and workspace-root layouts.
- Claim: the search lists each node_modules from the page's folder up, with scopes, and keeps links into the carried folder that sit outside node_modules and do not hold the page. Verified:
page-worker.mjs:243-283. - Claim: a linked file that a carried file imports by a relative path is carried as before. Verified for direct and mixed imports (new relative-import test, probes); false when the package loaded first (second blocking finding).
- Claim: stylesheet, JSON and raw imports use the same importer check. Partly false: the stylesheet check runs once per stylesheet (
page-worker.mjs:901-903). - Claim: with no link, every path is as before. Verified: code, and byte-identical files for the no-link, pnpm store, pnpm workspace app and ES module layouts.
- Claim: images a linked package imports stay carried. Verified: the styles/JSON/images test.
- Claim: each fixed layout exports, reverses exactly, and a second export gives the same file. Verified: probes.
- Claim: a CommonJS package is unchanged. Verified by its round trip on the head; not compared byte-for-byte with the base.
- Claim: a 3,935-case corpus is byte-identical. Not reproducible here; the corpus is not in the repository.
- Claim: the listed tests, eslint and the CLI typechecks pass. Verified: 861 passed, 3 skipped; eslint and typecheck exit 0.
- File
.changeset/export-linked-package.md: finding (category tag and credit line). - File
packages/cli/api/render/render.test.mjs: clear; the late-loading layout has no test yet (second finding). - File
packages/cli/foundation/render/page-worker.mjs: finding (stylesheet carry at lines 901-903).
…ect is a package, so --reverse gives the page back
…ports by a relative path
…s stylesheet is carried [skip ci]
… alias are carried; a linked package's @import stays the package's [skip ci]
…d package keeps the rest [skip ci]
…the images its modules name [skip ci]
49f0d4a to
3f5bd34
Compare
…h any quote [skip ci]
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 its latest commits skip CI.
Pages that import a package linked inside their own project now come back exactly from --reverse: eight of the ten new tests fail on main with the damaged-source refusal and pass here, and the exported file's markup, styles and script are unchanged. Both earlier findings (a relative import into a linked folder, and a linked stylesheet reached after the package loaded) are fixed and covered by tests.
Claims and files checked
Review mode: full; reason: rebase
- Claim: a package linked into the project (npm link, a file dependency, a workspace package) is treated as a package, so the reverse gives the page back exactly. Verified: eight new tests fail on main with a damaged-source refusal and pass here.
- Claim: the page looks and runs the same. Verified: the markup, stylesheet and script match main's byte for byte in every linked layout probed.
- Claim: the release note is a valid experimental patch note. Verified: the changeset check passes.
- Claim: on main, the reverse refuses these layouts as damaged. Verified: red-first runs.
- Claim: the search reads each node_modules folder from the page's folder up, with scopes, keeps links into the carried folder that sit outside node_modules and do not hold the page, and also reads each linked package's node_modules. Verified:
page-worker.mjs:245-300and the nested workspace test. - Claim: with a link, the file carries what the page reaches by a path, through relative and path-alias imports of modules, JSON, stylesheets and raw files. Verified:
page-worker.mjs:1685-1723and the relative, alias and late-reach tests. - Claim: a linked package's files reached only by its name, and project files only it imports, are neither carried nor named as not carried. Verified: the project-file test and probes.
- Claim: images stay carried, including one a linked module names only as a string for the script. Verified: the styles, JSON and images test and the script-image test.
- Claim: with a link, a stylesheet another pulls in with @import is carried when any carried stylesheet imports it, whichever imported it first. Verified:
render-page.mjs:1419-1437, the shared-stylesheet test, and probes in both load orders. - Claim: with no link, every path is as before. Verified: code, and identical files for layouts with no link and for a project whose link the page never uses.
- Claim: each fixed layout exports, reverses exactly, and the restored page renders the same markup again. Verified: tests and probes.
- Claim: the pnpm workspace app, pnpm store, CommonJS, ES module and relative-import layouts are unchanged. Verified: the same size, markup, styles, script and carried files as main.
- Claim: a 3,935-case corpus is byte-identical before and after. Not reproducible here: the corpus is not in the repository.
- Claim: the listed tests, the changeset check, eslint and the CLI typechecks pass. Verified: 868 passed and 3 skipped; the other checks exit 0.
- File
.changeset/export-linked-package.md: clear. - File
packages/cli/api/render/render.test.mjs: clear. - File
packages/cli/foundation/render/page-worker.mjs: clear. - File
packages/cli/foundation/render/render-page.mjs: clear.
There was a problem hiding this comment.
Approved pending CI: CI has not run on this head yet, because its latest commit skips CI.
Pages that import a package linked inside their own project (npm link, a file: dependency, a workspace package) now come back exactly from --reverse: eight of the ten new tests fail on the base with the damaged-source refusal and pass here. The latest commit makes the late-image test check the script for the image path in any quote style, so it can now fail; no other code changed since the last review.
Claims and files checked
Review mode: incremental; reason: none
- Claim: a package linked inside the project (npm link, a file dependency, a workspace package) is treated as a package, its modules are no longer carried, and the reverse gives the page back exactly instead of refusing it. Verified: eight new tests fail on the base with a damaged-source refusal and pass here.
- Claim: the page looks and runs the same. Verified: earlier base-against-head probes, on product code unchanged since, show the same markup, stylesheet and script for every linked layout.
- Claim: the release note is a valid experimental patch note. Verified: the changeset check passes.
- Claim: Node reports a linked package's real path inside the project, so the export carried its modules and the reverse never reached them. Verified: the base's refusal names exactly those modules.
- Claim: the page still compiles and draws as before, with the same styles, server render and script. Verified: the compile path is unchanged; only the carried list changes.
- Claim: images a linked package imports stay carried. Verified: the styles, JSON and images test.
- Claim: the search reads each node_modules folder from the page's folder up, with scopes, keeps links into the project that sit outside node_modules and do not hold the page, and also reads each linked package's node_modules. Verified:
page-worker.mjs:245-305and the nested workspace test. - Claim: with a link, the file carries what the page reaches by a path, through relative or path-alias imports of modules, JSON, stylesheets and raw files. Verified:
page-worker.mjs:1685-1723and the relative, alias and late-reach tests. - Claim: a linked package's files reached only by its name, and project files only it imports, are neither carried nor named as not carried. Verified: the project-file test.
- Claim: an image only a linked module names for the script is carried and rewritten for it. Verified: the late-image test, which now fails if the script keeps the path in any quote style.
- Claim: with a link, a stylesheet another pulls in with @import is carried when any carried stylesheet imports it, whichever imported it first. Verified:
render-page.mjs:304and:1419-1437, and the shared-stylesheet test. - Claim: with no link, every path is as before. Verified: each new branch runs only with a link, and the unchanged-layout test passes.
- Claim: each fixed layout exports, reverses exactly, and renders the same again. Verified: each test renders the restored page again and gets the same markup.
- Claim: the workspace app, pnpm store, CommonJS, ES module and relative-import layouts give byte-identical files. Verified: earlier probes on the same product code give the same bytes.
- Claim: a 3,935-case corpus is byte-identical before and after. Not reproducible here: the corpus is not in the repository.
- Claim: the listed tests, the changeset check, eslint and the CLI typechecks pass. Verified: 868 passed and 3 skipped; the other checks exit 0.
- Claim: the author's preflight passed at this head. Not reproducible here; the scoped checks it names pass.
- Claim: one defect is restored, with no tagalong, no new public API, default or interaction, and no internal context. Verified: one carry rule changes, no export or option changes, and no internal reference is added.
- File
.changeset/export-linked-package.md: clear. - File
packages/cli/api/render/render.test.mjs: clear. - File
packages/cli/foundation/render/page-worker.mjs: clear. - File
packages/cli/foundation/render/render-page.mjs: clear.
- #12367 [experimental] export: checks the file it wrote and names the one file to share Author: @josephfarina - #12405 [experimental] export: the size output names each part of the file under its JSON key Author: @josephfarina - #12295 fix(Markdown): keep task lists inside their column Author: @josephfarina - #12696 docs: Toast needs no provider; Table hooks name their row-type generic Author: @josephfarina - #12733 [experimental] export: a package linked from a folder inside the project is a package, so --reverse gives the page back Author: @josephfarina
|
Landed in #12859. |
User impact
Someone exports a page that imports a package linked from a folder inside the same project:
npm link, afile:dependency, or a workspace package thatnode_moduleslinks to its own folder. Then they give the file back withastryx experimental export --reverse. The reverse refuses the file as damaged, so the page cannot come back, even though the export looked fine.Problem and solution fit
node_modules, so the export carried those modules as page files. The page imports them by package name, so the reverse never reached them from the page, and it read the carried set as damaged.--reverseis the way back to an editable page, and it fails for a common project layout.The fix treats a package that
node_moduleslinks to a folder inside the project as a package. The export still compiles and draws it as today, with the same styles, server render and page script, but it does not carry its modules as page files or follow their imports as page files. Images a linked package imports stay carried.Expected behavior and authority
--reversegives back the page as written, withexact: truewhen every carried file comes back (architecture:cli-surface, the export guide). A package is not a page file, wherever its folder is.Smallest restoration
foundation/render/page-worker.mjs:linkedPackageRoots()lists the top level (with@scope/*) of eachnode_modulesfolder from the page's folder up. An entry that is a symlink whose real path is inside the carried folder, outsidenode_modulesand not a folder that holds the page is a linked package root. Thenode_modulesfolders of each linked package (and of the folders above it) are read too, as a workspace links one package into another. Compiling, the server render and the page's script are unchanged.--reversewalks it: from the page through each relative or path-alias import of a carried module (modules, JSON, stylesheets,?rawfiles). A linked package's files that the page reaches only through the package's name stay the package's, and so do the project files that only the package's modules import: none is carried or named as not carried. Images stay carried, because the page's script reads them from the file, and an image that only a linked package's module names as a string (drawn later by the script) is still carried and rewritten for the script.foundation/render/render-page.mjs: with a linked root, a stylesheet another one pulls in with@importis carried when any carried stylesheet imports it, whichever imported it first.Evidence
npm linklayout, afile:dependency, a linked package with CSS, JSON and an image, and a workspace root that links its own package each export, then--reverserefuses the file as damaged.--reverseis exact, and a second export gives the same file. For the linked layouts, the markup, the stylesheet and the page's script are byte-identical before and after; only the embedded source block and the list of carried files in the note at the top of the file are smaller.--reversecorpus (no links into a carried folder) is byte-identical before and after, apart from pages that differ between two runs of the same CLI (random values, clocks): 0 exit-code changes, 0 message changes, 0--reversechanges.api/render/render.test.mjs("what a page imports"): the link andfile:round trips, the linked package's styles, JSON and images, a linked folder the page imports by a relative path (carried,exact: true), a linked folder the page imports through a path alias (carried,exact: true, nothing missing when restored outside the project), a linked package that loads before the page's own module reaches its files and stylesheets by their paths (carried,exact: true), a linked package stylesheet that@imports another (inlined, not carried,exact: true), a stylesheet that both the package's and the page's own stylesheets import (carried), a project file that only the linked package imports (not carried, nothing missing), a workspace package that another linked package links in (not carried,exact: true), an image only a linked package's module names for the script (carried), the workspace control, and the unchanged layouts.Scope
Components: cli export (
foundation/render/page-worker.mjs)Testing
pnpm exec vitest run --project node packages/cli/api/render packages/cli/foundation/render packages/cli/test/export-name.test.mjs packages/cli/foundation/doc-compiler/doc-loads.test.mjs packages/cli/test/lazy-dependencies.test.mjs packages/cli/clients/cli/commands/text-json-parity.test.mjs(all pass at this head).node scripts/check-changesets.mjs.preflight: pass 14b1187 (test-node left to the batch: 1646 files)