@praxisjs/vite-plugin 0.1.0 → 0.1.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # @praxisjs/vite-plugin
2
2
 
3
+ ## 0.1.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 2c61a25: Refresh dependencies across workspace to improve stability and security.
8
+
9
+ Bumped versions of several packages, including @types/node, eslint, and unocss, to enhance compatibility and security.
10
+
3
11
  ## 0.1.0
4
12
 
5
13
  ### Minor Changes
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=index.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/index.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,122 @@
1
+ import { describe, it, expect, vi } from "vitest";
2
+ import { praxisjs } from "../index";
3
+ describe("praxisjs() plugin factory", () => {
4
+ it("returns two plugins by default (core + hmr)", () => {
5
+ const plugins = praxisjs();
6
+ expect(plugins).toHaveLength(2);
7
+ });
8
+ it("returns one plugin when hmr is disabled", () => {
9
+ const plugins = praxisjs({ hmr: false });
10
+ expect(plugins).toHaveLength(1);
11
+ });
12
+ it("core plugin has the correct name", () => {
13
+ const [core] = praxisjs();
14
+ expect(core.name).toBe("praxisjs:core");
15
+ });
16
+ it("core plugin enforces 'pre'", () => {
17
+ const [core] = praxisjs();
18
+ expect(core.enforce).toBe("pre");
19
+ });
20
+ it("hmr plugin has the correct name", () => {
21
+ const [, hmr] = praxisjs();
22
+ expect(hmr.name).toBe("praxisjs:hmr");
23
+ });
24
+ it("hmr plugin enforces 'post'", () => {
25
+ const [, hmr] = praxisjs();
26
+ expect(hmr.enforce).toBe("post");
27
+ });
28
+ });
29
+ describe("praxisjs:core config()", () => {
30
+ it("sets esbuild target to es2022", () => {
31
+ const [core] = praxisjs();
32
+ const config = core.config();
33
+ expect(config).toEqual({ esbuild: { target: "es2022" } });
34
+ });
35
+ });
36
+ describe("praxisjs:core transform()", () => {
37
+ it("returns null for .tsx files when autoImport is enabled", () => {
38
+ const [core] = praxisjs({ autoImport: true });
39
+ const transform = core.transform;
40
+ const result = transform("const x = 1;", "component.tsx");
41
+ expect(result).toBeNull();
42
+ });
43
+ it("returns null for .jsx files when autoImport is enabled", () => {
44
+ const [core] = praxisjs({ autoImport: true });
45
+ const transform = core.transform;
46
+ const result = transform("const x = 1;", "component.jsx");
47
+ expect(result).toBeNull();
48
+ });
49
+ it("returns undefined (no-op) for non-.tsx/.jsx files", () => {
50
+ const [core] = praxisjs({ autoImport: true });
51
+ const transform = core.transform;
52
+ const result = transform("const x = 1;", "module.ts");
53
+ expect(result).toBeUndefined();
54
+ });
55
+ it("returns undefined when autoImport is false", () => {
56
+ const [core] = praxisjs({ autoImport: false });
57
+ const transform = core.transform;
58
+ const result = transform("const x = 1;", "component.tsx");
59
+ expect(result).toBeUndefined();
60
+ });
61
+ it("returns undefined when code already imports @praxisjs/jsx/jsx-runtime", () => {
62
+ const [core] = praxisjs({ autoImport: true });
63
+ const transform = core.transform;
64
+ const code = 'import "@praxisjs/jsx/jsx-runtime"; const x = 1;';
65
+ const result = transform(code, "component.tsx");
66
+ expect(result).toBeUndefined();
67
+ });
68
+ });
69
+ describe("praxisjs:hmr handleHotUpdate()", () => {
70
+ function makeMockServer() {
71
+ return {
72
+ ws: {
73
+ send: vi.fn(),
74
+ },
75
+ };
76
+ }
77
+ it("sends custom event for .ts files", () => {
78
+ const [, hmr] = praxisjs({ hmr: true });
79
+ const server = makeMockServer();
80
+ hmr.handleHotUpdate({
81
+ file: "src/app.ts",
82
+ server,
83
+ });
84
+ expect(server.ws.send).toHaveBeenCalledWith({
85
+ type: "custom",
86
+ event: "praxisjs:component-update",
87
+ data: { file: "src/app.ts" },
88
+ });
89
+ });
90
+ it("sends custom event for .tsx files", () => {
91
+ const [, hmr] = praxisjs({ hmr: true });
92
+ const server = makeMockServer();
93
+ hmr.handleHotUpdate({
94
+ file: "src/component.tsx",
95
+ server,
96
+ });
97
+ expect(server.ws.send).toHaveBeenCalledWith({
98
+ type: "custom",
99
+ event: "praxisjs:component-update",
100
+ data: { file: "src/component.tsx" },
101
+ });
102
+ });
103
+ it("does not send event for non-.ts/.tsx files", () => {
104
+ const [, hmr] = praxisjs({ hmr: true });
105
+ const server = makeMockServer();
106
+ hmr.handleHotUpdate({
107
+ file: "src/style.css",
108
+ server,
109
+ });
110
+ expect(server.ws.send).not.toHaveBeenCalled();
111
+ });
112
+ it("does not send event for .js files", () => {
113
+ const [, hmr] = praxisjs({ hmr: true });
114
+ const server = makeMockServer();
115
+ hmr.handleHotUpdate({
116
+ file: "src/utils.js",
117
+ server,
118
+ });
119
+ expect(server.ws.send).not.toHaveBeenCalled();
120
+ });
121
+ });
122
+ //# sourceMappingURL=index.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.test.js","sourceRoot":"","sources":["../../src/__tests__/index.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAElD,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAEpC,QAAQ,CAAC,2BAA2B,EAAE,GAAG,EAAE;IACzC,EAAE,CAAC,6CAA6C,EAAE,GAAG,EAAE;QACrD,MAAM,OAAO,GAAG,QAAQ,EAAE,CAAC;QAC3B,MAAM,CAAC,OAAO,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;IAClC,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,yCAAyC,EAAE,GAAG,EAAE;QACjD,MAAM,OAAO,GAAG,QAAQ,CAAC,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC,CAAC;QACzC,MAAM,CAAC,OAAO,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;IAClC,CAAC,CAAC,CAAC;IAEH,EAAE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@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@praxisjs/vite-plugin",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -14,7 +14,7 @@
14
14
  "vite": ">=7.0.0"
15
15
  },
16
16
  "devDependencies": {
17
- "@types/node": "^25.3.0",
17
+ "@types/node": "^25.5.0",
18
18
  "typescript": "^5.9.3",
19
19
  "vite": "^7.3.1"
20
20
  },
@@ -0,0 +1,143 @@
1
+ import { describe, it, expect, vi } from "vitest";
2
+
3
+ import { praxisjs } from "../index";
4
+
5
+ describe("praxisjs() plugin factory", () => {
6
+ it("returns two plugins by default (core + hmr)", () => {
7
+ const plugins = praxisjs();
8
+ expect(plugins).toHaveLength(2);
9
+ });
10
+
11
+ it("returns one plugin when hmr is disabled", () => {
12
+ const plugins = praxisjs({ hmr: false });
13
+ expect(plugins).toHaveLength(1);
14
+ });
15
+
16
+ it("core plugin has the correct name", () => {
17
+ const [core] = praxisjs();
18
+ expect(core.name).toBe("praxisjs:core");
19
+ });
20
+
21
+ it("core plugin enforces 'pre'", () => {
22
+ const [core] = praxisjs();
23
+ expect(core.enforce).toBe("pre");
24
+ });
25
+
26
+ it("hmr plugin has the correct name", () => {
27
+ const [, hmr] = praxisjs();
28
+ expect(hmr.name).toBe("praxisjs:hmr");
29
+ });
30
+
31
+ it("hmr plugin enforces 'post'", () => {
32
+ const [, hmr] = praxisjs();
33
+ expect(hmr.enforce).toBe("post");
34
+ });
35
+ });
36
+
37
+ describe("praxisjs:core config()", () => {
38
+ it("sets esbuild target to es2022", () => {
39
+ const [core] = praxisjs();
40
+ const config = (core as unknown as { config: () => unknown }).config();
41
+ expect(config).toEqual({ esbuild: { target: "es2022" } });
42
+ });
43
+ });
44
+
45
+ describe("praxisjs:core transform()", () => {
46
+ type TransformFn = (code: string, id: string) => null | undefined;
47
+
48
+ it("returns null for .tsx files when autoImport is enabled", () => {
49
+ const [core] = praxisjs({ autoImport: true });
50
+ const transform = (core as { transform: TransformFn }).transform;
51
+ const result = transform("const x = 1;", "component.tsx");
52
+ expect(result).toBeNull();
53
+ });
54
+
55
+ it("returns null for .jsx files when autoImport is enabled", () => {
56
+ const [core] = praxisjs({ autoImport: true });
57
+ const transform = (core as { transform: TransformFn }).transform;
58
+ const result = transform("const x = 1;", "component.jsx");
59
+ expect(result).toBeNull();
60
+ });
61
+
62
+ it("returns undefined (no-op) for non-.tsx/.jsx files", () => {
63
+ const [core] = praxisjs({ autoImport: true });
64
+ const transform = (core as { transform: TransformFn }).transform;
65
+ const result = transform("const x = 1;", "module.ts");
66
+ expect(result).toBeUndefined();
67
+ });
68
+
69
+ it("returns undefined when autoImport is false", () => {
70
+ const [core] = praxisjs({ autoImport: false });
71
+ const transform = (core as { transform: TransformFn }).transform;
72
+ const result = transform("const x = 1;", "component.tsx");
73
+ expect(result).toBeUndefined();
74
+ });
75
+
76
+ it("returns undefined when code already imports @praxisjs/jsx/jsx-runtime", () => {
77
+ const [core] = praxisjs({ autoImport: true });
78
+ const transform = (core as { transform: TransformFn }).transform;
79
+ const code = 'import "@praxisjs/jsx/jsx-runtime"; const x = 1;';
80
+ const result = transform(code, "component.tsx");
81
+ expect(result).toBeUndefined();
82
+ });
83
+ });
84
+
85
+ describe("praxisjs:hmr handleHotUpdate()", () => {
86
+ type HandleHotUpdate = (ctx: { file: string; server: unknown }) => void;
87
+
88
+ function makeMockServer() {
89
+ return {
90
+ ws: {
91
+ send: vi.fn(),
92
+ },
93
+ };
94
+ }
95
+
96
+ it("sends custom event for .ts files", () => {
97
+ const [, hmr] = praxisjs({ hmr: true });
98
+ const server = makeMockServer();
99
+ (hmr as unknown as { handleHotUpdate: HandleHotUpdate }).handleHotUpdate({
100
+ file: "src/app.ts",
101
+ server,
102
+ });
103
+ expect(server.ws.send).toHaveBeenCalledWith({
104
+ type: "custom",
105
+ event: "praxisjs:component-update",
106
+ data: { file: "src/app.ts" },
107
+ });
108
+ });
109
+
110
+ it("sends custom event for .tsx files", () => {
111
+ const [, hmr] = praxisjs({ hmr: true });
112
+ const server = makeMockServer();
113
+ (hmr as unknown as { handleHotUpdate: HandleHotUpdate }).handleHotUpdate({
114
+ file: "src/component.tsx",
115
+ server,
116
+ });
117
+ expect(server.ws.send).toHaveBeenCalledWith({
118
+ type: "custom",
119
+ event: "praxisjs:component-update",
120
+ data: { file: "src/component.tsx" },
121
+ });
122
+ });
123
+
124
+ it("does not send event for non-.ts/.tsx files", () => {
125
+ const [, hmr] = praxisjs({ hmr: true });
126
+ const server = makeMockServer();
127
+ (hmr as unknown as { handleHotUpdate: HandleHotUpdate }).handleHotUpdate({
128
+ file: "src/style.css",
129
+ server,
130
+ });
131
+ expect(server.ws.send).not.toHaveBeenCalled();
132
+ });
133
+
134
+ it("does not send event for .js files", () => {
135
+ const [, hmr] = praxisjs({ hmr: true });
136
+ const server = makeMockServer();
137
+ (hmr as unknown as { handleHotUpdate: HandleHotUpdate }).handleHotUpdate({
138
+ file: "src/utils.js",
139
+ server,
140
+ });
141
+ expect(server.ws.send).not.toHaveBeenCalled();
142
+ });
143
+ });