SoftwareBrothers / adminjs-design-system

DesignSystem on which AdminJS is based on
27 stars 33 forks source link

Release 4.0.4 broke admin.js #96

Open otsec opened 5 months ago

otsec commented 5 months ago

Hi there!

I just wanted to try admin.js for the first time and spent a couple of hours trying to understand why it wasn't working. I got an error:

(node:71680) ExperimentalWarning: Importing JSON modules is an experimental feature and might change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
node:internal/process/esm_loader:34
      internalBinding('errors').triggerUncaughtException(
                                ^

Error [ERR_UNSUPPORTED_DIR_IMPORT]: Directory import '/Users/otsec/Code/asynca/adminjs/node_modules/date-fns/parseISO' is not supported resolving ES modules imported from /Users/otsec/Code/asynca/adminjs/node_modules/@adminjs/design-system/build/molecules/date-picker/useDatePicker.js
Did you mean to import date-fns/parseISO/index.js?
    at finalizeResolution (node:internal/modules/esm/resolve:258:11)
    at moduleResolve (node:internal/modules/esm/resolve:917:10)
    at defaultResolve (node:internal/modules/esm/resolve:1130:11)
    at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:396:12)
    at ModuleLoader.resolve (node:internal/modules/esm/loader:365:25)
    at ModuleLoader.getModuleJob (node:internal/modules/esm/loader:240:38)
    at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:85:39)
    at link (node:internal/modules/esm/module_job:84:36) {
  code: 'ERR_UNSUPPORTED_DIR_IMPORT',
  url: 'file:///Users/otsec/Code/asynca/adminjs/node_modules/date-fns/parseISO'
}

Node.js v20.11.1

It works when I manually downgrade design system to 4.0.3.

How to reproduce

It tried it with AdonisJS, but you can reproduce it on fresh setup:

  1. Init npm in new dir npm init -y
  2. Add "type": "module" to package.json
  3. Install adminjs npm i adminjs.
  4. The following index.js that I copied from the docs.
import AdminJS from 'adminjs'

const adminJS = new AdminJS({
  // ...
})

adminJS.watch()
dziraf commented 5 months ago

@otsec 4.0.5 should fix the problem.

It is odd since the issue was related to incorrect import from date-fns but at the same time 4.0.4 didn't change anything related to it.