Including Library in Office Addin for Production Build

Daniel G Brown 0 Reputation points
2024-11-29T16:21:59.51+00:00

I am writing an office addin for Excel. The code I have written has a dependency on the mathjs and accounting libraries. I am developing in Visual Studio Code.

To simplify I built the Excel addin with custom functions and a shared runtime in TypeScript. I edited the taskpane.ts file to include:

import

at the beginning and modified the run function to call this.

export

To get this code to work, I ran npm install mathjs in a terminal from Visual Studio Code. This works in development.

The problem I have is that "npm run build" fails with

> excel-custom-functions@

How to I properly include this library in the production build?

I checked that mathjs is included in the dependencies in the package.json. I tried using externals in the webpack.config.js file. This allowed npm run build to work, but the addin no longer loaded in development. I tested that npm run build:dev works

Excel
Excel
A family of Microsoft spreadsheet software with tools for analyzing, charting, and communicating data.
2,027 questions
Office Development
Office Development
Office: A suite of Microsoft productivity software that supports common business tasks, including word processing, email, presentations, and data management and analysis.Development: The process of researching, productizing, and refining new or existing technologies.
4,077 questions
0 comments No comments
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.