@@ -5,26 +5,26 @@ import { format as formatSQL } from "sql-formatter";
5
5
import { Language } from "./codeEditorTypes" ;
6
6
7
7
export async function cssFormatter ( text : string ) {
8
- const prettier = await import ( "prettier/standalone" ) ;
8
+ const prettier = await require ( "prettier/standalone" ) ;
9
9
const parserPlugin = await require ( "prettier/parser-postcss" ) ;
10
10
return ( await prettier . format ( text , { parser : "css" , plugins : [ parserPlugin ] , semi : false } ) ) . trim ( ) ;
11
11
}
12
12
13
13
export async function htmlFormatter ( text : string ) {
14
- const prettier = await import ( "prettier/standalone" ) ;
14
+ const prettier = await require ( "prettier/standalone" ) ;
15
15
const parserPlugin = await require ( "prettier/parser-html" ) ;
16
16
return ( await prettier . format ( text , { parser : "html" , plugins : [ parserPlugin ] , semi : false } ) ) . trim ( ) ;
17
17
}
18
18
19
19
async function getJavascriptFormatter ( ) {
20
- const prettier = await import ( "prettier/standalone" ) ;
20
+ const prettier = await require ( "prettier/standalone" ) ;
21
21
const parserBabel = await require ( "prettier/parser-babel" ) ;
22
22
return async ( text : string ) =>
23
23
( await prettier . format ( text , { parser : "babel" , plugins : [ parserBabel ] , semi : false } ) ) . trim ( ) ;
24
24
}
25
25
26
26
export async function getJsonFormatter ( ) {
27
- const prettier = await import ( "prettier/standalone" ) ;
27
+ const prettier = await require ( "prettier/standalone" ) ;
28
28
const parserBabel = await require ( "prettier/parser-babel" ) ;
29
29
return async ( text : string ) => ( await prettier . format ( text , { parser : "json" , plugins : [ parserBabel ] } ) ) . trim ( ) ;
30
30
}
@@ -130,7 +130,7 @@ async function formatJsonWithJsSnippetsImpl(text: string) {
130
130
return segment ;
131
131
} ) ) ;
132
132
133
- return ( await formattedJSON ) . replace ( / ( " { { \d + } } " ) | ( { { \d + } } ) | ( \\ \\ { \\ \\ { \d + \\ \\ } \\ \\ } ) / g, ( s ) => {
133
+ return ( await formattedJSON ) . replace ( / ( " { { \d + } } " ) | ( { { \d + } } ) | ( \\ \\ { \\ \\ { \d + \\ \\ } \\ \\ } ) / g, ( s : string ) => {
134
134
const index = parseInt (
135
135
s . startsWith ( '"{{' ) ? s . slice ( 3 , - 3 ) : s . startsWith ( "{{" ) ? s . slice ( 2 , - 2 ) : s . slice ( 6 , - 6 )
136
136
) ;
0 commit comments