Skip to content

Commit 6bd68a3

Browse files
committed
fix: find the translations for bundles
During `yarn start`: Without this change the translations are not correctly identified and too many bundles are created resulting in error messages: ``` Error: InvalidTemplates - Template(s) with syntax error(s) Validation error Zendesk.Theme/templates/assets.hbs Mapping has more items than allowed. ```
1 parent 34e4fc7 commit 6bd68a3

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

rollup.config.mjs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,21 @@ import terser from "@rollup/plugin-terser";
1010
import svgr from "@svgr/rollup";
1111
import { generateImportMap } from "./generate-import-map.mjs";
1212
import { defineConfig } from "rollup";
13+
import { sep as filePathSeparator } from "path";
1314

1415
const fileNames = "[name]-bundle.js";
1516
const isProduction = process.env.NODE_ENV === "production";
16-
const TRANSLATION_FILE_REGEX =
17-
/src\/modules\/(.+?)\/translations\/locales\/.+?\.json$/;
17+
const TRANSLATION_FILE_REGEX = ( // IIFE
18+
() => {
19+
// escape the file path separator if it's a backslash (Windows)
20+
const escapedSeparator = filePathSeparator.replace("\\", "\\\\");
21+
22+
return new RegExp(
23+
["src", "modules", "(.+?)", "translations", "locales", ".+?\.json$"].join(escapedSeparator)
24+
);
25+
}
26+
)();
27+
1828

1929
export default defineConfig([
2030
// Configuration for bundling the script.js file

0 commit comments

Comments
 (0)