Uncaught TypeError: Object$1 is undefined

I tried to deploy using baremetal and I endup with a blank page and this: Uncaught TypeError: Object$1 is undefined in the console

I am able to reproduce this locally using yarn rw build && yarn rw serve

Compiled code looks like this:

var path$2 = path$4;
var Object$1 = path$2.Object;
var defineProperty$5 = defineProperty$7.exports = function defineProperty3(it, key, desc) {
  return Object$1.defineProperty(it, key, desc);
};
if (Object$1.defineProperty.sham) defineProperty$5.sham = true;

Where the last line is where it fails

I tried to look what’s inside of path$4:

JSON.stringify(path$4)
"{}" 

So the Object called on it is producing a undefined on Object$1, but overall I don’t really know how to debug this issue

Does anyone have a clue ?

I already checked:

  • dependencies in web & api are correct (I don’t use deps in api from web and vice versa)
  • I don’t use code from web in api and vice-versa

I have the issue on RW 8.2.0 and 8.4.0, haven’t tried earlier version, I started the project in 8.2.0

I wonder if it’s not a “Vite” problem

But I checked my tsconfig.json agains’t a new project, and it’s the same…

{
  "compilerOptions": {
    "noEmit": true,
    "allowJs": true,
    "esModuleInterop": true,
    "target": "ES2022",
    "module": "ESNext",
    "moduleResolution": "Bundler",
    "skipLibCheck": false,
    "rootDirs": [
      "./src",
      "../.redwood/types/mirror/web/src",
      "../api/src",
      "../.redwood/types/mirror/api/src"
    ],
    "paths": {
      "src/*": [
        "./src/*",
        "../.redwood/types/mirror/web/src/*",
        "../api/src/*",
        "../.redwood/types/mirror/api/src/*"
      ],
      "$api/*": ["../api/*"],
      "types/*": ["./types/*", "../types/*"],
      "@redwoodjs/testing": ["../node_modules/@redwoodjs/testing/web"]
    },
    "typeRoots": [
      "../node_modules/@types",
      "./node_modules/@types",
      "../node_modules/@testing-library"
    ],
    "types": ["jest", "jest-dom"],
    "jsx": "preserve"
  },
  "include": [
    "src",
    "config",
    "../.redwood/types/includes/all-*",
    "../.redwood/types/includes/web-*",
    "../types",
    "./types"
  ]
}

I tried to clean as well, but didn’t work

Seems to be related

node_modules/core-js-pure/es/object/define-property.js

Found the code responsible, but I think it is something wrong in the config of babel at Redwood level then ?

'use strict';
require('../../modules/es.object.define-property');
var path = require('../../internals/path');

var Object = path.Object;

var defineProperty = module.exports = function defineProperty(it, key, desc) {
  return Object.defineProperty(it, key, desc);
};

if (Object.defineProperty.sham) defineProperty.sham = true;

Anyway, I have created a new project moved the files from the old one to the new one, same dependencies, same code, and it just builds and runs fine now. Something might be broken in the node_module Daedalus, but I’ll not be the one to investigate.