Description
The renderChunk hook in @vanilla-extract/rollup-plugin passes moduleInfo.id directly as the name field in this.emitFile():
https://github.com/vanilla-extract-css/vanilla-extract/blob/master/packages/rollup-plugin/src/plugin.ts#L155
const assetId = this.emitFile({
type: 'asset',
name: moduleInfo.id, // can be a relative path like "../styles/src/focusRing.css.ts.vanilla.css"
source: moduleInfo.meta.css
});
When a .css.ts file imports from another package (e.g. @vanilla-extract/rollup-plugin processing a component that imports tokens from a shared styles package), moduleInfo.id resolves to a relative path like ../styles/src/focusRing.css.ts.vanilla.css.
This worked with rollup/older rolldown versions, but rolldown 1.0.0-rc.12 (shipped with tsdown 0.21.x) now validates that name is neither an absolute nor relative path:
Error: The "fileName" or "name" properties of emitted chunks and assets must be strings
that are neither absolute nor relative paths, received "../styles/src/focusRing.css.ts.vanilla.css".
Suggested Fix
Use path.basename(moduleInfo.id) instead of moduleInfo.id for the name field:
const assetId = this.emitFile({
type: 'asset',
name: path.basename(moduleInfo.id),
source: moduleInfo.meta.css
});
The name field is only used for generating the output filename (via assetFileNames), so stripping the directory prefix should be safe.
Reproduction
- Create a package with a
.css.ts file that imports from another package's .css.ts file
- Build with tsdown >= 0.21.0 (which bundles rolldown 1.0.0-rc.12)
- Build fails with the error above
Versions
@vanilla-extract/rollup-plugin: 1.5.1 (also reproducible on 1.5.3)
tsdown: 0.21.7
rolldown: 1.0.0-rc.12
Description
The
renderChunkhook in@vanilla-extract/rollup-pluginpassesmoduleInfo.iddirectly as thenamefield inthis.emitFile():https://github.com/vanilla-extract-css/vanilla-extract/blob/master/packages/rollup-plugin/src/plugin.ts#L155
When a
.css.tsfile imports from another package (e.g.@vanilla-extract/rollup-pluginprocessing a component that imports tokens from a shared styles package),moduleInfo.idresolves to a relative path like../styles/src/focusRing.css.ts.vanilla.css.This worked with rollup/older rolldown versions, but rolldown 1.0.0-rc.12 (shipped with tsdown 0.21.x) now validates that
nameis neither an absolute nor relative path:Suggested Fix
Use
path.basename(moduleInfo.id)instead ofmoduleInfo.idfor thenamefield:The
namefield is only used for generating the output filename (viaassetFileNames), so stripping the directory prefix should be safe.Reproduction
.css.tsfile that imports from another package's.css.tsfileVersions
@vanilla-extract/rollup-plugin: 1.5.1 (also reproducible on 1.5.3)tsdown: 0.21.7rolldown: 1.0.0-rc.12