Skip to content

Commit 84734ac

Browse files
committed
Handle empty files corectly
1 parent 4fabb48 commit 84734ac

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/plugins/ftl/inject.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,10 @@ export function getInjectFtl(options: SFCPluginOptions): InjectFtlFn {
2323
const importString = options.parseFtl === true ? '' : '\nimport { FluentResource } from \'@fluent/bundle\'\n'
2424
const localeString = locale == null ? '' : locale
2525

26-
if (options.parseFtl === true) {
26+
if (source.length === 0) {
27+
magic.append('undefined')
28+
}
29+
else if (options.parseFtl === true) {
2730
const resource = new FluentResource(normalize(source))
2831
magic.overwrite(0, source.length, JSON.stringify(resource))
2932
}

0 commit comments

Comments
 (0)