@batijs/build 0.0.16 → 0.0.17
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/exec.js +14 -8
- package/package.json +3 -3
package/dist/exec.js
CHANGED
|
@@ -47,13 +47,13 @@ function transformFileAfterExec(filepath, fileContent) {
|
|
|
47
47
|
throw new Error(`Unsupported extension ${ext} (${filepath})`);
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
|
-
async function
|
|
50
|
+
async function fileContainsBatiMeta(filepath) {
|
|
51
51
|
const code = await readFile(filepath, { encoding: "utf-8" });
|
|
52
52
|
return code.includes("import.meta.BATI_");
|
|
53
53
|
}
|
|
54
54
|
async function main(options, meta) {
|
|
55
55
|
const sources = Array.isArray(options.source) ? options.source : [options.source];
|
|
56
|
-
const targets = /* @__PURE__ */ new
|
|
56
|
+
const targets = /* @__PURE__ */ new Set();
|
|
57
57
|
for (const source of sources) {
|
|
58
58
|
for await (const p of walk(source, meta)) {
|
|
59
59
|
const target = toDist(p, source, options.dist);
|
|
@@ -61,15 +61,21 @@ async function main(options, meta) {
|
|
|
61
61
|
if (parsed.name.match(reIgnoreFile)) {
|
|
62
62
|
continue;
|
|
63
63
|
} else if (parsed.name.startsWith("$") && parsed.ext.match(/\.tsx?$/)) {
|
|
64
|
-
throw new Error(
|
|
64
|
+
throw new Error(
|
|
65
|
+
`Typescript file needs to be compiled before it can be executed: '${p}'.
|
|
66
|
+
Please report this issue to https://github.com/magne4000/bati`
|
|
67
|
+
);
|
|
65
68
|
} else if (parsed.name.startsWith("$") && parsed.ext.match(/\.jsx?$/)) {
|
|
66
69
|
const f = await import(p);
|
|
67
|
-
const fileContent = transformFileAfterExec(
|
|
70
|
+
const fileContent = transformFileAfterExec(
|
|
71
|
+
target,
|
|
72
|
+
await f.default(targets.has(target) ? () => readFile(target, { encoding: "utf-8" }) : void 0, meta)
|
|
73
|
+
);
|
|
68
74
|
if (fileContent !== null) {
|
|
69
75
|
await safeWriteFile(target, fileContent);
|
|
70
76
|
}
|
|
71
|
-
targets.
|
|
72
|
-
} else if (parsed.ext.match(/\.[tj]sx?$/) && await
|
|
77
|
+
targets.add(target);
|
|
78
|
+
} else if (parsed.ext.match(/\.[tj]sx?$/) && await fileContainsBatiMeta(p)) {
|
|
73
79
|
const mod = await loadFile(p);
|
|
74
80
|
const fileContent = await transformAndGenerate(mod.$ast, meta, {
|
|
75
81
|
filepath: p
|
|
@@ -77,10 +83,10 @@ async function main(options, meta) {
|
|
|
77
83
|
if (fileContent) {
|
|
78
84
|
await safeWriteFile(target, fileContent);
|
|
79
85
|
}
|
|
80
|
-
targets.
|
|
86
|
+
targets.add(target);
|
|
81
87
|
} else {
|
|
82
88
|
await safeCopyFile(p, target);
|
|
83
|
-
targets.
|
|
89
|
+
targets.add(target);
|
|
84
90
|
}
|
|
85
91
|
}
|
|
86
92
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@batijs/build",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.17",
|
|
4
4
|
"description": "",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"keywords": [],
|
|
@@ -8,10 +8,10 @@
|
|
|
8
8
|
"license": "MIT",
|
|
9
9
|
"devDependencies": {
|
|
10
10
|
"@types/node": "^16.18.27",
|
|
11
|
-
"@batijs/tsup": "0.0.
|
|
11
|
+
"@batijs/tsup": "0.0.17"
|
|
12
12
|
},
|
|
13
13
|
"dependencies": {
|
|
14
|
-
"@batijs/core": "0.0.
|
|
14
|
+
"@batijs/core": "0.0.17"
|
|
15
15
|
},
|
|
16
16
|
"main": "./dist/exec.js",
|
|
17
17
|
"module": "./dist/exec.js",
|