@jalvin/vite-plugin 1.0.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.
- package/dist/index.d.ts +20 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +85 -0
- package/dist/index.js.map +1 -0
- package/package.json +36 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export interface JalvinViteOptions {
|
|
2
|
+
/**
|
|
3
|
+
* Extra file extensions to treat as Jalvin sources.
|
|
4
|
+
* Default: [".jalvin"]
|
|
5
|
+
*/
|
|
6
|
+
extensions?: string[];
|
|
7
|
+
/**
|
|
8
|
+
* Emit TypeScript type annotations in output.
|
|
9
|
+
* Default: false
|
|
10
|
+
*/
|
|
11
|
+
emitTypes?: boolean;
|
|
12
|
+
/**
|
|
13
|
+
* Runtime package to import from.
|
|
14
|
+
* Default: "@jalvin/runtime"
|
|
15
|
+
*/
|
|
16
|
+
runtimeImport?: string;
|
|
17
|
+
}
|
|
18
|
+
export declare function jalvin(opts?: JalvinViteOptions): any;
|
|
19
|
+
export default jalvin;
|
|
20
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAkBA,MAAM,WAAW,iBAAiB;IAChC;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB;;;OAGG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;;;OAGG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,wBAAgB,MAAM,CAAC,IAAI,GAAE,iBAAsB,GAAG,GAAG,CAuExD;AAED,eAAe,MAAM,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
3
|
+
// @jalvin/vite-plugin — Vite plugin for the Jalvin language
|
|
4
|
+
//
|
|
5
|
+
// Usage (vite.config.ts):
|
|
6
|
+
//
|
|
7
|
+
// import jalvin from "@jalvin/vite-plugin";
|
|
8
|
+
//
|
|
9
|
+
// export default defineConfig({
|
|
10
|
+
// plugins: [jalvin()],
|
|
11
|
+
// });
|
|
12
|
+
//
|
|
13
|
+
// You can then import .jalvin files directly in your app:
|
|
14
|
+
//
|
|
15
|
+
// import { Counter } from "./Counter.jalvin";
|
|
16
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.jalvin = jalvin;
|
|
19
|
+
const compiler_1 = require("@jalvin/compiler");
|
|
20
|
+
function jalvin(opts = {}) {
|
|
21
|
+
const extensions = opts.extensions ?? [".jalvin"];
|
|
22
|
+
let viteConfig;
|
|
23
|
+
const isJalvinFile = (id) => extensions.some((ext) => id.endsWith(ext));
|
|
24
|
+
return {
|
|
25
|
+
name: "vite-plugin-jalvin",
|
|
26
|
+
enforce: "pre",
|
|
27
|
+
configResolved(config) {
|
|
28
|
+
viteConfig = config;
|
|
29
|
+
},
|
|
30
|
+
resolveId(id, importer) {
|
|
31
|
+
// Allow .jalvin imports without explicit extension in some scenarios
|
|
32
|
+
if (isJalvinFile(id))
|
|
33
|
+
return id;
|
|
34
|
+
return null;
|
|
35
|
+
},
|
|
36
|
+
transform(code, id) {
|
|
37
|
+
if (!isJalvinFile(id))
|
|
38
|
+
return null;
|
|
39
|
+
const result = (0, compiler_1.compile)(code, id, {
|
|
40
|
+
emitTypes: opts.emitTypes ?? false,
|
|
41
|
+
runtimeImport: opts.runtimeImport ?? "@jalvin/runtime",
|
|
42
|
+
});
|
|
43
|
+
if (!result.ok) {
|
|
44
|
+
const errors = result.diagnostics.items
|
|
45
|
+
.filter((d) => d.severity === "error")
|
|
46
|
+
.map((d) => {
|
|
47
|
+
const loc = d.span ? `${id}:${d.span.startLine + 1}:${d.span.startCol + 1}` : id;
|
|
48
|
+
return ` ${loc}: ${d.message} [${d.code}]`;
|
|
49
|
+
})
|
|
50
|
+
.join("\n");
|
|
51
|
+
this.error(`Jalvin compilation failed:\n${errors}`);
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
// Surface warnings through Vite
|
|
55
|
+
for (const diag of result.diagnostics.items) {
|
|
56
|
+
if (diag.severity === "warning") {
|
|
57
|
+
this.warn({
|
|
58
|
+
message: diag.message,
|
|
59
|
+
id,
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return {
|
|
64
|
+
code: result.code,
|
|
65
|
+
// Basic line map for source-map support
|
|
66
|
+
map: {
|
|
67
|
+
version: 3,
|
|
68
|
+
sources: [id],
|
|
69
|
+
sourcesContent: [code],
|
|
70
|
+
mappings: "",
|
|
71
|
+
names: [],
|
|
72
|
+
},
|
|
73
|
+
};
|
|
74
|
+
},
|
|
75
|
+
handleHotUpdate({ file, server }) {
|
|
76
|
+
if (!isJalvinFile(file))
|
|
77
|
+
return;
|
|
78
|
+
// Force full reload for now — incremental recompile is straightforward
|
|
79
|
+
server.ws.send({ type: "full-reload", path: file });
|
|
80
|
+
return [];
|
|
81
|
+
},
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
exports.default = jalvin;
|
|
85
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,4DAA4D;AAC5D,EAAE;AACF,0BAA0B;AAC1B,EAAE;AACF,8CAA8C;AAC9C,EAAE;AACF,kCAAkC;AAClC,2BAA2B;AAC3B,QAAQ;AACR,EAAE;AACF,0DAA0D;AAC1D,EAAE;AACF,gDAAgD;AAChD,gFAAgF;;AAsBhF,wBAuEC;AA3FD,+CAA2C;AAoB3C,SAAgB,MAAM,CAAC,OAA0B,EAAE;IACjD,MAAM,UAA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Jalvin language — import .jalvin files directly",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"module": "dist/index.mjs",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"import": "./dist/index.mjs",
|
|
11
|
+
"require": "./dist/index.js",
|
|
12
|
+
"types": "./dist/index.d.ts"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"publishConfig": {
|
|
16
|
+
"access": "public"
|
|
17
|
+
},
|
|
18
|
+
"files": [
|
|
19
|
+
"dist"
|
|
20
|
+
],
|
|
21
|
+
"peerDependencies": {
|
|
22
|
+
"vite": ">=5.0.0"
|
|
23
|
+
},
|
|
24
|
+
"dependencies": {
|
|
25
|
+
"@jalvin/compiler": "1.0.0"
|
|
26
|
+
},
|
|
27
|
+
"devDependencies": {
|
|
28
|
+
"typescript": "^5.4.0",
|
|
29
|
+
"@types/node": "^20.0.0",
|
|
30
|
+
"vite": "^5.0.0"
|
|
31
|
+
},
|
|
32
|
+
"scripts": {
|
|
33
|
+
"build": "tsc -p tsconfig.json",
|
|
34
|
+
"typecheck": "tsc -p tsconfig.json --noEmit"
|
|
35
|
+
}
|
|
36
|
+
}
|