Bug
pbiviz start / pbiviz package (without --all-locales) fails to compile any visual that depends on powerbi-visuals-utils-formattingutils >= 7.x:
ERROR in ./node_modules/powerbi-visuals-utils-formattingutils/lib/globalize/powerbiGlobalizeLocales.js
Module build failed (from .../powerbi-visuals-webpack-plugin/src/localizationLoader.js):
SyntaxError: Unexpected token 'export'
at Object.localizationLoader (.../src/localizationLoader.js:12:37)
Root cause
src/localizationLoader.js filters locales by running eval() on the source of powerbiGlobalizeLocales.js:
const result = Object.entries(eval(source)).filter(...)
In current powerbi-visuals-utils-formattingutils (7.0.0, pulled in by powerbi-visuals-utils-chartutils@9), that file is an ES module:
export const locales = {
"ar": ["ar", "default", { ...
eval() cannot parse ESM syntax, so it throws SyntaxError: Unexpected token 'export'. The variableDeclaration slicing on the lines above (source.indexOf("locales = {")) also assumes the old non-ESM shape of the file.
The loader is only attached when --all-locales is not passed (WebPackWrap.js → configureLoaders, if (!includeAllLocales)), which is why the flag hides the bug.
Repro
- powerbi-visuals-tools 7.2.1 (powerbi-visuals-webpack-plugin 5.0.3), Node 22.15.0, macOS
- Visual with
powerbi-visuals-utils-chartutils@^9.0.0 (→ formattingutils 7.0.0) imported from src
pbiviz start → webpack 5.110.2 compiled with 1 error (the SyntaxError above)
pbiviz start --all-locales → compiled successfully (loader skipped)
Workaround
Always pass --all-locales, at the cost of bundling every locale.
Suggested fix
Parse the file instead of eval'ing it — e.g. strip the export const prefix before evaluating (eval(source.replace(/^export\s+/, "") + ";locales")), or import the module properly. Locale filtering currently cannot work at all against ESM formattingutils.
Bug
pbiviz start/pbiviz package(without--all-locales) fails to compile any visual that depends onpowerbi-visuals-utils-formattingutils>= 7.x:Root cause
src/localizationLoader.jsfilters locales by runningeval()on the source ofpowerbiGlobalizeLocales.js:In current
powerbi-visuals-utils-formattingutils(7.0.0, pulled in bypowerbi-visuals-utils-chartutils@9), that file is an ES module:eval()cannot parse ESM syntax, so it throwsSyntaxError: Unexpected token 'export'. ThevariableDeclarationslicing on the lines above (source.indexOf("locales = {")) also assumes the old non-ESM shape of the file.The loader is only attached when
--all-localesis not passed (WebPackWrap.js→configureLoaders,if (!includeAllLocales)), which is why the flag hides the bug.Repro
powerbi-visuals-utils-chartutils@^9.0.0(→ formattingutils 7.0.0) imported fromsrcpbiviz start→webpack 5.110.2 compiled with 1 error(the SyntaxError above)pbiviz start --all-locales→compiled successfully(loader skipped)Workaround
Always pass
--all-locales, at the cost of bundling every locale.Suggested fix
Parse the file instead of eval'ing it — e.g. strip the
export constprefix before evaluating (eval(source.replace(/^export\s+/, "") + ";locales")), or import the module properly. Locale filtering currently cannot work at all against ESM formattingutils.