Skip to content

Commit 1acd1bd

Browse files
committed
allow plugin to work in rolldown
rolldown does not expose importedIdResolutions similar to rollup and so we need to move the emit to the render phase
1 parent b733023 commit 1acd1bd

File tree

2 files changed

+13
-15
lines changed

2 files changed

+13
-15
lines changed

.changeset/light-guests-pull.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@vanilla-extract/rollup-plugin': patch
3+
---
4+
5+
allow plugin to work in rolldown

packages/rollup-plugin/src/index.ts

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -72,27 +72,20 @@ export function vanillaExtractPlugin({
7272
},
7373
};
7474
},
75-
// Emit .css assets
76-
moduleParsed(moduleInfo) {
77-
moduleInfo.importedIdResolutions.forEach((resolution) => {
78-
if (resolution.meta.css) {
79-
resolution.meta.assetId = this.emitFile({
80-
type: 'asset',
81-
name: resolution.id,
82-
source: resolution.meta.css,
83-
});
84-
}
85-
});
86-
},
87-
// Replace .css import paths with relative paths to emitted css files
75+
// Emit .css assets and replace .css import paths with relative paths to emitted css files
8876
renderChunk(code, chunkInfo) {
8977
const chunkPath = dirname(chunkInfo.fileName);
9078
const output = chunkInfo.imports.reduce((codeResult, importPath) => {
9179
const moduleInfo = this.getModuleInfo(importPath);
92-
if (!moduleInfo?.meta.assetId) {
80+
if (!moduleInfo?.meta.css) {
9381
return codeResult;
9482
}
95-
const assetPath = this.getFileName(moduleInfo?.meta.assetId);
83+
const assetId = this.emitFile({
84+
type: 'asset',
85+
name: moduleInfo.id,
86+
source: moduleInfo.meta.css,
87+
});
88+
const assetPath = this.getFileName(assetId);
9689
const relativeAssetPath = `./${normalize(
9790
relative(chunkPath, assetPath),
9891
)}`;

0 commit comments

Comments
 (0)