Skip to content

Commit c6aa446

Browse files
committed
refactor: improve code clarity by adding JS comment syntax in loaders and removing default file name constant
1 parent 1f8b2aa commit c6aa446

2 files changed

Lines changed: 3 additions & 4 deletions

File tree

src/loader.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export type Loader = (sourceUrl: string, sourceCode: string) => Awaitable<string
1010

1111
export const cssLoader: Loader = (sourceUrl, _sourceCode) => {
1212
// Note: _sourceCode is empty string
13-
const code = `\
13+
const code = /*js*/ `\
1414
const link = document.createElement("link");
1515
link.rel = "stylesheet";
1616
link.href = ${JSON.stringify(sourceUrl)};
@@ -28,7 +28,7 @@ export const cssModuleLoader: Loader = (sourceUrl, sourceCode) => {
2828

2929
const { map, css } = cssToModule(sourceCode, prefix);
3030

31-
const code = `\
31+
const code = /*js*/ `\
3232
const style = document.createElement("style");
3333
style.textContent = ${JSON.stringify(css)};
3434
document.head.appendChild(style);

src/ts.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
import ts from "typescript";
22
import { ModuleTSXError } from "./error.ts";
33

4-
const FILE_NAME = "temp.tsx";
54

6-
export function createSourceFile(code: string, fileName = FILE_NAME) {
5+
export function createSourceFile(code: string, fileName :string) {
76
try {
87
const sourceFile = ts.createSourceFile(fileName, code, ts.ScriptTarget.Latest, true, ts.ScriptKind.TSX);
98
return sourceFile;

0 commit comments

Comments
 (0)