Functions crashing on live site

Hello, i’m having issues with my site after deploying on Netlify. My site is built with Tanstack Start using React and typescript.

https://space-and-wonders.netlify.app (site currently working, have disabled the React library causing problems until I can resolve the issue.)

After deploying my site, I am getting the following error.

An unhandled error in the function code triggered the following message:

SyntaxError - Cannot use import statement outside a module

Stack trace
/var/task/node_modules/react-datepicker/dist/index.es.js:6
import { clsx } from 'clsx';
^^^^^^

SyntaxError: Cannot use import statement outside a module
    at wrapSafe (node:internal/modules/cjs/loader:1713:18)
    at Module._compile (node:internal/modules/cjs/loader:1755:20)
    at Object..js (node:internal/modules/cjs/loader:1913:10)
    at Module.load (node:internal/modules/cjs/loader:1505:32)
    at Function._load (node:internal/modules/cjs/loader:1309:12)
    at wrapModuleLoad (node:internal/modules/cjs/loader:254:19)
    at loadCJSModuleWithModuleLoad (node:internal/modules/esm/translators:335:3)
    at ModuleWrap.<anonymous> (node:internal/modules/esm/translators:235:7)
    at ModuleJob.run (node:internal/modules/esm/module_job:343:25)
    at async onImport.tracePromise.__proto__ (node:internal/modules/esm/loader:681:26)

I have tried to google this error and used the ask Netlify feature which both tell me to add this to my netlify.toml

[functions]
node_bundler = "esbuild"

And this to my package.json

"type": "module",

Which I had already done but I still get the error. The error seems to be coming from a React library i’m using called React Datepicker

I have also had the same issue with another React library I was using called React Mega Scroll

The problems both seem to be with the imports used by the above, the site works fine on localhost during development and only has problems once deploying it to Netlify, so the problem must be on Netlify’s side.

Not sure how to resolve the issue as any search results just provide fixes i’ve already tried.

As i’m using Tanstack Start and they are partnered with Netlify I used the guide on manual deployment on the Netlify website

Is there anyone from Netlify or anyone else that can help me resolve these issues please?

Problem resolved using a Material UI date picker component. If anyone has a fix for the original issue please let me know.