@pandacss/transformer 2.0.0 → 2.0.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.
Files changed (2) hide show
  1. package/dist/index.js +14 -4
  2. package/package.json +3 -3
package/dist/index.js CHANGED
@@ -330,9 +330,14 @@ function toNativeOptions(options) {
330
330
  };
331
331
  }
332
332
  var SOURCE_RE = /\.(c|m)?(t|j)sx?$/;
333
+ var SFC_RE = /\.(svelte|vue|astro)$/;
334
+ var VUE_BLOCK_QUERY_RE = /^(.+\.vue)\?vue&type=(?:script|template|style|custom)(?:&|$)/;
335
+ function stripVueBlockQuery(id) {
336
+ return VUE_BLOCK_QUERY_RE.exec(id)?.[1] ?? id;
337
+ }
333
338
  function shouldTransform(path, options = {}) {
334
- const id = path.split("?")[0] ?? path;
335
- if (!SOURCE_RE.test(id)) return false;
339
+ const [id = path, query] = path.split("?");
340
+ if (!SOURCE_RE.test(id) && !(SFC_RE.test(id) && query === void 0)) return false;
336
341
  if (options.include && !matchesAny(id, options.include)) return false;
337
342
  if (options.exclude && matchesAny(id, options.exclude)) return false;
338
343
  return true;
@@ -398,7 +403,7 @@ function createPandaSourcePluginHooks(resolveOptions) {
398
403
 
399
404
  // src/plugin.ts
400
405
  import { createUnplugin } from "unplugin";
401
- var pandaTransformer = createUnplugin((options) => {
406
+ var pandaTransformer = createUnplugin((options, meta) => {
402
407
  const {
403
408
  compiler: _compiler,
404
409
  transformer: _transformer,
@@ -413,15 +418,20 @@ var pandaTransformer = createUnplugin((options) => {
413
418
  getCompiler: options.getCompiler,
414
419
  getTransformer: options.getTransformer
415
420
  }));
421
+ const isWebpackLike = meta.framework === "webpack" || meta.framework === "rspack";
422
+ const transformId = (id) => isWebpackLike ? stripVueBlockQuery(id) : id;
416
423
  return {
417
424
  name: "pandacss-transformer",
418
425
  enforce: "pre",
419
426
  ...hooks,
427
+ transform(code, id) {
428
+ return hooks.transform.call(this, code, transformId(id));
429
+ },
420
430
  loadInclude(id) {
421
431
  return id === INTERNAL_CSS_RESOLVED_ID;
422
432
  },
423
433
  transformInclude(id) {
424
- return shouldTransform(id, transformOptions);
434
+ return shouldTransform(transformId(id), transformOptions);
425
435
  }
426
436
  };
427
437
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pandacss/transformer",
3
- "version": "2.0.0",
3
+ "version": "2.0.1",
4
4
  "description": "Source transformer facade for Panda CSS",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -34,8 +34,8 @@
34
34
  "dist"
35
35
  ],
36
36
  "dependencies": {
37
- "@pandacss/compiler": "2.0.0",
38
- "@pandacss/compiler-shared": "2.0.0",
37
+ "@pandacss/compiler": "2.0.1",
38
+ "@pandacss/compiler-shared": "2.0.1",
39
39
  "unplugin": "^2.3.11"
40
40
  },
41
41
  "devDependencies": {