@vanilla-extract/vite-plugin 5.2.5 → 5.2.6
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.
|
@@ -163,6 +163,39 @@ function vanillaExtractPlugin({
|
|
|
163
163
|
compilerReady ?? (compilerReady = initializeCompiler());
|
|
164
164
|
return compilerReady;
|
|
165
165
|
};
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* Virtual `*.vanilla.css` modules are only populated after the parent
|
|
169
|
+
* `.css.ts` has been `processVanillaFile`'d. That normally happens in
|
|
170
|
+
* `transform`, but Vite can serve the parent without re-running `transform`
|
|
171
|
+
* (notably 304 Not Modified after a server restart with a warm browser
|
|
172
|
+
* cache), leaving the compiler CSS cache empty when the virtual module is
|
|
173
|
+
* requested. On miss, process the parent so virtual CSS is self-sufficient.
|
|
174
|
+
*
|
|
175
|
+
* A future (likely breaking) refactor should consider a soft-read/ensure API
|
|
176
|
+
* in the compiler so plugins don't have to catch thrown cache misses or call
|
|
177
|
+
* `processVanillaFile` themselves.
|
|
178
|
+
*/
|
|
179
|
+
const ensureCssForVirtualId = async absoluteVirtualId => {
|
|
180
|
+
await ensureCompiler();
|
|
181
|
+
if (!compiler$1) {
|
|
182
|
+
return null;
|
|
183
|
+
}
|
|
184
|
+
const fileId = virtualIdToFileId(absoluteVirtualId);
|
|
185
|
+
try {
|
|
186
|
+
return compiler$1.getCssForFile(fileId).css;
|
|
187
|
+
} catch {
|
|
188
|
+
// Not in cache yet for this compiler lifetime
|
|
189
|
+
}
|
|
190
|
+
await compiler$1.processVanillaFile(fileId, {
|
|
191
|
+
outputCss: true
|
|
192
|
+
});
|
|
193
|
+
try {
|
|
194
|
+
return compiler$1.getCssForFile(fileId).css;
|
|
195
|
+
} catch {
|
|
196
|
+
return null;
|
|
197
|
+
}
|
|
198
|
+
};
|
|
166
199
|
return [{
|
|
167
200
|
name: `${PLUGIN_NAMESPACE}-inline-dev-css`,
|
|
168
201
|
apply: (_, {
|
|
@@ -298,36 +331,27 @@ function vanillaExtractPlugin({
|
|
|
298
331
|
timestamp
|
|
299
332
|
});
|
|
300
333
|
},
|
|
301
|
-
resolveId(source) {
|
|
334
|
+
async resolveId(source) {
|
|
302
335
|
const [validId, query] = source.split('?');
|
|
303
336
|
if (!isVirtualId(validId)) return;
|
|
304
337
|
const absoluteId = getAbsoluteId({
|
|
305
338
|
filePath: validId,
|
|
306
339
|
root: config.root
|
|
307
340
|
});
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
// The only valid scenario for a missing CSS entry is if someone had
|
|
311
|
-
// written a file in their app using the .vanilla.js/.vanilla.css
|
|
312
|
-
// extension, or the file produced no CSS output.
|
|
313
|
-
const {
|
|
314
|
-
css
|
|
315
|
-
} = compiler$1.getCssForFile(virtualIdToFileId(absoluteId));
|
|
341
|
+
const css = await ensureCssForVirtualId(absoluteId);
|
|
316
342
|
if (css) {
|
|
317
343
|
// Keep the original query string for HMR.
|
|
318
344
|
return absoluteId + (query ? `?${query}` : '');
|
|
319
345
|
}
|
|
320
346
|
},
|
|
321
|
-
load(id) {
|
|
347
|
+
async load(id) {
|
|
322
348
|
const [validId] = id.split('?');
|
|
323
|
-
if (!isVirtualId(validId)
|
|
349
|
+
if (!isVirtualId(validId)) return;
|
|
324
350
|
const absoluteId = getAbsoluteId({
|
|
325
351
|
filePath: validId,
|
|
326
352
|
root: config.root
|
|
327
353
|
});
|
|
328
|
-
const
|
|
329
|
-
css
|
|
330
|
-
} = compiler$1.getCssForFile(virtualIdToFileId(absoluteId));
|
|
354
|
+
const css = await ensureCssForVirtualId(absoluteId);
|
|
331
355
|
if (css) {
|
|
332
356
|
return css;
|
|
333
357
|
}
|
|
@@ -163,6 +163,39 @@ function vanillaExtractPlugin({
|
|
|
163
163
|
compilerReady ?? (compilerReady = initializeCompiler());
|
|
164
164
|
return compilerReady;
|
|
165
165
|
};
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* Virtual `*.vanilla.css` modules are only populated after the parent
|
|
169
|
+
* `.css.ts` has been `processVanillaFile`'d. That normally happens in
|
|
170
|
+
* `transform`, but Vite can serve the parent without re-running `transform`
|
|
171
|
+
* (notably 304 Not Modified after a server restart with a warm browser
|
|
172
|
+
* cache), leaving the compiler CSS cache empty when the virtual module is
|
|
173
|
+
* requested. On miss, process the parent so virtual CSS is self-sufficient.
|
|
174
|
+
*
|
|
175
|
+
* A future (likely breaking) refactor should consider a soft-read/ensure API
|
|
176
|
+
* in the compiler so plugins don't have to catch thrown cache misses or call
|
|
177
|
+
* `processVanillaFile` themselves.
|
|
178
|
+
*/
|
|
179
|
+
const ensureCssForVirtualId = async absoluteVirtualId => {
|
|
180
|
+
await ensureCompiler();
|
|
181
|
+
if (!compiler$1) {
|
|
182
|
+
return null;
|
|
183
|
+
}
|
|
184
|
+
const fileId = virtualIdToFileId(absoluteVirtualId);
|
|
185
|
+
try {
|
|
186
|
+
return compiler$1.getCssForFile(fileId).css;
|
|
187
|
+
} catch {
|
|
188
|
+
// Not in cache yet for this compiler lifetime
|
|
189
|
+
}
|
|
190
|
+
await compiler$1.processVanillaFile(fileId, {
|
|
191
|
+
outputCss: true
|
|
192
|
+
});
|
|
193
|
+
try {
|
|
194
|
+
return compiler$1.getCssForFile(fileId).css;
|
|
195
|
+
} catch {
|
|
196
|
+
return null;
|
|
197
|
+
}
|
|
198
|
+
};
|
|
166
199
|
return [{
|
|
167
200
|
name: `${PLUGIN_NAMESPACE}-inline-dev-css`,
|
|
168
201
|
apply: (_, {
|
|
@@ -298,36 +331,27 @@ function vanillaExtractPlugin({
|
|
|
298
331
|
timestamp
|
|
299
332
|
});
|
|
300
333
|
},
|
|
301
|
-
resolveId(source) {
|
|
334
|
+
async resolveId(source) {
|
|
302
335
|
const [validId, query] = source.split('?');
|
|
303
336
|
if (!isVirtualId(validId)) return;
|
|
304
337
|
const absoluteId = getAbsoluteId({
|
|
305
338
|
filePath: validId,
|
|
306
339
|
root: config.root
|
|
307
340
|
});
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
// The only valid scenario for a missing CSS entry is if someone had
|
|
311
|
-
// written a file in their app using the .vanilla.js/.vanilla.css
|
|
312
|
-
// extension, or the file produced no CSS output.
|
|
313
|
-
const {
|
|
314
|
-
css
|
|
315
|
-
} = compiler$1.getCssForFile(virtualIdToFileId(absoluteId));
|
|
341
|
+
const css = await ensureCssForVirtualId(absoluteId);
|
|
316
342
|
if (css) {
|
|
317
343
|
// Keep the original query string for HMR.
|
|
318
344
|
return absoluteId + (query ? `?${query}` : '');
|
|
319
345
|
}
|
|
320
346
|
},
|
|
321
|
-
load(id) {
|
|
347
|
+
async load(id) {
|
|
322
348
|
const [validId] = id.split('?');
|
|
323
|
-
if (!isVirtualId(validId)
|
|
349
|
+
if (!isVirtualId(validId)) return;
|
|
324
350
|
const absoluteId = getAbsoluteId({
|
|
325
351
|
filePath: validId,
|
|
326
352
|
root: config.root
|
|
327
353
|
});
|
|
328
|
-
const
|
|
329
|
-
css
|
|
330
|
-
} = compiler$1.getCssForFile(virtualIdToFileId(absoluteId));
|
|
354
|
+
const css = await ensureCssForVirtualId(absoluteId);
|
|
331
355
|
if (css) {
|
|
332
356
|
return css;
|
|
333
357
|
}
|
|
@@ -159,6 +159,39 @@ function vanillaExtractPlugin({
|
|
|
159
159
|
compilerReady ?? (compilerReady = initializeCompiler());
|
|
160
160
|
return compilerReady;
|
|
161
161
|
};
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* Virtual `*.vanilla.css` modules are only populated after the parent
|
|
165
|
+
* `.css.ts` has been `processVanillaFile`'d. That normally happens in
|
|
166
|
+
* `transform`, but Vite can serve the parent without re-running `transform`
|
|
167
|
+
* (notably 304 Not Modified after a server restart with a warm browser
|
|
168
|
+
* cache), leaving the compiler CSS cache empty when the virtual module is
|
|
169
|
+
* requested. On miss, process the parent so virtual CSS is self-sufficient.
|
|
170
|
+
*
|
|
171
|
+
* A future (likely breaking) refactor should consider a soft-read/ensure API
|
|
172
|
+
* in the compiler so plugins don't have to catch thrown cache misses or call
|
|
173
|
+
* `processVanillaFile` themselves.
|
|
174
|
+
*/
|
|
175
|
+
const ensureCssForVirtualId = async absoluteVirtualId => {
|
|
176
|
+
await ensureCompiler();
|
|
177
|
+
if (!compiler) {
|
|
178
|
+
return null;
|
|
179
|
+
}
|
|
180
|
+
const fileId = virtualIdToFileId(absoluteVirtualId);
|
|
181
|
+
try {
|
|
182
|
+
return compiler.getCssForFile(fileId).css;
|
|
183
|
+
} catch {
|
|
184
|
+
// Not in cache yet for this compiler lifetime
|
|
185
|
+
}
|
|
186
|
+
await compiler.processVanillaFile(fileId, {
|
|
187
|
+
outputCss: true
|
|
188
|
+
});
|
|
189
|
+
try {
|
|
190
|
+
return compiler.getCssForFile(fileId).css;
|
|
191
|
+
} catch {
|
|
192
|
+
return null;
|
|
193
|
+
}
|
|
194
|
+
};
|
|
162
195
|
return [{
|
|
163
196
|
name: `${PLUGIN_NAMESPACE}-inline-dev-css`,
|
|
164
197
|
apply: (_, {
|
|
@@ -294,36 +327,27 @@ function vanillaExtractPlugin({
|
|
|
294
327
|
timestamp
|
|
295
328
|
});
|
|
296
329
|
},
|
|
297
|
-
resolveId(source) {
|
|
330
|
+
async resolveId(source) {
|
|
298
331
|
const [validId, query] = source.split('?');
|
|
299
332
|
if (!isVirtualId(validId)) return;
|
|
300
333
|
const absoluteId = getAbsoluteId({
|
|
301
334
|
filePath: validId,
|
|
302
335
|
root: config.root
|
|
303
336
|
});
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
// The only valid scenario for a missing CSS entry is if someone had
|
|
307
|
-
// written a file in their app using the .vanilla.js/.vanilla.css
|
|
308
|
-
// extension, or the file produced no CSS output.
|
|
309
|
-
const {
|
|
310
|
-
css
|
|
311
|
-
} = compiler.getCssForFile(virtualIdToFileId(absoluteId));
|
|
337
|
+
const css = await ensureCssForVirtualId(absoluteId);
|
|
312
338
|
if (css) {
|
|
313
339
|
// Keep the original query string for HMR.
|
|
314
340
|
return absoluteId + (query ? `?${query}` : '');
|
|
315
341
|
}
|
|
316
342
|
},
|
|
317
|
-
load(id) {
|
|
343
|
+
async load(id) {
|
|
318
344
|
const [validId] = id.split('?');
|
|
319
|
-
if (!isVirtualId(validId)
|
|
345
|
+
if (!isVirtualId(validId)) return;
|
|
320
346
|
const absoluteId = getAbsoluteId({
|
|
321
347
|
filePath: validId,
|
|
322
348
|
root: config.root
|
|
323
349
|
});
|
|
324
|
-
const
|
|
325
|
-
css
|
|
326
|
-
} = compiler.getCssForFile(virtualIdToFileId(absoluteId));
|
|
350
|
+
const css = await ensureCssForVirtualId(absoluteId);
|
|
327
351
|
if (css) {
|
|
328
352
|
return css;
|
|
329
353
|
}
|
package/package.json
CHANGED