#Transform failed only when using JavaScript API

1 messages · Page 1 of 1 (latest)

autumn urchin
#

When I use the JavaScript API to start vite server from a Node script, I got the following errors

[vite] Internal server error: Transform failed with 3 errors:
App.tsx:1:810: ERROR: The symbol "inWebWorker" has already been declared
App.tsx:1:906: ERROR: The symbol "prevRefreshReg" has already been declared
App.tsx:1:925: ERROR: The symbol "prevRefreshSig" has already been declared
  Plugin: vite:esbuild

Looks like something related to react-refresh?
The same errors did not occur when I started the server with the CLI

This is how I used the JavaScript API

import viteConfig from './vite.config.js';
createServer(viteConfig).then(viteServer => {
    viteServer.listen().then(() => {
        viteServer.printUrls();
        viteServer.bindCLIShortcuts({ print: true });
    });
});
autumn urchin
#

I changed the usage to

createServer({ configFile: 'vite.config.js' }).then(viteServer => {
    viteServer.listen().then(() => {
        viteServer.printUrls();
        viteServer.bindCLIShortcuts({ print: true });
    });
});

and it solved the issue.

I don't really know why... but I guess I got what I need for now