diff --git a/packages/string-templates/src/processors/index.js b/packages/string-templates/src/processors/index.js index aae18aed8b..a5bcf84eaf 100644 --- a/packages/string-templates/src/processors/index.js +++ b/packages/string-templates/src/processors/index.js @@ -1,6 +1,6 @@ -const { FIND_HBS_REGEX } = require("../utilities") -const preprocessor = require("./preprocessor") -const postprocessor = require("./postprocessor") +import { FIND_HBS_REGEX } from "../utilities" +import * as preprocessor from "./preprocessor" +import * as postprocessor from "./postprocessor" function process(output, processors, opts) { for (let processor of processors) { @@ -21,7 +21,7 @@ function process(output, processors, opts) { return output } -module.exports.preprocess = (string, opts) => { +export function preprocess(string, opts) { let processors = preprocessor.processors if (opts.noFinalise) { processors = processors.filter( @@ -30,7 +30,7 @@ module.exports.preprocess = (string, opts) => { } return process(string, processors, opts) } -module.exports.postprocess = string => { +export function postprocess(string) { let processors = postprocessor.processors return process(string, processors) } diff --git a/packages/string-templates/src/processors/postprocessor.js b/packages/string-templates/src/processors/postprocessor.js index f78a572d07..3122d43e53 100644 --- a/packages/string-templates/src/processors/postprocessor.js +++ b/packages/string-templates/src/processors/postprocessor.js @@ -1,6 +1,6 @@ -const { LITERAL_MARKER } = require("../helpers/constants") +import { LITERAL_MARKER } from "../helpers/constants" -const PostProcessorNames = { +export const PostProcessorNames = { CONVERT_LITERALS: "convert-literals", } @@ -16,9 +16,7 @@ class Postprocessor { } } -module.exports.PostProcessorNames = PostProcessorNames - -module.exports.processors = [ +export const processors = [ new Postprocessor(PostProcessorNames.CONVERT_LITERALS, statement => { if (typeof statement !== "string" || !statement.includes(LITERAL_MARKER)) { return statement diff --git a/packages/string-templates/src/processors/preprocessor.js b/packages/string-templates/src/processors/preprocessor.js index 185a3ab38a..a7210fe520 100644 --- a/packages/string-templates/src/processors/preprocessor.js +++ b/packages/string-templates/src/processors/preprocessor.js @@ -1,9 +1,9 @@ -const { HelperNames } = require("../helpers") -const { swapStrings, isAlphaNumeric } = require("../utilities") +import { HelperNames } from "../helpers" +import { swapStrings, isAlphaNumeric } from "../utilities" const FUNCTION_CASES = ["#", "else", "/"] -const PreprocessorNames = { +export const PreprocessorNames = { SWAP_TO_DOT: "swap-to-dot-notation", FIX_FUNCTIONS: "fix-functions", FINALISE: "finalise", @@ -23,7 +23,7 @@ class Preprocessor { } } -module.exports.processors = [ +export const processors = [ new Preprocessor(PreprocessorNames.SWAP_TO_DOT, statement => { let startBraceIdx = statement.indexOf("[") let lastIdx = 0 @@ -74,5 +74,3 @@ module.exports.processors = [ return `{{ all ${insideStatement} }}` }), ] - -module.exports.PreprocessorNames = PreprocessorNames