@vanilla-extract/vite-plugin 3.7.1 → 3.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -3,8 +3,9 @@ import { IdentifierOption, CompileOptions } from '@vanilla-extract/integration';
|
|
|
3
3
|
|
|
4
4
|
interface Options {
|
|
5
5
|
identifiers?: IdentifierOption;
|
|
6
|
+
emitCssInSsr?: boolean;
|
|
6
7
|
esbuildOptions?: CompileOptions['esbuildOptions'];
|
|
7
8
|
}
|
|
8
|
-
declare function vanillaExtractPlugin({ identifiers, esbuildOptions, }?: Options): Plugin;
|
|
9
|
+
declare function vanillaExtractPlugin({ identifiers, emitCssInSsr, esbuildOptions, }?: Options): Plugin;
|
|
9
10
|
|
|
10
11
|
export { vanillaExtractPlugin };
|
|
@@ -69,13 +69,15 @@ const virtualExtCss = '.vanilla.css';
|
|
|
69
69
|
const virtualExtJs = '.vanilla.js';
|
|
70
70
|
function vanillaExtractPlugin({
|
|
71
71
|
identifiers,
|
|
72
|
+
emitCssInSsr,
|
|
72
73
|
esbuildOptions
|
|
73
74
|
} = {}) {
|
|
74
75
|
let config;
|
|
75
76
|
let server;
|
|
76
77
|
let postCssConfig;
|
|
77
78
|
const cssMap = new Map();
|
|
78
|
-
|
|
79
|
+
const hasEmitCssOverride = typeof emitCssInSsr === 'boolean';
|
|
80
|
+
let resolvedEmitCssInSsr = hasEmitCssOverride ? emitCssInSsr : !!process.env.VITE_RSC_BUILD;
|
|
79
81
|
let packageName;
|
|
80
82
|
const getAbsoluteVirtualFileId = source => vite.normalizePath(path__default["default"].join(config.root, source));
|
|
81
83
|
return {
|
|
@@ -101,8 +103,8 @@ function vanillaExtractPlugin({
|
|
|
101
103
|
if (config.command === 'serve') {
|
|
102
104
|
postCssConfig = await resolvePostcssConfig(config);
|
|
103
105
|
}
|
|
104
|
-
if (config.plugins.some(plugin => ['astro:build', 'solid-start-server', 'vite-plugin-qwik', 'vite-plugin-svelte'].includes(plugin.name))) {
|
|
105
|
-
|
|
106
|
+
if (!hasEmitCssOverride && config.plugins.some(plugin => ['astro:build', 'solid-start-server', 'vite-plugin-qwik', 'vite-plugin-svelte'].includes(plugin.name))) {
|
|
107
|
+
resolvedEmitCssInSsr = true;
|
|
106
108
|
}
|
|
107
109
|
},
|
|
108
110
|
resolveId(source) {
|
|
@@ -166,7 +168,7 @@ function vanillaExtractPlugin({
|
|
|
166
168
|
} else {
|
|
167
169
|
ssr = ssrParam === null || ssrParam === void 0 ? void 0 : ssrParam.ssr;
|
|
168
170
|
}
|
|
169
|
-
if (ssr && !
|
|
171
|
+
if (ssr && !resolvedEmitCssInSsr) {
|
|
170
172
|
return integration.transform({
|
|
171
173
|
source: code,
|
|
172
174
|
filePath: vite.normalizePath(validId),
|
|
@@ -199,7 +201,7 @@ function vanillaExtractPlugin({
|
|
|
199
201
|
fileScope,
|
|
200
202
|
source
|
|
201
203
|
}) => {
|
|
202
|
-
const rootRelativeId = `${fileScope.filePath}${config.command === 'build' || ssr &&
|
|
204
|
+
const rootRelativeId = `${fileScope.filePath}${config.command === 'build' || ssr && resolvedEmitCssInSsr ? virtualExtCss : virtualExtJs}`;
|
|
203
205
|
const absoluteId = getAbsoluteVirtualFileId(rootRelativeId);
|
|
204
206
|
let cssSource = source;
|
|
205
207
|
if (postCssConfig) {
|
|
@@ -214,12 +216,14 @@ function vanillaExtractPlugin({
|
|
|
214
216
|
const {
|
|
215
217
|
moduleGraph
|
|
216
218
|
} = server;
|
|
217
|
-
const
|
|
218
|
-
|
|
219
|
-
|
|
219
|
+
const modules = Array.from(moduleGraph.getModulesByFile(absoluteId) || []);
|
|
220
|
+
for (const module of modules) {
|
|
221
|
+
if (module) {
|
|
222
|
+
moduleGraph.invalidateModule(module);
|
|
220
223
|
|
|
221
|
-
|
|
222
|
-
|
|
224
|
+
// Vite uses this timestamp to add `?t=` query string automatically for HMR.
|
|
225
|
+
module.lastHMRTimestamp = module.lastInvalidationTimestamp || Date.now();
|
|
226
|
+
}
|
|
223
227
|
}
|
|
224
228
|
server.ws.send({
|
|
225
229
|
type: 'custom',
|
|
@@ -69,13 +69,15 @@ const virtualExtCss = '.vanilla.css';
|
|
|
69
69
|
const virtualExtJs = '.vanilla.js';
|
|
70
70
|
function vanillaExtractPlugin({
|
|
71
71
|
identifiers,
|
|
72
|
+
emitCssInSsr,
|
|
72
73
|
esbuildOptions
|
|
73
74
|
} = {}) {
|
|
74
75
|
let config;
|
|
75
76
|
let server;
|
|
76
77
|
let postCssConfig;
|
|
77
78
|
const cssMap = new Map();
|
|
78
|
-
|
|
79
|
+
const hasEmitCssOverride = typeof emitCssInSsr === 'boolean';
|
|
80
|
+
let resolvedEmitCssInSsr = hasEmitCssOverride ? emitCssInSsr : !!process.env.VITE_RSC_BUILD;
|
|
79
81
|
let packageName;
|
|
80
82
|
const getAbsoluteVirtualFileId = source => vite.normalizePath(path__default["default"].join(config.root, source));
|
|
81
83
|
return {
|
|
@@ -101,8 +103,8 @@ function vanillaExtractPlugin({
|
|
|
101
103
|
if (config.command === 'serve') {
|
|
102
104
|
postCssConfig = await resolvePostcssConfig(config);
|
|
103
105
|
}
|
|
104
|
-
if (config.plugins.some(plugin => ['astro:build', 'solid-start-server', 'vite-plugin-qwik', 'vite-plugin-svelte'].includes(plugin.name))) {
|
|
105
|
-
|
|
106
|
+
if (!hasEmitCssOverride && config.plugins.some(plugin => ['astro:build', 'solid-start-server', 'vite-plugin-qwik', 'vite-plugin-svelte'].includes(plugin.name))) {
|
|
107
|
+
resolvedEmitCssInSsr = true;
|
|
106
108
|
}
|
|
107
109
|
},
|
|
108
110
|
resolveId(source) {
|
|
@@ -166,7 +168,7 @@ function vanillaExtractPlugin({
|
|
|
166
168
|
} else {
|
|
167
169
|
ssr = ssrParam === null || ssrParam === void 0 ? void 0 : ssrParam.ssr;
|
|
168
170
|
}
|
|
169
|
-
if (ssr && !
|
|
171
|
+
if (ssr && !resolvedEmitCssInSsr) {
|
|
170
172
|
return integration.transform({
|
|
171
173
|
source: code,
|
|
172
174
|
filePath: vite.normalizePath(validId),
|
|
@@ -199,7 +201,7 @@ function vanillaExtractPlugin({
|
|
|
199
201
|
fileScope,
|
|
200
202
|
source
|
|
201
203
|
}) => {
|
|
202
|
-
const rootRelativeId = `${fileScope.filePath}${config.command === 'build' || ssr &&
|
|
204
|
+
const rootRelativeId = `${fileScope.filePath}${config.command === 'build' || ssr && resolvedEmitCssInSsr ? virtualExtCss : virtualExtJs}`;
|
|
203
205
|
const absoluteId = getAbsoluteVirtualFileId(rootRelativeId);
|
|
204
206
|
let cssSource = source;
|
|
205
207
|
if (postCssConfig) {
|
|
@@ -214,12 +216,14 @@ function vanillaExtractPlugin({
|
|
|
214
216
|
const {
|
|
215
217
|
moduleGraph
|
|
216
218
|
} = server;
|
|
217
|
-
const
|
|
218
|
-
|
|
219
|
-
|
|
219
|
+
const modules = Array.from(moduleGraph.getModulesByFile(absoluteId) || []);
|
|
220
|
+
for (const module of modules) {
|
|
221
|
+
if (module) {
|
|
222
|
+
moduleGraph.invalidateModule(module);
|
|
220
223
|
|
|
221
|
-
|
|
222
|
-
|
|
224
|
+
// Vite uses this timestamp to add `?t=` query string automatically for HMR.
|
|
225
|
+
module.lastHMRTimestamp = module.lastInvalidationTimestamp || Date.now();
|
|
226
|
+
}
|
|
223
227
|
}
|
|
224
228
|
server.ws.send({
|
|
225
229
|
type: 'custom',
|
|
@@ -42,13 +42,15 @@ const virtualExtCss = '.vanilla.css';
|
|
|
42
42
|
const virtualExtJs = '.vanilla.js';
|
|
43
43
|
function vanillaExtractPlugin({
|
|
44
44
|
identifiers,
|
|
45
|
+
emitCssInSsr,
|
|
45
46
|
esbuildOptions
|
|
46
47
|
} = {}) {
|
|
47
48
|
let config;
|
|
48
49
|
let server;
|
|
49
50
|
let postCssConfig;
|
|
50
51
|
const cssMap = new Map();
|
|
51
|
-
|
|
52
|
+
const hasEmitCssOverride = typeof emitCssInSsr === 'boolean';
|
|
53
|
+
let resolvedEmitCssInSsr = hasEmitCssOverride ? emitCssInSsr : !!process.env.VITE_RSC_BUILD;
|
|
52
54
|
let packageName;
|
|
53
55
|
const getAbsoluteVirtualFileId = source => normalizePath(path.join(config.root, source));
|
|
54
56
|
return {
|
|
@@ -74,8 +76,8 @@ function vanillaExtractPlugin({
|
|
|
74
76
|
if (config.command === 'serve') {
|
|
75
77
|
postCssConfig = await resolvePostcssConfig(config);
|
|
76
78
|
}
|
|
77
|
-
if (config.plugins.some(plugin => ['astro:build', 'solid-start-server', 'vite-plugin-qwik', 'vite-plugin-svelte'].includes(plugin.name))) {
|
|
78
|
-
|
|
79
|
+
if (!hasEmitCssOverride && config.plugins.some(plugin => ['astro:build', 'solid-start-server', 'vite-plugin-qwik', 'vite-plugin-svelte'].includes(plugin.name))) {
|
|
80
|
+
resolvedEmitCssInSsr = true;
|
|
79
81
|
}
|
|
80
82
|
},
|
|
81
83
|
resolveId(source) {
|
|
@@ -139,7 +141,7 @@ function vanillaExtractPlugin({
|
|
|
139
141
|
} else {
|
|
140
142
|
ssr = ssrParam === null || ssrParam === void 0 ? void 0 : ssrParam.ssr;
|
|
141
143
|
}
|
|
142
|
-
if (ssr && !
|
|
144
|
+
if (ssr && !resolvedEmitCssInSsr) {
|
|
143
145
|
return transform({
|
|
144
146
|
source: code,
|
|
145
147
|
filePath: normalizePath(validId),
|
|
@@ -172,7 +174,7 @@ function vanillaExtractPlugin({
|
|
|
172
174
|
fileScope,
|
|
173
175
|
source
|
|
174
176
|
}) => {
|
|
175
|
-
const rootRelativeId = `${fileScope.filePath}${config.command === 'build' || ssr &&
|
|
177
|
+
const rootRelativeId = `${fileScope.filePath}${config.command === 'build' || ssr && resolvedEmitCssInSsr ? virtualExtCss : virtualExtJs}`;
|
|
176
178
|
const absoluteId = getAbsoluteVirtualFileId(rootRelativeId);
|
|
177
179
|
let cssSource = source;
|
|
178
180
|
if (postCssConfig) {
|
|
@@ -187,12 +189,14 @@ function vanillaExtractPlugin({
|
|
|
187
189
|
const {
|
|
188
190
|
moduleGraph
|
|
189
191
|
} = server;
|
|
190
|
-
const
|
|
191
|
-
|
|
192
|
-
|
|
192
|
+
const modules = Array.from(moduleGraph.getModulesByFile(absoluteId) || []);
|
|
193
|
+
for (const module of modules) {
|
|
194
|
+
if (module) {
|
|
195
|
+
moduleGraph.invalidateModule(module);
|
|
193
196
|
|
|
194
|
-
|
|
195
|
-
|
|
197
|
+
// Vite uses this timestamp to add `?t=` query string automatically for HMR.
|
|
198
|
+
module.lastHMRTimestamp = module.lastInvalidationTimestamp || Date.now();
|
|
199
|
+
}
|
|
196
200
|
}
|
|
197
201
|
server.ws.send({
|
|
198
202
|
type: 'custom',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vanilla-extract/vite-plugin",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.8.1",
|
|
4
4
|
"description": "Zero-runtime Stylesheets-in-TypeScript",
|
|
5
5
|
"main": "dist/vanilla-extract-vite-plugin.cjs.js",
|
|
6
6
|
"module": "dist/vanilla-extract-vite-plugin.esm.js",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"postcss-load-config": "^3.1.0"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
|
-
"vite": "
|
|
24
|
+
"vite": "npm:vite@^2.7.0"
|
|
25
25
|
},
|
|
26
26
|
"peerDependencies": {
|
|
27
27
|
"vite": "^2.2.3 || ^3.0.0 || ^4.0.3"
|