-
Notifications
You must be signed in to change notification settings - Fork 64
Description
Hi there,
Newbie here in Office add-ins and JavaScript, so please be patient!
I created a Javascript Excel custom functions add-in, by using the Yeoman generator. In one of my custom function I want to use a JS function defined in an external file. So I defined a function named testExternal and placed it in taskpane.js file:
export function testExternal() {
return 1;
}
then in the functions.js file I have:
import { testExternal } from "../taskpane/taskpane.js";
and in my custom function:
console.log(testExternal());
When debugging, I'm getting the desired 1 in console, but also get the "Cannot use import statement outside a module" error message:

This happens not only in debug mode, but also when the add-in is published on a web server and the add-in is sideloaded. So the external defined function is working correctly, but:
- is there any way to get rid of that error message?
- what are the steps to use a function defined in another JS file (not in taskpane.js)? Let's say I want to have all my utils functions in a file named utils.js and use that in my custom functions. What is the best location for utils.js and how can be automatically added to the dist folder, when the project is build in VS Code?
Thank you for your time,
Adrian