You've already forked AstralRinth
forked from didirus/AstralRinth
Fix sveld plugin
This commit is contained in:
+22
-15
@@ -11,6 +11,28 @@ export default function sveld() {
|
|||||||
// TODO: Make more efficient & handle typescript types with `svelte2tsx`
|
// TODO: Make more efficient & handle typescript types with `svelte2tsx`
|
||||||
async transform(src, id) {
|
async transform(src, id) {
|
||||||
if (id.includes('/src/components/')) {
|
if (id.includes('/src/components/')) {
|
||||||
|
await generateComponentApi()
|
||||||
|
}
|
||||||
|
},
|
||||||
|
async buildStart() {
|
||||||
|
await generateComponentApi()
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function parseRaw(raw, filePath) {
|
||||||
|
let { code } = await svelte.preprocess(raw, preprocess, {
|
||||||
|
filename: filePath,
|
||||||
|
})
|
||||||
|
return new ComponentParser({
|
||||||
|
verbose: false,
|
||||||
|
}).parseSvelteComponent(code, {
|
||||||
|
filePath,
|
||||||
|
moduleName: filePath,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
async function generateComponentApi() {
|
||||||
const output = {}
|
const output = {}
|
||||||
|
|
||||||
const componentFiles = await fs.readdir(path.resolve('./src/components'))
|
const componentFiles = await fs.readdir(path.resolve('./src/components'))
|
||||||
@@ -29,18 +51,3 @@ export default function sveld() {
|
|||||||
|
|
||||||
await fs.writeFile(path.resolve('./generated/COMPONENT_API.json'), JSON.stringify(output))
|
await fs.writeFile(path.resolve('./generated/COMPONENT_API.json'), JSON.stringify(output))
|
||||||
}
|
}
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async function parseRaw(raw, filePath) {
|
|
||||||
let { code } = await svelte.preprocess(raw, preprocess, {
|
|
||||||
filename: filePath,
|
|
||||||
})
|
|
||||||
return new ComponentParser({
|
|
||||||
verbose: false,
|
|
||||||
}).parseSvelteComponent(code, {
|
|
||||||
filePath,
|
|
||||||
moduleName: filePath,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user