svelte-ag 1.0.36 → 1.0.37

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.
@@ -15,6 +15,6 @@ interface Options {
15
15
  */
16
16
  safePackages: string[];
17
17
  }
18
- export default function componentSourceCollector(opts?: Options): Plugin;
18
+ export default function componentSourceCollector(opts?: Options): Promise<Plugin>;
19
19
  export {};
20
20
  //# sourceMappingURL=vite-plugin-component-source-collector.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"vite-plugin-component-source-collector.d.ts","sourceRoot":"","sources":["../../../src/lib/vite/vite-plugin-component-source-collector.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAkB,MAAM,MAAM,CAAC;AAKnD,UAAU,OAAO;IACf;;;;OAIG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAC5B;;OAEG;IACH,YAAY,EAAE,MAAM,EAAE,CAAC;CACxB;AAKD,MAAM,CAAC,OAAO,UAAU,wBAAwB,CAAC,IAAI,GAAE,OAA8B,GAAG,MAAM,CA4J7F"}
1
+ {"version":3,"file":"vite-plugin-component-source-collector.d.ts","sourceRoot":"","sources":["../../../src/lib/vite/vite-plugin-component-source-collector.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAkB,MAAM,MAAM,CAAC;AAMnD,UAAU,OAAO;IACf;;;;OAIG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAC5B;;OAEG;IACH,YAAY,EAAE,MAAM,EAAE,CAAC;CACxB;AAKD,wBAA8B,wBAAwB,CAAC,IAAI,GAAE,OAA8B,GAAG,OAAO,CAAC,MAAM,CAAC,CAoK5G"}
@@ -1,9 +1,10 @@
1
1
  import { exists, writeIfDifferent } from 'ts-ag';
2
2
  import { readFile } from 'fs/promises';
3
3
  import { resolve, join, relative, dirname } from 'path';
4
+ import { open } from 'fs/promises';
4
5
  /** All unique component directories */
5
6
  const componentFiles = new Set();
6
- export default function componentSourceCollector(opts = { safePackages: [] }) {
7
+ export default async function componentSourceCollector(opts = { safePackages: [] }) {
7
8
  // constants
8
9
  const outFileName = opts.outputFile ?? 'component-sources.css';
9
10
  const classRegex = /class(?:=|:)/;
@@ -15,6 +16,7 @@ export default function componentSourceCollector(opts = { safePackages: [] }) {
15
16
  let firstRound = true;
16
17
  let initialTransformDone = false;
17
18
  let initialTransformTimer = null;
19
+ // init
18
20
  function shouldAdd(code) {
19
21
  return classRegex.test(code);
20
22
  }
@@ -26,7 +28,7 @@ export default function componentSourceCollector(opts = { safePackages: [] }) {
26
28
  (!/\.pnpm|.vite/.test(file) || opts.safePackages.some((p) => file.includes(`node_modules/${p}`)))) {
27
29
  const cleanedFileName = file.replace(/\?v=.*$/, '');
28
30
  const relativeFilePath = relative(dirname(outputFilePath), cleanedFileName);
29
- if (relativeFilePath !== outputFilePath) {
31
+ if (relativeFilePath !== outFileName) {
30
32
  // Dont add itself
31
33
  componentFiles.add(relativeFilePath);
32
34
  }
@@ -42,6 +44,10 @@ export default function componentSourceCollector(opts = { safePackages: [] }) {
42
44
  }
43
45
  }, 1000); // adjust delay as needed
44
46
  }
47
+ async function touch(path) {
48
+ const handle = await open(path, 'a');
49
+ await handle.close();
50
+ }
45
51
  const writeOutFile = async () => {
46
52
  const lines = Array.from(componentFiles)
47
53
  .map((d) => `@source '${d}';`)
@@ -63,6 +69,7 @@ export default function componentSourceCollector(opts = { safePackages: [] }) {
63
69
  config = resolved;
64
70
  root = config.root;
65
71
  outputFilePath = resolve(root, outFileName);
72
+ await touch(outputFilePath);
66
73
  if (config.command === 'build' && firstRound) {
67
74
  componentFiles.clear();
68
75
  firstRound = false;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "svelte-ag",
3
- "version": "1.0.36",
3
+ "version": "1.0.37",
4
4
  "description": "Useful svelte components",
5
5
  "bugs": "https://github.com/ageorgeh/svelte-ag/issues",
6
6
  "repository": {
@@ -78,13 +78,13 @@
78
78
  "@tailwindcss/typography": "^0.5.19",
79
79
  "@tailwindcss/vite": "^4.2.1",
80
80
  "@types/node": "^24.11.0",
81
- "@typescript/native-preview": "7.0.0-dev.20260228.1",
81
+ "@typescript/native-preview": "7.0.0-dev.20260301.1",
82
82
  "eslint": "^10.0.2",
83
83
  "eslint-plugin-better-tailwindcss": "^4.3.1",
84
84
  "eslint-plugin-svelte": "^3.15.0",
85
- "globals": "^17.3.0",
85
+ "globals": "^17.4.0",
86
86
  "husky": "^9.1.7",
87
- "lint-staged": "^16.3.0",
87
+ "lint-staged": "^16.3.1",
88
88
  "prettier": "^3.8.1",
89
89
  "prettier-plugin-packagejson": "^3.0.0",
90
90
  "prettier-plugin-svelte": "^3.5.0",
@@ -2,6 +2,7 @@ import type { Plugin, ResolvedConfig } from 'vite';
2
2
  import { exists, writeIfDifferent } from 'ts-ag';
3
3
  import { readFile } from 'fs/promises';
4
4
  import { resolve, join, relative, dirname } from 'path';
5
+ import { open } from 'fs/promises';
5
6
 
6
7
  interface Options {
7
8
  /**
@@ -23,7 +24,7 @@ interface Options {
23
24
  /** All unique component directories */
24
25
  const componentFiles = new Set<string>();
25
26
 
26
- export default function componentSourceCollector(opts: Options = { safePackages: [] }): Plugin {
27
+ export default async function componentSourceCollector(opts: Options = { safePackages: [] }): Promise<Plugin> {
27
28
  // constants
28
29
  const outFileName = opts.outputFile ?? 'component-sources.css';
29
30
  const classRegex = /class(?:=|:)/;
@@ -38,6 +39,7 @@ export default function componentSourceCollector(opts: Options = { safePackages:
38
39
  let initialTransformDone = false;
39
40
  let initialTransformTimer: NodeJS.Timeout | null = null;
40
41
 
42
+ // init
41
43
  function shouldAdd(code: string) {
42
44
  return classRegex.test(code);
43
45
  }
@@ -53,7 +55,7 @@ export default function componentSourceCollector(opts: Options = { safePackages:
53
55
  const cleanedFileName = file.replace(/\?v=.*$/, '');
54
56
  const relativeFilePath = relative(dirname(outputFilePath), cleanedFileName);
55
57
 
56
- if (relativeFilePath !== outputFilePath) {
58
+ if (relativeFilePath !== outFileName) {
57
59
  // Dont add itself
58
60
  componentFiles.add(relativeFilePath);
59
61
  }
@@ -70,6 +72,11 @@ export default function componentSourceCollector(opts: Options = { safePackages:
70
72
  }, 1000); // adjust delay as needed
71
73
  }
72
74
 
75
+ async function touch(path: string) {
76
+ const handle = await open(path, 'a');
77
+ await handle.close();
78
+ }
79
+
73
80
  const writeOutFile = async () => {
74
81
  const lines = Array.from(componentFiles)
75
82
  .map((d) => `@source '${d}';`)
@@ -95,6 +102,8 @@ export default function componentSourceCollector(opts: Options = { safePackages:
95
102
  root = config.root;
96
103
  outputFilePath = resolve(root, outFileName);
97
104
 
105
+ await touch(outputFilePath);
106
+
98
107
  if (config.command === 'build' && firstRound) {
99
108
  componentFiles.clear();
100
109
  firstRound = false;