Skip to content
This repository has been archived by the owner on Aug 31, 2023. It is now read-only.

Commit

Permalink
fix(playground): Script Type (#3903)
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaReiser committed Nov 30, 2022
1 parent d52da50 commit ba0b713
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions website/src/playground/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -275,15 +275,29 @@ export function classnames(...names: (undefined | boolean | string)[]): string {
}

export function isTypeScriptFilename(filename: string): boolean {
return filename.endsWith(".ts") || filename.endsWith(".tsx");
return (
filename.endsWith(".ts") ||
filename.endsWith(".tsx") ||
filename.endsWith(".mts") ||
filename.endsWith(".cts")
);
}

export function isJSXFilename(filename: string): boolean {
return filename.endsWith(".tsx") || filename.endsWith(".jsx");
}

export function isScriptFilename(filename: string): boolean {
return filename.endsWith(".js");
return filename.endsWith(".cjs") || filename.endsWith(".cts");
}

export function isModuleFilename(filename: string): boolean {
return (
filename.endsWith(".mjs") ||
filename.endsWith(".mts") ||
filename.endsWith(".js") ||
filename.endsWith(".ts")
);
}

export function modifyFilename(
Expand All @@ -307,9 +321,9 @@ export function getExtension(opts: ExtensionOptions): string {
let ext = "";

if (opts.script) {
ext = "js";
ext = "cjs";
} else {
ext = "mjs";
ext = "js";
}

if (opts.typescript) {
Expand All @@ -328,6 +342,7 @@ export function getExtension(opts: ExtensionOptions): string {
export function isValidExtension(filename: string): boolean {
return (
isScriptFilename(filename) ||
isModuleFilename(filename) ||
isTypeScriptFilename(filename) ||
isJSXFilename(filename)
);
Expand Down

0 comments on commit ba0b713

Please sign in to comment.