Skip to content

Commit 0d7f912

Browse files
author
Ben Jervis
authored
Update vite plugin for [email protected] (#530)
1 parent 4c690ca commit 0d7f912

File tree

5 files changed

+27
-11
lines changed

5 files changed

+27
-11
lines changed

.changeset/metal-cobras-beg.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
'@vanilla-extract/vite-plugin': patch
3+
---
4+
5+
Fix compatibility issues with [email protected]
6+
7+
Vite 2.7 introduced some [breaking changes](https://github.com/vitejs/vite/blob/main/packages/vite/CHANGELOG.md#270-2021-12-07) around the way SSR was indicated in plugins.
8+
The plugin has been updated to handle both the old and new formats, so it should support both 2.7 forward, as well as previous versions.

packages/vite-plugin/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"postcss-load-config": "^3.1.0"
2222
},
2323
"devDependencies": {
24-
"vite": "^2.6.0"
24+
"vite": "^2.7.0"
2525
},
2626
"peerDependencies": {
2727
"vite": "^2.2.3"

packages/vite-plugin/src/index.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,11 +105,19 @@ export function vanillaExtractPlugin({ identifiers }: Options = {}): Plugin {
105105

106106
return null;
107107
},
108-
async transform(code, id, ssr) {
108+
async transform(code, id, ssrParam) {
109109
if (!cssFileFilter.test(id)) {
110110
return null;
111111
}
112112

113+
let ssr: boolean | undefined;
114+
115+
if (typeof ssrParam === 'boolean') {
116+
ssr = ssrParam;
117+
} else {
118+
ssr = ssrParam?.ssr;
119+
}
120+
113121
const index = id.indexOf('?');
114122
const validId = index === -1 ? id : id.substring(0, index);
115123

pnpm-lock.yaml

Lines changed: 8 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test-helpers/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
"prettier": "^2.3.2",
3434
"serve-handler": "^6.1.3",
3535
"style-loader": "^2.0.0",
36-
"vite": "^2.6.0",
36+
"vite": "^2.7.0",
3737
"webpack": "^5.36.1",
3838
"webpack-dev-server": "^3.11.2",
3939
"webpack-merge": "^5.7.3"

0 commit comments

Comments
 (0)