@batijs/build 0.0.1 → 0.0.2
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/chunk-IYRELEBO.js +15 -0
- package/dist/{chunk-U7QQNTGA.js → chunk-MGVFRR6M.js} +4 -7
- package/dist/{chunk-3EUYSS5H.js → chunk-N3I7EPEL.js} +1 -1
- package/dist/eval.d.ts +1 -1
- package/dist/eval.js +2 -1
- package/dist/exec.js +7 -7
- package/dist/parse.js +3 -2
- package/dist/transpile-ts.d.ts +3 -0
- package/dist/transpile-ts.js +6 -0
- package/package.json +1 -1
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import {
|
|
2
|
+
transpileTs
|
|
3
|
+
} from "./chunk-MGVFRR6M.js";
|
|
4
|
+
|
|
5
|
+
// src/eval.ts
|
|
6
|
+
function evalCondition(code, meta = {}) {
|
|
7
|
+
code = code.replaceAll("import.meta", "VIKE_META");
|
|
8
|
+
code = `var VIKE_META = ${JSON.stringify(meta)};(${code})`;
|
|
9
|
+
code = transpileTs(code);
|
|
10
|
+
return (0, eval)(code);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export {
|
|
14
|
+
evalCondition
|
|
15
|
+
};
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
// src/
|
|
1
|
+
// src/transpile-ts.ts
|
|
2
2
|
import ts from "typescript";
|
|
3
|
-
function
|
|
4
|
-
|
|
5
|
-
obj = `var VIKE_META = ${JSON.stringify(meta)};(${obj})`;
|
|
6
|
-
obj = ts.transpile(obj, {
|
|
3
|
+
function transpileTs(code) {
|
|
4
|
+
return ts.transpile(code, {
|
|
7
5
|
strict: true,
|
|
8
6
|
allowJs: true,
|
|
9
7
|
checkJs: true,
|
|
@@ -18,9 +16,8 @@ function evalCondition(obj, meta = {}) {
|
|
|
18
16
|
lib: ["DOM", "DOM.Iterable", "ESNext"],
|
|
19
17
|
types: ["@types/node"]
|
|
20
18
|
});
|
|
21
|
-
return (0, eval)(obj);
|
|
22
19
|
}
|
|
23
20
|
|
|
24
21
|
export {
|
|
25
|
-
|
|
22
|
+
transpileTs
|
|
26
23
|
};
|
package/dist/eval.d.ts
CHANGED
package/dist/eval.js
CHANGED
package/dist/exec.js
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ast,
|
|
3
3
|
transform
|
|
4
|
-
} from "./chunk-
|
|
5
|
-
import "./chunk-
|
|
4
|
+
} from "./chunk-N3I7EPEL.js";
|
|
5
|
+
import "./chunk-IYRELEBO.js";
|
|
6
|
+
import {
|
|
7
|
+
transpileTs
|
|
8
|
+
} from "./chunk-MGVFRR6M.js";
|
|
6
9
|
import "./chunk-5XFUXMWM.js";
|
|
7
10
|
|
|
8
11
|
// src/exec.ts
|
|
@@ -75,13 +78,10 @@ async function main(options, meta) {
|
|
|
75
78
|
}
|
|
76
79
|
const parsed = path.parse(p);
|
|
77
80
|
if (parsed.name.startsWith("$")) {
|
|
78
|
-
const tmpfile = path.join(
|
|
79
|
-
parsed.dir,
|
|
80
|
-
`${parsed.name}.${(/* @__PURE__ */ new Date()).toISOString().replaceAll(":", "-")}${parsed.ext}`
|
|
81
|
-
);
|
|
81
|
+
const tmpfile = path.join(parsed.dir, `${parsed.name}.${(/* @__PURE__ */ new Date()).toISOString().replaceAll(":", "-")}.js`);
|
|
82
82
|
let fileContent = null;
|
|
83
83
|
try {
|
|
84
|
-
await writeFile(tmpfile, code, { encoding: "utf-8" });
|
|
84
|
+
await writeFile(tmpfile, parsed.ext === ".ts" ? transpileTs(code) : code, { encoding: "utf-8" });
|
|
85
85
|
const f = await import(tmpfile);
|
|
86
86
|
fileContent = transformFileAfterExec(target, await f.default());
|
|
87
87
|
} finally {
|
package/dist/parse.js
CHANGED