Importing JSON file in Netlify function

Hello,

I’m trying to import a JSON file in my Netlify function.

import manifest from '../../dist/client/ssr-manifest.json' with { type: "json" }

If I run netlify dev it works fine; but netlify build returns an error :

Packaging Functions from functions directory:
 - render/index.mjs


Bundling of function "render" failed                          
────────────────────────────────────────────────────────────────

  Error message
  In file "/home/nicolas/code/vue2-vite-ssr/front/functions/render/index.mjs"
  This experimental syntax requires enabling the parser plugin: "importAttributes". (7:64)

  Error location
  While bundling function "render"

The differences between netlify dev and netlify build, and how functions are bundled are very opaque.
I can’t manage to sort it out.

I also tried importing it like this :

import manifest from '../../dist/client/ssr-manifest.json'

If I run netlify dev it builds
I get this error when calling the function:
Module "file:///code/vue2-vite-ssr/front/dist/client/ssr-manifest.json" needs an import attribute of type "json"

If I deploy, the build works; but then calling my function fails with this error :

Error [ERR_REQUIRE_ESM]: require() of ES Module /var/task/functions/render/index.mjs not supported.
Instead change the require of /var/task/functions/render/index.mjs to a dynamic import() which is available in all CommonJS modules.
    at Object.<anonymous> (/var/task/render.js:1:18)
    at _tryRequireFile (file:///var/runtime/index.mjs:1002:37)
    at _tryRequire (file:///var/runtime/index.mjs:1052:25)
    at _loadUserApp (file:///var/runtime/index.mjs:1081:22)
    at UserFunction.js.module.exports.load (file:///var/runtime/index.mjs:1119:27)
    at start (file:///var/runtime/index.mjs:1282:42)
    at file:///var/runtime/index.mjs:1288:7

Netlify internal ID: 01J88M8V716X8H29VRRTB72NKY

I think there is a confusion somewhere between ES module and CommonJS.

The project is still here :

and here :
https://lustrous-kringle-485ab9.netlify.app/lazy
You can find a failing build here :

Thank you for your help

I used

const manifest = JSON.parse(readFileSync('./dist/client/ssr-manifest.json', 'utf-8'))

instead of :

import manifest from '../../dist/client/ssr-manifest.json' with { type: "json" }