@jalvin/vite-plugin 2.0.32 → 2.0.34
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 @@
|
|
|
1
|
+
{"version":3,"file":"entry-module.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/entry-module.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const vitest_1 = require("vitest");
|
|
4
|
+
const index_js_1 = require("../../dist/index.js");
|
|
5
|
+
(0, vitest_1.describe)("vite-plugin virtual entry", () => {
|
|
6
|
+
(0, vitest_1.it)("uses one React root and never mutates #root via innerHTML", () => {
|
|
7
|
+
const plugin = (0, index_js_1.jalvin)({
|
|
8
|
+
entry: {
|
|
9
|
+
file: "./UIShowcase.jalvin",
|
|
10
|
+
component: "UIShowcase",
|
|
11
|
+
},
|
|
12
|
+
});
|
|
13
|
+
plugin.configResolved?.({ root: "/tmp/jalvin-app" });
|
|
14
|
+
const virtualId = plugin.resolveId?.("virtual:@jalvin/app-entry", undefined);
|
|
15
|
+
(0, vitest_1.expect)(virtualId).toBe("\0virtual:@jalvin/app-entry");
|
|
16
|
+
const generated = plugin.load?.(virtualId);
|
|
17
|
+
(0, vitest_1.expect)(typeof generated).toBe("string");
|
|
18
|
+
const entryModule = generated;
|
|
19
|
+
(0, vitest_1.expect)(entryModule).toContain('const root = ReactDOM.createRoot(rootEl);');
|
|
20
|
+
(0, vitest_1.expect)(entryModule).not.toContain("root.innerHTML");
|
|
21
|
+
const createRootCalls = entryModule.match(/createRoot\(/g) ?? [];
|
|
22
|
+
(0, vitest_1.expect)(createRootCalls).toHaveLength(1);
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
//# sourceMappingURL=entry-module.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entry-module.test.js","sourceRoot":"","sources":["../../src/__tests__/entry-module.test.ts"],"names":[],"mappings":";;AAAA,mCAA8C;AAC9C,kDAA6C;AAE7C,IAAA,iBAAQ,EAAC,2BAA2B,EAAE,GAAG,EAAE;IACzC,IAAA,WAAE,EAAC,2DAA2D,EAAE,GAAG,EAAE;QACnE,MAAM,MAAM,GAAG,IAAA,iBAAM,EAAC;YACpB,KAAK,EAAE;gBACL,IAAI,EAAE,qBAAqB;gBAC3B,SAAS,EAAE,YAAY;aACxB;SACF,CAAC,CAAC;QAEH,MAAM,CAAC,cAAc,EAAE,CAAC,EAAE,IAAI,EAAE,iBAAiB,EAAE,CAAC,CAAC;QAErD,MAAM,SAAS,GAAG,MAAM,CAAC,SAAS,EAAE,CAAC,2BAA2B,EAAE,SAAS,CAAC,CAAC;QAC7E,IAAA,eAAM,EAAC,SAAS,CAAC,CAAC,IAAI,CAAC,6BAA6B,CAAC,CAAC;QAEtD,MAAM,SAAS,GAAG,MAAM,CAAC,IAAI,EAAE,CAAC,SAAS,CAAC,CAAC;QAC3C,IAAA,eAAM,EAAC,OAAO,SAAS,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAExC,MAAM,WAAW,GAAG,SAAmB,CAAC;QACxC,IAAA,eAAM,EAAC,WAAW,CAAC,CAAC,SAAS,CAAC,2CAA2C,CAAC,CAAC;QAC3E,IAAA,eAAM,EAAC,WAAW,CAAC,CAAC,GAAG,CAAC,SAAS,CAAC,gBAAgB,CAAC,CAAC;QAEpD,MAAM,eAAe,GAAG,WAAW,CAAC,KAAK,CAAC,eAAe,CAAC,IAAI,EAAE,CAAC;QACjE,IAAA,eAAM,EAAC,eAAe,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;IAC1C,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -64,31 +64,31 @@ const compiler_1 = require("@jalvin/compiler");
|
|
|
64
64
|
const VIRTUAL_ENTRY = "virtual:@jalvin/app-entry";
|
|
65
65
|
const VIRTUAL_ENTRY_RESOLVED = "\0virtual:@jalvin/app-entry";
|
|
66
66
|
function generateIndexHtml(title, scriptSrc) {
|
|
67
|
-
return `<!DOCTYPE html>
|
|
68
|
-
<html lang="en">
|
|
69
|
-
<head>
|
|
70
|
-
<meta charset="UTF-8" />
|
|
71
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
72
|
-
<title>${title}</title>
|
|
73
|
-
<style>
|
|
74
|
-
*, *::before, *::after { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
|
|
75
|
-
html, body { height: 100%; margin: 0; overflow-x: hidden; }
|
|
76
|
-
body {
|
|
77
|
-
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
|
|
78
|
-
background: #fafafa;
|
|
79
|
-
color: #1c1c1c;
|
|
80
|
-
-webkit-text-size-adjust: 100%;
|
|
81
|
-
text-size-adjust: 100%;
|
|
82
|
-
}
|
|
83
|
-
#root { height: 100%; }
|
|
84
|
-
button { touch-action: manipulation; }
|
|
85
|
-
input, textarea, select { font-size: 1rem; }
|
|
86
|
-
</style>
|
|
87
|
-
</head>
|
|
88
|
-
<body>
|
|
89
|
-
<div id="root"></div>
|
|
90
|
-
<script type="module" src="${scriptSrc}"></script>
|
|
91
|
-
</body>
|
|
67
|
+
return `<!DOCTYPE html>
|
|
68
|
+
<html lang="en">
|
|
69
|
+
<head>
|
|
70
|
+
<meta charset="UTF-8" />
|
|
71
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
72
|
+
<title>${title}</title>
|
|
73
|
+
<style>
|
|
74
|
+
*, *::before, *::after { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
|
|
75
|
+
html, body { height: 100%; margin: 0; overflow-x: hidden; }
|
|
76
|
+
body {
|
|
77
|
+
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
|
|
78
|
+
background: #fafafa;
|
|
79
|
+
color: #1c1c1c;
|
|
80
|
+
-webkit-text-size-adjust: 100%;
|
|
81
|
+
text-size-adjust: 100%;
|
|
82
|
+
}
|
|
83
|
+
#root { height: 100%; }
|
|
84
|
+
button { touch-action: manipulation; }
|
|
85
|
+
input, textarea, select { font-size: 1rem; }
|
|
86
|
+
</style>
|
|
87
|
+
</head>
|
|
88
|
+
<body>
|
|
89
|
+
<div id="root"></div>
|
|
90
|
+
<script type="module" src="${scriptSrc}"></script>
|
|
91
|
+
</body>
|
|
92
92
|
</html>`;
|
|
93
93
|
}
|
|
94
94
|
function generateEntryModule(entryFilePath, component) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jalvin/vite-plugin",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.34",
|
|
4
4
|
"description": "Vite plugin for the Jalvin language — import .jalvin files directly",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -12,28 +12,24 @@
|
|
|
12
12
|
"types": "./dist/index.d.ts"
|
|
13
13
|
}
|
|
14
14
|
},
|
|
15
|
-
"publishConfig": {
|
|
16
|
-
|
|
15
|
+
"publishConfig": { "access": "public" },
|
|
16
|
+
"files": ["dist"],
|
|
17
|
+
"scripts": {
|
|
18
|
+
"build": "tsc -p tsconfig.json",
|
|
19
|
+
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
20
|
+
"test": "pnpm build && vitest run",
|
|
21
|
+
"test:watch": "vitest"
|
|
17
22
|
},
|
|
18
|
-
"files": [
|
|
19
|
-
"dist"
|
|
20
|
-
],
|
|
21
23
|
"peerDependencies": {
|
|
22
24
|
"vite": ">=5.0.0"
|
|
23
25
|
},
|
|
24
26
|
"dependencies": {
|
|
25
|
-
"@jalvin/compiler": "
|
|
27
|
+
"@jalvin/compiler": "workspace:*"
|
|
26
28
|
},
|
|
27
29
|
"devDependencies": {
|
|
28
30
|
"typescript": "^5.4.0",
|
|
29
31
|
"@types/node": "^20.0.0",
|
|
30
32
|
"vite": "^5.0.0",
|
|
31
33
|
"vitest": "^2.1.9"
|
|
32
|
-
},
|
|
33
|
-
"scripts": {
|
|
34
|
-
"build": "tsc -p tsconfig.json",
|
|
35
|
-
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
36
|
-
"test": "pnpm build && vitest run",
|
|
37
|
-
"test:watch": "vitest"
|
|
38
34
|
}
|
|
39
|
-
}
|
|
35
|
+
}
|