@batijs/build
Advanced tools
Comparing version 0.0.12 to 0.0.13
@@ -39,2 +39,4 @@ // src/exec.ts | ||
case ".js": | ||
case ".tsx": | ||
case ".jsx": | ||
return fileContent; | ||
@@ -47,2 +49,6 @@ case ".json": | ||
} | ||
async function fileContainsVikeMeta(filepath) { | ||
const code = await readFile(filepath, { encoding: "utf-8" }); | ||
return code.includes("import.meta.VIKE_"); | ||
} | ||
async function main(options, meta) { | ||
@@ -57,9 +63,2 @@ const sources = Array.isArray(options.source) ? options.source : [options.source]; | ||
continue; | ||
} else if (parsed.name.startsWith("$$") && parsed.ext.match(/\.[tj]sx?$/)) { | ||
const mod = await loadFile(p); | ||
const fileContent = await transformAndGenerate(mod.$ast, meta); | ||
if (fileContent) { | ||
await safeWriteFile(target, fileContent); | ||
} | ||
targets.set(target, () => fileContent); | ||
} else if (parsed.name.startsWith("$") && parsed.ext.match(/\.tsx?$/)) { | ||
@@ -74,2 +73,11 @@ throw new Error(`Typescript file needs to be compiled before it can be executed: '${p}'`); | ||
targets.set(target, () => fileContent); | ||
} else if (parsed.ext.match(/\.[tj]sx?$/) && await fileContainsVikeMeta(p)) { | ||
const mod = await loadFile(p); | ||
const fileContent = await transformAndGenerate(mod.$ast, meta, { | ||
filepath: p | ||
}); | ||
if (fileContent) { | ||
await safeWriteFile(target, fileContent); | ||
} | ||
targets.set(target, () => fileContent); | ||
} else { | ||
@@ -76,0 +84,0 @@ await safeCopyFile(p, target); |
@@ -39,2 +39,4 @@ // src/exec.ts | ||
case ".js": | ||
case ".tsx": | ||
case ".jsx": | ||
return fileContent; | ||
@@ -47,2 +49,6 @@ case ".json": | ||
} | ||
async function fileContainsVikeMeta(filepath) { | ||
const code = await readFile(filepath, { encoding: "utf-8" }); | ||
return code.includes("import.meta.VIKE_"); | ||
} | ||
async function main(options, meta) { | ||
@@ -57,9 +63,2 @@ const sources = Array.isArray(options.source) ? options.source : [options.source]; | ||
continue; | ||
} else if (parsed.name.startsWith("$$") && parsed.ext.match(/\.[tj]sx?$/)) { | ||
const mod = await loadFile(p); | ||
const fileContent = await transformAndGenerate(mod.$ast, meta); | ||
if (fileContent) { | ||
await safeWriteFile(target, fileContent); | ||
} | ||
targets.set(target, () => fileContent); | ||
} else if (parsed.name.startsWith("$") && parsed.ext.match(/\.tsx?$/)) { | ||
@@ -74,2 +73,11 @@ throw new Error(`Typescript file needs to be compiled before it can be executed: '${p}'`); | ||
targets.set(target, () => fileContent); | ||
} else if (parsed.ext.match(/\.[tj]sx?$/) && await fileContainsVikeMeta(p)) { | ||
const mod = await loadFile(p); | ||
const fileContent = await transformAndGenerate(mod.$ast, meta, { | ||
filepath: p | ||
}); | ||
if (fileContent) { | ||
await safeWriteFile(target, fileContent); | ||
} | ||
targets.set(target, () => fileContent); | ||
} else { | ||
@@ -76,0 +84,0 @@ await safeCopyFile(p, target); |
{ | ||
"name": "@batijs/build", | ||
"version": "0.0.12", | ||
"version": "0.0.13", | ||
"description": "", | ||
@@ -11,6 +11,6 @@ "type": "module", | ||
"@types/node": "^16.18.27", | ||
"@batijs/tsup": "0.0.12" | ||
"@batijs/tsup": "0.0.13" | ||
}, | ||
"dependencies": { | ||
"@batijs/core": "0.0.12" | ||
"@batijs/core": "0.0.13" | ||
}, | ||
@@ -17,0 +17,0 @@ "main": "./dist/exec.js", |
7040
182
+ Added@batijs/core@0.0.13(transitive)
- Removed@batijs/core@0.0.12(transitive)
Updated@batijs/core@0.0.13