Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion packages/preprocess/src/svelte-ts-preprocess.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import fs from 'fs'
import path from 'path'
import ts from 'typescript'

const LANGS = ['ts', 'typescript']
Expand Down Expand Up @@ -93,7 +95,8 @@ interface Script {
filename: string
content: string
attributes: {
lang?: string
lang?: string,
src?: string
}
}

Expand Down Expand Up @@ -164,6 +167,12 @@ export function preprocess(opts?: Partial<PreprocessOptions>) {
return
}

if (attributes.src) {
const dir = path.parse(filename).dir
filename = path.join(dir, attributes.src)
content = fs.readFileSync(filename).toString()
}

filename = ts.sys.resolvePath(filename)
const options = createPreprocessOptions(opts)

Expand Down