SoftwareBrothers / adminjs

AdminJS is an admin panel for apps written in node.js
https://adminjs.co
MIT License
8.19k stars 661 forks source link

Can't bundle a custom component #897

Closed kevinjbayer closed 2 years ago

kevinjbayer commented 3 years ago

Describe the bug Trying to create a custom component results in the following error: Error: You have declared using "bundled" babelHelpers, but transforming /Users/k/Documents/Projects/site/wd/.adminjs/.entry.js resulted in "runtime". Please check your configuration.

Installed libraries and their versions

To Reproduce Admittedly, this is a complex project. It's a Vue app with an Express backend to handle SAML authentication. I just wanted to try this out as a potential candidate for a CMS. It's working and connecting well, but creating a custom React component results in the above error. I'm sure it's possible this is some sort of conflict with the Vue app, but thought I would check here before moving on.

Expected behavior A custom component is created.

Screenshots .adminjs/.entry.js creates the following:

AdminJS.UserComponents = {}
import Component1 from '../admin/components/my-dashboard-component'
AdminJS.UserComponents.Component1 = Component1
import Component2 from '../admin/components/some-stats'
AdminJS.UserComponents.Component2 = Component2

AdminJSOptions with schema I don't think it's related but here's what I have:

const AdminJS = require('adminjs')
const AdminJSSequelizejs = require('@adminjs/sequelize')
const sequelize = require('sequelize')
const db = require('../models');
AdminJS.registerAdapter(AdminJSSequelizejs)

const SequelizeDb = require('../models')

const user = require('./resources/user')

// const DashboardPage = require('./dashboard-page')

module.exports = {
  resources: [
    { resource: SequelizeDb.sequelize.models.User, options: { } }
  ],
  dashboard: {
    component: AdminJS.bundle('./components/my-dashboard-component')
  },
  pages: {
    customPage: {
      label: "Custom page",
      handler: async (request, response, context) => {
        return {
          text: 'I am fetched from the backend',
        }
      },
      component: AdminJS.bundle('./components/some-stats'),
    },
  },
  rootPath: '/admin',
}

Additional context My babel.config.js is just the following. I'm guessing I need additional transforms possibly here?

module.exports = {
  presets: [
    '@vue/cli-plugin-babel/preset'
  ]
}

I tried adding "plugins": ["@babel/plugin-transform-runtime"] but still no dice.

dziraf commented 2 years ago

Closing because the issue is old. Please reopen if you still need help. Meanwhile:

Can you try with the latest version of adminjs? There have been some rollup/babel changes recently.