Fix sveld plugin
This commit is contained in:
@@ -11,6 +11,28 @@ export default function sveld() {
|
||||
// TODO: Make more efficient & handle typescript types with `svelte2tsx`
|
||||
async transform(src, id) {
|
||||
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 componentFiles = await fs.readdir(path.resolve('./src/components'))
|
||||
@@ -28,19 +50,4 @@ export default function sveld() {
|
||||
}
|
||||
|
||||
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