@@ -5,26 +5,26 @@ import { format as formatSQL } from "sql-formatter";
55import { Language } from "./codeEditorTypes" ;
66
77export async function cssFormatter ( text : string ) {
8- const prettier = await import ( "prettier/standalone" ) ;
8+ const prettier = await require ( "prettier/standalone" ) ;
99 const parserPlugin = await require ( "prettier/parser-postcss" ) ;
1010 return ( await prettier . format ( text , { parser : "css" , plugins : [ parserPlugin ] , semi : false } ) ) . trim ( ) ;
1111}
1212
1313export async function htmlFormatter ( text : string ) {
14- const prettier = await import ( "prettier/standalone" ) ;
14+ const prettier = await require ( "prettier/standalone" ) ;
1515 const parserPlugin = await require ( "prettier/parser-html" ) ;
1616 return ( await prettier . format ( text , { parser : "html" , plugins : [ parserPlugin ] , semi : false } ) ) . trim ( ) ;
1717}
1818
1919async function getJavascriptFormatter ( ) {
20- const prettier = await import ( "prettier/standalone" ) ;
20+ const prettier = await require ( "prettier/standalone" ) ;
2121 const parserBabel = await require ( "prettier/parser-babel" ) ;
2222 return async ( text : string ) =>
2323 ( await prettier . format ( text , { parser : "babel" , plugins : [ parserBabel ] , semi : false } ) ) . trim ( ) ;
2424}
2525
2626export async function getJsonFormatter ( ) {
27- const prettier = await import ( "prettier/standalone" ) ;
27+ const prettier = await require ( "prettier/standalone" ) ;
2828 const parserBabel = await require ( "prettier/parser-babel" ) ;
2929 return async ( text : string ) => ( await prettier . format ( text , { parser : "json" , plugins : [ parserBabel ] } ) ) . trim ( ) ;
3030}
@@ -130,7 +130,7 @@ async function formatJsonWithJsSnippetsImpl(text: string) {
130130 return segment ;
131131 } ) ) ;
132132
133- return ( await formattedJSON ) . replace ( / ( " { { \d + } } " ) | ( { { \d + } } ) | ( \\ \\ { \\ \\ { \d + \\ \\ } \\ \\ } ) / g, ( s ) => {
133+ return ( await formattedJSON ) . replace ( / ( " { { \d + } } " ) | ( { { \d + } } ) | ( \\ \\ { \\ \\ { \d + \\ \\ } \\ \\ } ) / g, ( s : string ) => {
134134 const index = parseInt (
135135 s . startsWith ( '"{{' ) ? s . slice ( 3 , - 3 ) : s . startsWith ( "{{" ) ? s . slice ( 2 , - 2 ) : s . slice ( 6 , - 6 )
136136 ) ;
0 commit comments