Function: xmBuildOutput()
API / @xmachines/shared / vite-aliases / xmBuildOutput
function xmBuildOutput(importMetaUrl): Plugin;Defined in: vite-aliases.ts:388
The Vite plugin of the dist run: it moves each src/ file of a published package to its
counterpart in dist/.
A specifier of a published package resolves through its exports map in the dist run (see
xmAliases). A test also imports the module under test by path, as
../src/define-player.js, and that import reaches no exports map. Without this plugin the
test would exercise the source while every other import reads the build, and a class would
exist two times, one copy for each tree. The plugin gives both imports the ONE file of
dist/. A vi.mock of a src/ path resolves through the same hook, so the mock replaces
the module that the build output imports.
A source file with no counterpart in dist/ is a module that the build does not ship. The
plugin then fails the import and names both files, because a fallback to the source would
hide exactly the defect that the dist run exists to find.
The plugin is part of every config of defineXmVitestConfig when XM_TEST_TARGET is
dist, and of none when it is not.
Parameters
| Parameter | Type | Description |
|---|---|---|
importMetaUrl | string | Pass import.meta.url from the calling config file. |
Returns
Plugin