After updating my PowerBI custom visual with "powerbi-visuals-utils-tooltiputils": "^2.3.1" (following instructions on https://github.com/microsoft/powerbi-visuals-utils-tooltiputils/blob/master/docs/usage/installation-guide.md and https://github.com/microsoft/powerbi-visuals-utils-tooltiputils/blob/master/docs/usage/usage-guide.md), the custom visual won't display any more in the online PowerBI service. The error description that I get in the web developer console in Chrome is the one in the title of this issue.
Here is my package.json file:
{
"name": "visual",
"scripts": {
"pbiviz": "pbiviz",
"start": "pbiviz start",
"package": "pbiviz package",
"lint": "tslint -r \"node_modules/tslint-microsoft-contrib\" \"+(src|test)/**/*.ts\""
},
"dependencies": {
"@babel/runtime": "^7.4.5",
"@babel/runtime-corejs2": "^7.4.5",
"@types/d3": "5.7.2",
"core-js": "3.1.3",
"d3": "5.9.7",
"powerbi-visuals-api": "^2.6.1",
"powerbi-visuals-utils-dataviewutils": "^2.2.0",
"powerbi-visuals-utils-tooltiputils": "^2.3.1"
},
"devDependencies": {
"ts-loader": "6.0.4",
"typescript": "3.5.3"
}
}
Here is the error stack message taken from the browser's console:
VM89901:14 Uncaught SyntaxError: Cannot use import statement outside a module
at Object.i [as injectJsCode] (customVisualsHost.bundle.min.js:formatted:14324)
at r (customVisualsHost.bundle.min.js:formatted:18561)
at i.loadWithoutResourcePackage (customVisualsHost.bundle.min.js:formatted:18850)
at i.executeMessage (customVisualsHost.bundle.min.js:formatted:18939)
at i.onMessageReceived (customVisualsHost.bundle.min.js:formatted:18932)
at customVisualsHost.bundle.min.js:formatted:18695
at e.invokeHandler (customVisualsHost.bundle.min.js:formatted:15412)
at e.dispatchMessage (customVisualsHost.bundle.min.js:formatted:15400)
at e.onMessageReceived (customVisualsHost.bundle.min.js:formatted:15381)
at windowMessageHandler (customVisualsHost.bundle.min.js:formatted:15265)
I am suspecting the error has something to do with compilation of my JS with Babel, because when I am coding and running pbiviz start I get no errors whatsoever. I don't think this is a TypeScript error and the module mentioned does not seem to be a TypeScript module, but rather an ES6 module.
I'd love if someone could help me get to the bottom of this. What am I missing here?
If I remove the "powerbi-visuals-utils-tooltiputils" package reference from my project (from package.json) and reinstall all the npm packages, the error disappears. Therefore I conclude there is a JS compatibility issue that I cannot spot in powerbi-visuals-utils-tooltiputils package.
Am I perhaps missing a package in my project that I need to install or update? I am trying to search for TupeScript modules that might be the source of the issue but I am not able to find any. Meaning that there must be an issue with how some code in powerbi-visuals-utils-tooltiputils package is compiling to ES6.
Thank you in advance for any help.