Skip to content

Commit 14ec5da

Browse files
committed
Move check to plugin root
1 parent c912910 commit 14ec5da

File tree

2 files changed

+14
-18
lines changed

2 files changed

+14
-18
lines changed

src/helpers/getDtsSnapshot.ts

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,16 @@ export const getDtsSnapshot = (
1515
compilerOptions: tsModule.CompilerOptions,
1616
directory: string,
1717
): tsModule.IScriptSnapshot => {
18-
try {
19-
const css = readFileSync(fileName, 'utf-8');
20-
const cssExports = getCssExports({
21-
css,
22-
fileName,
23-
logger,
24-
options,
25-
processor,
26-
compilerOptions,
27-
directory,
28-
});
29-
const dts = createDtsExports({ cssExports, fileName, logger, options });
30-
return ts.ScriptSnapshot.fromString(dts);
31-
}
32-
catch (e) {
33-
logger.error(e);
34-
}
18+
const css = readFileSync(fileName, 'utf-8');
19+
const cssExports = getCssExports({
20+
css,
21+
fileName,
22+
logger,
23+
options,
24+
processor,
25+
compilerOptions,
26+
directory,
27+
});
28+
const dts = createDtsExports({ cssExports, fileName, logger, options });
29+
return ts.ScriptSnapshot.fromString(dts);
3530
};

src/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,8 @@ const init: tsModule.server.PluginModuleFactory = ({ typescript: ts }) => {
126126
};
127127

128128
languageServiceHost.getScriptSnapshot = (fileName) => {
129-
if (isCSS(fileName)) {
129+
const fileExists = fs.existsSync(fileName);
130+
if (fileExists && isCSS(fileName)) {
130131
return getDtsSnapshot(
131132
ts,
132133
processor,

0 commit comments

Comments
 (0)