nexa-vite-plugin 0.1.0

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.
@@ -0,0 +1,2 @@
1
+ export { nexaPlugin } from './plugin.js';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA"}
package/dist/index.js ADDED
@@ -0,0 +1,2 @@
1
+ export { nexaPlugin } from './plugin.js';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA"}
@@ -0,0 +1,2 @@
1
+ export declare function nexaPlugin(): any;
2
+ //# sourceMappingURL=plugin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAIA,wBAAgB,UAAU,IAAI,GAAG,CAsDhC"}
package/dist/plugin.js ADDED
@@ -0,0 +1,52 @@
1
+ import { parseSFC, generateComponentCode } from 'nexa-compiler';
2
+ const nexaExt = '.nexa';
3
+ export function nexaPlugin() {
4
+ return {
5
+ name: 'vite-plugin-nexa',
6
+ enforce: 'pre',
7
+ transform(code, id) {
8
+ if (!id.endsWith(nexaExt))
9
+ return null;
10
+ try {
11
+ const sfc = parseSFC(code);
12
+ const scriptContent = sfc.script?.content || '';
13
+ const templateContent = sfc.template?.content || null;
14
+ const compiled = generateComponentCode({
15
+ template: templateContent,
16
+ script: scriptContent,
17
+ style: sfc.styles[0]?.content || null,
18
+ scoped: sfc.styles[0]?.scoped || false,
19
+ });
20
+ return {
21
+ code: compiled,
22
+ map: null,
23
+ };
24
+ }
25
+ catch (err) {
26
+ const message = err instanceof Error ? err.message : String(err);
27
+ this.error(`Nexa compiler error in ${id}: ${message}`);
28
+ return null;
29
+ }
30
+ },
31
+ handleHotUpdate(ctx) {
32
+ const { file, server } = ctx;
33
+ if (file.endsWith(nexaExt)) {
34
+ const module = server.moduleGraph.getModuleById(file);
35
+ if (module) {
36
+ server.moduleGraph.invalidateModule(module);
37
+ }
38
+ server.ws.send({
39
+ type: 'update',
40
+ updates: [{
41
+ type: 'js-update',
42
+ path: file,
43
+ acceptedPath: file,
44
+ timestamp: Date.now(),
45
+ }],
46
+ });
47
+ return [];
48
+ }
49
+ },
50
+ };
51
+ }
52
+ //# sourceMappingURL=plugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.js","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAA;AAE/D,MAAM,OAAO,GAAG,OAAO,CAAA;AAEvB,MAAM,UAAU,UAAU;IACxB,OAAO;QACL,IAAI,EAAE,kBAAkB;QACxB,OAAO,EAAE,KAAc;QAEvB,SAAS,CAAC,IAAY,EAAE,EAAU;YAChC,IAAI,CAAC,EAAE,CAAC,QAAQ,CAAC,OAAO,CAAC;gBAAE,OAAO,IAAI,CAAA;YAEtC,IAAI,CAAC;gBACH,MAAM,GAAG,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAA;gBAC1B,MAAM,aAAa,GAAG,GAAG,CAAC,MAAM,EAAE,OAAO,IAAI,EAAE,CAAA;gBAC/C,MAAM,eAAe,GAAG,GAAG,CAAC,QAAQ,EAAE,OAAO,IAAI,IAAI,CAAA;gBAErD,MAAM,QAAQ,GAAG,qBAAqB,CAAC;oBACrC,QAAQ,EAAE,eAAe;oBACzB,MAAM,EAAE,aAAa;oBACrB,KAAK,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,OAAO,IAAI,IAAI;oBACrC,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,IAAI,KAAK;iBACvC,CAAC,CAAA;gBAEF,OAAO;oBACL,IAAI,EAAE,QAAQ;oBACd,GAAG,EAAE,IAAI;iBACV,CAAA;YACH,CAAC;YAAC,OAAO,GAAG,EAAE,CAAC;gBACb,MAAM,OAAO,GAAG,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAA;gBAChE,IAAI,CAAC,KAAK,CAAC,0BAA0B,EAAE,KAAK,OAAO,EAAE,CAAC,CAAA;gBACtD,OAAO,IAAI,CAAA;YACb,CAAC;QACH,CAAC;QAED,eAAe,CAAC,GAAQ;YACtB,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,GAAG,CAAA;YAE5B,IAAI,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC;gBAC3B,MAAM,MAAM,GAAG,MAAM,CAAC,WAAW,CAAC,aAAa,CAAC,IAAI,CAAC,CAAA;gBACrD,IAAI,MAAM,EAAE,CAAC;oBACX,MAAM,CAAC,WAAW,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAA;gBAC7C,CAAC;gBAED,MAAM,CAAC,EAAE,CAAC,IAAI,CAAC;oBACb,IAAI,EAAE,QAAQ;oBACd,OAAO,EAAE,CAAC;4BACR,IAAI,EAAE,WAAW;4BACjB,IAAI,EAAE,IAAI;4BACV,YAAY,EAAE,IAAI;4BAClB,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE;yBACtB,CAAC;iBACH,CAAC,CAAA;gBAEF,OAAO,EAAE,CAAA;YACX,CAAC;QACH,CAAC;KACF,CAAA;AACH,CAAC"}
package/package.json ADDED
@@ -0,0 +1,31 @@
1
+ {
2
+ "name": "nexa-vite-plugin",
3
+ "version": "0.1.0",
4
+ "type": "module",
5
+ "main": "./dist/index.js",
6
+ "module": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.js",
12
+ "default": "./dist/index.js"
13
+ }
14
+ },
15
+ "dependencies": {
16
+ "nexa-compiler": "0.1.0"
17
+ },
18
+ "peerDependencies": {
19
+ "vite": "^5.0.0 || ^6.0.0"
20
+ },
21
+ "files": [
22
+ "dist"
23
+ ],
24
+ "publishConfig": {
25
+ "access": "public"
26
+ },
27
+ "scripts": {
28
+ "build": "tsc",
29
+ "clean": "rm -rf dist"
30
+ }
31
+ }