Tests / @ogygia/barrels

@ogygia/barrels

Version 0.14.0 latest
commit 620ddcca
94 test runs (94 tests, each run in Node, the browsers or both)
2.77× lines of test for each line of source (2,048 to 739) Only real test code counts: test files and their helpers, not fixtures, sample apps or benches. Blank lines are left out on both sides.
Exactly what is counted non-blank lines of test code across the repo (*.test.ts, *.test-d.ts, *.spec.ts, and the .ts helpers in test/ and e2e/ folders; no fixtures, fixture apps, stubs or benches), over non-blank lines of packages/*/src (no .d.ts or generated files)
97.5% of source lines run by the tests
  • 94Unit
  • 0Browser
  • 0End to end
  • 0Type tests
  • 0Lint rules
  • 0Failing

Coverage

  • 97.5%Lines
  • 84.4%Branches
  • 92.5%Functions
  • 96.2%Statements

Every test

94 tests

TestKindNodeChromiumFirefoxWebKit
packages/barrels/test/barrel.test.ts
cache + invalidation > a barrel edited while its map is being built is built again: no caller keeps the old mapUnitpassnot runnot runnot run
cache + invalidation > a map is cached; invalidating a DEPENDENCY drops every map that walked through itUnitpassnot runnot runnot run
cache + invalidation > a nested barrel edited while the outer map walks through it is walked againUnitpassnot runnot runnot run
cache + invalidation > at scale: a 2 000-name barrel over 200 leaves maps in well under a second and points every name homeUnitpassnot runnot runnot run
cache + invalidation > invalidating a leaf that turned impure re-classifies the chain on the next mapUnitpassnot runnot runnot run
concurrency — what a real build does > many importers, many barrels, all at once: every name lands homeUnitpassnot runnot runnot run
concurrency — what a real build does > two hundred importers asking for one barrel at once all get the SAME finished map (one build in flight)Unitpassnot runnot runnot run
concurrency — what a real build does > two walks that need each other (a → b while b → a is in flight) neither deadlock nor cache a holeUnitpassnot runnot runnot run
export map — the basic shapes > a .js barrel with .js-suffixed relative specifiers (nodenext style) resolves the sameUnitpassnot runnot runnot run
export map — the basic shapes > export * as ns → a namespace leafUnitpassnot runnot runnot run
export map — the basic shapes > import-then-export bindings resolve like direct re-exportsUnitpassnot runnot runnot run
export map — the basic shapes > named, renamed, default-as-name, star: each name points at its leafUnitpassnot runnot runnot run
nesting — barrels of barrels > a diamond — the same leaf reached by two paths — is NOT ambiguousUnitpassnot runnot runnot run
nesting — barrels of barrels > a nested barrel re-exporting a name its own star does not carry stays honest: unknown names are absentUnitpassnot runnot runnot run
nesting — barrels of barrels > a rename chain three barrels deep lands on the original leaf and nameUnitpassnot runnot runnot run
nesting — barrels of barrels > a star into a nested pure barrel is transparent; into an impure module it stops thereUnitpassnot runnot runnot run
nesting — barrels of barrels > cycles terminate: a ↔ b, and a barrel that stars itselfUnitpassnot runnot runnot run
nesting — barrels of barrels > explicit re-exports win over stars; two stars with different leaves for one name are ambiguousUnitpassnot runnot runnot run
where the walk stops > a CommonJS module behind a star is opaque (module.exports is not an export list)Unitpassnot runnot runnot run
where the walk stops > a kept module in the MIDDLE of a chain is the leaf (the walk does not look through it)Unitpassnot runnot runnot run
where the walk stops > a package barrel is a candidate only when opted in (packages), then its exports map is walkedUnitpassnot runnot runnot run
where the walk stops > a query id (?raw, ?url) is never a barrel; a re-export FROM a query id stays on the barrelUnitpassnot runnot runnot run
where the walk stops > a star into something unparsable (json, missing, a syntax error, virtual) makes the map OPAQUE, the rest still mapsUnitpassnot runnot runnot run
where the walk stops > an impure module is left (said why) unless forced; forced keeps own names as ownUnitpassnot runnot runnot run
where the walk stops > follow_packages: false makes a star into node_modules opaque; true walks itUnitpassnot runnot runnot run
where the walk stops > kept beats everything; a non-candidate is never walked; each map says why it is leftUnitpassnot runnot runnot run
packages/barrels/test/left-table.test.ts
one table per build leg > a leg answers only what was said in it, and a leg that begins again forgets its last build's wordUnitpassnot runnot runnot run
the barrel-left table > a component that could not be parsed explains every barrel it imports, joined by importerUnitpassnot runnot runnot run
the barrel-left table > a dependency's barrel is not explained by an unparsable importer (the pass never rewrites into it unasked)Unitpassnot runnot runnot run
the barrel-left table > a module transformed again forgets what it said beforeUnitpassnot runnot runnot run
the barrel-left table > answers the reasons recorded for a barrel, in a fixed order, once eachUnitpassnot runnot runnot run
the barrel-left table > clear empties it (the end of a build leg, the dev server closing)Unitpassnot runnot runnot run
the barrel-left table > holds at most its cap of barrels: a new barrel past it is not recorded, a known one still isUnitpassnot runnot runnot run
packages/barrels/test/left.test.ts
each import the plugin leaves on its barrel is told, with the reason > ambiguous: two stars give the same nameUnitpassnot runnot runnot run
each import the plugin leaves on its barrel is told, with the reason > impure: the barrel runs code of its ownUnitpassnot runnot runnot run
each import the plugin leaves on its barrel is told, with the reason > kept: barrels({ keep }) lists itUnitpassnot runnot runnot run
each import the plugin leaves on its barrel is told, with the reason > namespace: the barrel is imported wholeUnitpassnot runnot runnot run
each import the plugin leaves on its barrel is told, with the reason > opaque: a star into a module the index cannot read hides where a name livesUnitpassnot runnot runnot run
each import the plugin leaves on its barrel is told, with the reason > outside-project: a package that barrels({ packages }) does not listUnitpassnot runnot runnot run
each import the plugin leaves on its barrel is told, with the reason > own: the name is defined in the barrel itself (a forced impure barrel)Unitpassnot runnot runnot run
each import the plugin leaves on its barrel is told, with the reason > pinned: the import carries a region mark, so it stays as writtenUnitpassnot runnot runnot run
each import the plugin leaves on its barrel is told, with the reason > unparsable: a component the parser cannot read keeps every barrel it importsUnitpassnot runnot runnot run
what is not a barrel left behind says nothing > an import that moved, a plain module, a type-only or side-effect import, a name the barrel lacksUnitpassnot runnot runnot run
what the plugin said holds for its leg until the module or the leg begins again > a module transformed again forgets what it said beforeUnitpassnot runnot runnot run
what the plugin said holds for its leg until the module or the leg begins again > each leg answers for itself; a build leg that begins again drops its last build's wordUnitpassnot runnot runnot run
what the plugin said holds for its leg until the module or the leg begins again > the dev server is one build: nothing is dropped when it startsUnitpassnot runnot runnot run
packages/barrels/test/named-region.test.ts
barrels + a marked named import > a region-MARKED barrel import is left to the compiler (skip policy)Unitpassnot runnot runnot run
barrels + a marked named import > barrels() beside ogygia() applies that rule end to endUnitpassnot runnot runnot run
barrels + a marked named import > INSIDE ogygia the marked import is left alone and a plain import of the same barrel is rewritten; the island id is the raw oneUnitpassnot runnot runnot run
barrels + a marked named import > without the pass the marked named import compiles through the barrelUnitpassnot runnot runnot run
packages/barrels/test/plugin.test.ts
beside ogygia() > a specifier Vite cannot resolve (it THROWS from `this.resolve`) leaves that import alone and the rest still movesUnitpassnot runnot runnot run
beside ogygia() > leaves imports carrying the app's region-mark keys (custom importKeys too) as written, rewrites the restUnitpassnot runnot runnot run
beside ogygia() > listed without ogygia(), it fails the build saying what to addUnitpassnot runnot runnot run
the report names the components it had to skip > skipped components are counted and listed, with or without rewritesUnitpassnot runnot runnot run
vite build > a `keep` matcher leaves that barrel alone even though it is pureUnitpassnot runnot runnot run
vite build > a package NOT opted in is left alone (dev pre-bundling safety)Unitpassnot runnot runnot run
vite build > the barrel and its unused leaves are not in the bundle; the used leaves are; the package barrel is bypassed tooUnitpassnot runnot runnot run
vite build > the build report names the totals, the time, and the top barrels with their importer counts; `debug` narrates each rewriteUnitpassnot runnot runnot run
vite build > the default report shows the eight biggest barrels and counts the rest; `report: "all"` lists every oneUnitpassnot runnot runnot run
vite build > without the plugin the barrel and every leaf are in the graph (the baseline the pass beats)Unitpassnot runnot runnot run
vite dev > a leaf the client and the server resolve to different files (#252) > client and SSR transforms at the same time: each gets its own leaf#252Unitpassnot runnot runnot run
vite dev > a leaf the client and the server resolve to different files (#252) > the client first, then SSR (and the other way): the cached barrel map is not handed across#252Unitpassnot runnot runnot run
vite dev > editing a barrel re-points the importer on the next transform (watch + invalidate)Unitpassnot runnot runnot run
vite dev > transformRequest returns leaf imports for a TS module and a Svelte componentUnitpassnot runnot runnot run
which ids are importers > a build with extracted component CSS warns about nothing and still rewrites the componentUnitpassnot runnot runnot run
which ids are importers > the script only: a style sub-module or a raw/url/worker request is not the componentUnitpassnot runnot runnot run
packages/barrels/test/rewrite.test.ts
rewrite — output shapes > `import { default as X }` is a named default; two aliases of one leaf default get two linesUnitpassnot runnot runnot run
rewrite — output shapes > a barrel imported through two different specifiers (alias and relative) is the same barrelUnitpassnot runnot runnot run
rewrite — output shapes > a default import of the barrel is rewritten only when the barrel re-exports its defaultUnitpassnot runnot runnot run
rewrite — output shapes > a forced impure barrel whose names all moved keeps a bare import so its own code still runsUnitpassnot runnot runnot run
rewrite — output shapes > a leaf path with a quote in it is escaped in the emitted importUnitpassnot runnot runnot run
rewrite — output shapes > a namespace re-export becomes `import * as`Unitpassnot runnot runnot run
rewrite — output shapes > an importer that is itself a barrel gets rewritten too (a barrel of barrels flattens one level per file)Unitpassnot runnot runnot run
rewrite — output shapes > cursed spellings: no semicolons, no spaces, comments and newlines inside the braces, unicode, string export names on both sidesUnitpassnot runnot runnot run
rewrite — output shapes > emits a high-resolution sourcemap that still maps the untouched tail of the fileUnitpassnot runnot runnot run
rewrite — output shapes > import attributes ride onto every leaf importUnitpassnot runnot runnot run
rewrite — output shapes > named imports go to their leaves, one import per leaf, local names unchanged; the barrel import disappearsUnitpassnot runnot runnot run
rewrite — output shapes > returns null (no work) for a file that imports no barrel, and for a syntax errorUnitpassnot runnot runnot run
rewrite — output shapes > the skip policy leaves an import with a listed attribute key untouched — the ogygia mark stays on the barrelUnitpassnot runnot runnot run
rewrite — output shapes > two imports of the same barrel in one file are both rewritten; other imports are left byte-identicalUnitpassnot runnot runnot run
rewrite — output shapes > type-only: an `import type {}` declaration is left alone (erased, no edge); a mixed import splits, and a leaf that only gets `type` specifiers is imported `type`Unitpassnot runnot runnot run
rewrite — output shapes > untouched by design: `import * as B`, `import "barrel"`, dynamic import; a default the barrel OWNS staysUnitpassnot runnot runnot run
rewrite — output shapes > what cannot move stays on the barrel: unknown names, own names of a forced barrel, ambiguous namesUnitpassnot runnot runnot run
packages/barrels/test/svelte.test.ts
rewrite_svelte > `lang="ts"` types in the script do not break the parse (satisfies, generics, `as const`)Unitpassnot runnot runnot run
rewrite_svelte > a `.svelte.ts` module goes through the plain rewriterUnitpassnot runnot runnot run
rewrite_svelte > a <style lang="scss"> the CSS parser rejects no longer skips the file; the style stays byte-identicalUnitpassnot runnot runnot run
rewrite_svelte > a barrel that re-exports a Svelte component through a nested barrel still lands on the .svelte fileUnitpassnot runnot runnot run
rewrite_svelte > a component that still cannot be parsed is reported (code and position), never skipped in silenceUnitpassnot runnot runnot run
rewrite_svelte > a region-marked import in a component is left alone under the skip policy; the unmarked one next to it movesUnitpassnot runnot runnot run
rewrite_svelte > a script AFTER the style block is rewritten at the right place (the blanking keeps every offset)Unitpassnot runnot runnot run
rewrite_svelte > import-looking text in a template string, a comment, and the markup is never rewrittenUnitpassnot runnot runnot run
rewrite_svelte > no script, a component that imports no barrel, and a syntax error all leave the file aloneUnitpassnot runnot runnot run
rewrite_svelte > rewrites the instance script and leaves the markup byte-identicalUnitpassnot runnot runnot run
rewrite_svelte > rewrites the module script too, and both when present; attributes ride alongUnitpassnot runnot runnot run