Repository navigation
Move module browser scripts and Tinybird into their crates - #1423
Draft
jwrosewell wants to merge 6 commits into
Draft
jwrosewell wants to merge 6 commits into
jwrosewell wants to merge 6 commits into
Conversation
A vendor module's Rust lives in crates/<type>/<vendor>/, while its browser script, the script's tests and some test data live in the shared trusted-server-js crate. The design moves ten modules' scripts and tests into the nine crates that supply them, makes the build, the tests, the lint and format checks and editors find them there, and moves the Tinybird project into the Tinybird crate. It records what stays in the shared crate and why, being the APS renderer, which the browser core imports, Prebid, whose shim imports an npm package and whose bundle build the CLI runs from the shared crate, and the vendor names still in the browser core. Its review log records round 1.
Ten modules' browser scripts and their tests move from the shared trusted-server-js crate into the nine crates that supply the modules, as js/src/<module>/ and js/test/<module>/: datadome, didomi, google_tag_manager, gpt and gpt_diagnostics, lockr, osano, permutive, sourcepoint and testlight. The GPT tests' helper that locates gpt_bootstrap.js moves with them. moduleSourceDirs() in build-module-options.mjs and expected_module_ids in build/bundle_set.rs apply one rule, lib/src/integrations/<name> or crates/<type>/<crate>/js/src/<name>, refuse a name found in two places or the name core, and pass over a broken link, with tests on both sides. build.rs watches build-module-options.mjs and each crate's js/src folder that exists. Bundles keep their tsjs-<name>.js names, so the Rust API, served URLs and content hashes are unchanged, and all 14 built bundles are byte for byte the same as before. Scripts reach the shared browser code as @tsjs/core/... and @tsjs/shared/..., another module's code as @tsjs/module/<name>/..., and shared test data as @tsjs/test/.... tsconfig.json lists each crate's js/src folder for @tsjs/module, and a test checks the list. Vitest, ESLint and Prettier cover the crates' js/src and js/test folders, and crates/ holds a tsconfig.json, an ESLint config and a Prettier config so that editors and the npm scripts apply the shared settings there. The type gate covers the moved GPT diagnostics contract test. Comments and guides that named the old paths name the new ones. Three are comment lines in gpt_bootstrap.js, which the GPT module inlines into each page it changes, so readers receive those three lines with the new path, and the recorded page-change fixture changes with them. The tsjs guide now counts 13 source modules and 14 bundles, adding ec_client_fixed. The APS renderer stays in the shared crate because the browser core imports it, and Prebid stays because its shim imports an npm package and the ts prebid client command runs its bundle build from the shared crate.
The Tinybird project the analytics module sends to, its datasources, pipes, fixtures and tests, moves from tinybird/ at the repository root to crates/analytics/tinybird/project/, beside the module's Rust. Its README's links to the telemetry and configuration guides follow the move, the crate's README points at the project, the telemetry and configuration guides' links follow it, the Markdown format list in format.yml and AGENTS.md drops tinybird/**/*.md, which crates/**/*.md covers, and the changelog gives the new folder, because an operator runs tb from it.
Rust discovery passes over a module root that is a file, as the JavaScript side does. crates/tsconfig.json takes in the shared core's global.d.ts, so an editor checks a crate script as lib's TypeScript run does, and build.rs watches it, because Vite reads it when it compiles a crate script. The format check covers .mjs files and the configuration files in crates/, which crates/.prettierrc.json formats with lib's options. The design and the README say how ESLint finds the crates config, how modules kept in lib import each other, and that a Tinybird change starts the documentation proposal workflow, and the design's review log records round 2.
The module scripts design names #1423, the draft pull request that carries it, in its status and related pull requests, as the stack's other designs do.
jwrosewell
added a commit
to jwrosewell/trusted-server
that referenced
this pull request
Oct 20, 2026
The design of row 55, IABTechLab#1423, joins the specs pull request that carries every design of the stack, with the same text as on that row's branch.
The crate's tests run as WebAssembly under Viceroy in CI, where std::env::temp_dir panics, so the three discovery tests that built folders in a scratch tree aborted the cargo test job. The folder walk now hands what it found to module_ids, which applies the naming rules and is tested with in-memory folders. The JavaScript tests still walk a scratch tree. The design says why.
jwrosewell
added a commit
to jwrosewell/trusted-server
that referenced
this pull request
Oct 20, 2026
The design now says why the Rust discovery tests run without a file system, the same text as on the branch of IABTechLab#1423.
jwrosewell
added this pull request to stack #1422
October 20, 2026 07:11
This was referenced Oct 20, 2026
This branch has not been deployed
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
Changes
crates/trusted-server-js/libcrates/ad-tag/googlecrates/trusted-server-js/builddocs/superpowerscrates/trusted-server-js/build.rscrates/trusted-server-js/README.mdcrates/cmp/sourcepointdocs/guidecrates/.prettierrc.jsoncrates/eslint.config.jscrates/tsconfig.jsoncrates/analytics/tinybirdcrates/audience/permutivecrates/tag/google-tag-managercrates/testing/testlightcrates/bot-protection/datadomecrates/cmp/didomicrates/identity/lockrAGENTS.mdCHANGELOG.mdcrates/cmp/osano.github/workflowscrates/trusted-server-core/srcCloses
Part of #777
Spec
Spec: module-scripts-in-crates
Test plan
CI on this pull request at 5be1147 passed all 27 checks.
cargo test-fastly && cargo test-axumcargo clippy-fastly && cargo clippy-axumcargo fmt --all -- --checkcd crates/trusted-server-js/lib && npx vitest runcd crates/trusted-server-js/lib && npm run formatcd docs && npm run formatcargo build --package trusted-server-adapter-fastly --release --target wasm32-wasip1fastly compute serveChecklist
unwrap()in production code (clippy deniesunwrap_usedin CI)logmacros as AGENTS.md asks (notprintln!)Stacks on the asset routes served on every adapter (#1412).
What this pull request does
The design is module-scripts-in-crates. Each vendor module's Rust lives in its own crate, but its browser script, the script's tests and some of their test data lived in the shared
trusted-server-jscrate, underlib/src/integrations/<module>/andlib/test/integrations/<module>/. This change moves ten modules' scripts and tests into the nine crates that supply them, asjs/src/<module>/andjs/test/<module>/, and moves the Tinybird project fromtinybird/intocrates/analytics/tinybird/project/.datadomecrates/bot-protection/datadomedidomicrates/cmp/didomigoogle_tag_managercrates/tag/google-tag-managergptcrates/ad-tag/googlegpt_diagnosticscrates/ad-tag/googlelockrcrates/identity/lockrosanocrates/cmp/osanopermutivecrates/audience/permutivesourcepointcrates/cmp/sourcepointtestlightcrates/testing/testlightmoduleSourceDirs()inlib/build-module-options.mjsandexpected_module_idsinbuild/bundle_set.rsapply one rule,lib/src/integrations/<name>orcrates/<type>/<crate>/js/src/<name>, refuse a name found twice or the namecore, and pass over a broken link or a file, with tests on both sides.build.rswatches each crate'sjs/srcfolder that exists.@tsjs/core/...and@tsjs/shared/..., another module's code as@tsjs/module/<name>/..., and shared test data as@tsjs/test/.... It cannot import an npm package, because packages resolve only fromlib'snode_modules.js/srcandjs/testfolders, and the CI commands are unchanged.crates/holds atsconfig.json, an ESLint config and a Prettier config that applylib's settings there.tsjs-<name>.jsnames, so the Rust API, the served URLs and every content hash are unchanged. The only change a reader receives is three comment lines incrates/ad-tag/google/src/gpt_bootstrap.js, which the GPT module inlines into pages and which named the GPT script's old path.ts prebid clientcommand runs its bundle build from the shared crate. The vendor names in the browser core stay. Each is a later change, and the design says why.How it was verified
Locally on Windows at 0e0d3aa, against row 54 at 1dde36e:
build-all.mjswrites has the same SHA-256 as on row 54.npm run lintandnpm run formatpass, and a planted unused variable in a crate's script makesnpm run lintfail.npx vitest runpasses 1254 tests, including the discovery tests and the checks of the editor settings and the@tsjs/modulelist. The twobuild-prebid-externaltests that create symlinks fail on Windows, as they do on row 54. The type gate covers the moved GPT diagnostics contract test, which a planted false assertion makes fail.tsc --noEmit -p tsconfig.jsoninlibreports no error it does not report on row 54.cargo testandcargo clippy -- -D warningspass fortrusted-server-jsat 0e0d3aa, and fortrusted-server-ad-tag-google, whose recorded page-change fixture changed, at 338b648, after which nothing in that crate changes.cargo fmt --all -- --checkpasses.