DEV Community

Brian Jørgensen
Brian Jørgensen

Posted on

Vite build issue

Hi all,

I am facing an issue with VITE my react project. After upgrading NPM packages, settings and more, I am now facing an issue with certain packages not being included in the build running "vite build".

I have a function in a component, that is not being triggered before a user enters text in a textbox. in that function I use the sprintf NPM package.

so if I build my solution and push it to Azure it fails with

TypeError: sprintfExports.sprintf is not a function

I include the package like this

import * as sprintfModule from 'sprintf-js';

cand call it like

${sprintfModule.sprintf(t(passwordValidationRule2), ...rule.format)}

I later found out that if I add the following line of code in my component, then the package is added to the build

console.log("sprintfModule", sprintfModule);

can someone tell me how to fix this issue, I am pulling my hair out here :-)

Thanks in advance

Top comments (0)