@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.
@@ -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/eval.ts
1
+ // src/transpile-ts.ts
2
2
  import ts from "typescript";
3
- function evalCondition(obj, meta = {}) {
4
- obj = obj.replaceAll("import.meta", "VIKE_META");
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
- evalCondition
22
+ transpileTs
26
23
  };
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  evalCondition
3
- } from "./chunk-U7QQNTGA.js";
3
+ } from "./chunk-IYRELEBO.js";
4
4
  import {
5
5
  lazyfy
6
6
  } from "./chunk-5XFUXMWM.js";
package/dist/eval.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- declare function evalCondition(obj: string, meta?: VikeMeta): any;
1
+ declare function evalCondition(code: string, meta?: VikeMeta): any;
2
2
 
3
3
  export { evalCondition };
package/dist/eval.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import {
2
2
  evalCondition
3
- } from "./chunk-U7QQNTGA.js";
3
+ } from "./chunk-IYRELEBO.js";
4
+ import "./chunk-MGVFRR6M.js";
4
5
  export {
5
6
  evalCondition
6
7
  };
package/dist/exec.js CHANGED
@@ -1,8 +1,11 @@
1
1
  import {
2
2
  ast,
3
3
  transform
4
- } from "./chunk-3EUYSS5H.js";
5
- import "./chunk-U7QQNTGA.js";
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
@@ -3,8 +3,9 @@ import {
3
3
  metaAst,
4
4
  transform,
5
5
  transformAst
6
- } from "./chunk-3EUYSS5H.js";
7
- import "./chunk-U7QQNTGA.js";
6
+ } from "./chunk-N3I7EPEL.js";
7
+ import "./chunk-IYRELEBO.js";
8
+ import "./chunk-MGVFRR6M.js";
8
9
  import "./chunk-5XFUXMWM.js";
9
10
  export {
10
11
  ast,
@@ -0,0 +1,3 @@
1
+ declare function transpileTs(code: string): string;
2
+
3
+ export { transpileTs };
@@ -0,0 +1,6 @@
1
+ import {
2
+ transpileTs
3
+ } from "./chunk-MGVFRR6M.js";
4
+ export {
5
+ transpileTs
6
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@batijs/build",
3
- "version": "0.0.1",
3
+ "version": "0.0.2",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "keywords": [],