medusajs / medusa

The world's most flexible commerce platform.
https://medusajs.com
MIT License
26k stars 2.61k forks source link

[BUG] Admin UI componentes are not exposed to developers #9359

Open SalahAdDin opened 1 month ago

SalahAdDin commented 1 month ago

Bug report

Describe the bug

We are working on updating a plugin that contain Settings screens and we want them to match the existing screens. For that, based on the Team screen, we are calling two different components: BackButton and BodyCard but we are unable to make it work, since those components are not available.

System information

Medusa version (including plugins):

"@medusajs/admin": "^7.1.16",
    "@medusajs/cache-inmemory": "1.8.11",
    "@medusajs/cache-redis": "^1.9.2",
    "@medusajs/event-bus-local": "1.9.9",
    "@medusajs/event-bus-redis": "^1.8.14",
    "@medusajs/file-local": "1.0.4",
    "@medusajs/medusa": "^1.20.10",
    "@rsc-labs/medusa-documents": "^0.8.4",
    "@tanstack/react-query": "4.22.0",
    "body-parser": "^1.19.0",
    "cors": "^2.8.5",
    "dotenv": "16.3.1",
    "express": "^4.17.2",
    "medusa-fulfillment-manual": "1.1.41",
    "medusa-interfaces": "1.3.10",
    "medusa-payment-manual": "1.0.25",
    "medusa-payment-stripe": "6.0.11",
    "medusa-plugin-typesense": "^0.0.1",
    "prism-react-renderer": "^2.0.4",
    "typeorm": "0.3.16"

Node.js version: v20.15.1 Database: Postgre SQL 13 Operating system: Manjaro Linux Browser (if relevant): Firefox

Steps to reproduce the behavior

  1. Install @medusajs/admin-ui
  2. Prepare the plugin: rm -rf node_modules && yarn install && yarn prepare && rm -rf node_modules/@medusajs
  3. Run the server: yarn dev -- -- --preserve-symlinks
  4. See error

Expected behavior

It should not give any error.

Screenshots

In the plugin:

'src/assets' -> 'dist/assets'
Could not resolve import "@medusajs/admin-ui/ui/src/components/organisms/body-card" in /media/Storage/Projects/Experiments/e-commerce/medusa-plugin-user-roles/src/admin/settings/user-roles/page.tsx using exports defined in /media/Storage/Projects/Experiments/e-commerce/medusa-plugin-user-roles/node_modules/@medusajs/admin-ui/package.json.
Could not resolve import "@medusajs/admin-ui/ui/src/components/atoms/back-button" in /media/Storage/Projects/Experiments/e-commerce/medusa-plugin-user-roles/src/admin/settings/user-roles/page.tsx using exports defined in /media/Storage/Projects/Experiments/e-commerce/medusa-plugin-user-roles/node_modules/@medusajs/admin-ui/package.json.
Could not resolve import "@medusajs/admin-ui/ui/src/components/organisms/body-card" in /media/Storage/Projects/Experiments/e-commerce/medusa-plugin-user-roles/src/admin/settings/user-roles/page.tsx using exports defined in /media/Storage/Projects/Experiments/e-commerce/medusa-plugin-user-roles/node_modules/@medusajs/admin-ui/package.json.
"@medusajs/admin-ui/ui/src/components/organisms/body-card" is imported by "src/admin/settings/user-roles/page.tsx", but could not be resolved – treating it as an external dependency.
Could not resolve import "@medusajs/admin-ui/ui/src/components/atoms/back-button" in /media/Storage/Projects/Experiments/e-commerce/medusa-plugin-user-roles/src/admin/settings/user-roles/page.tsx using exports defined in /media/Storage/Projects/Experiments/e-commerce/medusa-plugin-user-roles/node_modules/@medusajs/admin-ui/package.json.
"@medusajs/admin-ui/ui/src/components/atoms/back-button" is imported by "src/admin/settings/user-roles/page.tsx", but could not be resolved – treating it as an external dependency.
20:19:38 [@medusajs/admin] The extension bundle has been built successfully

In the server:

WARNING in ../medusa-plugin-user-roles/dist/admin/_virtual_entry.js 764:102-105
export 'jsx' (imported as 'jsx') was not found in 'react/jsx-runtime' (module has no exports)
 @ ./.cache/admin/src/extensions/_main-entry.ts 3:0-88 7:4-11
 @ ./.cache/admin/src/main.tsx 151:24-152:54

ERROR in ../medusa-plugin-user-roles/dist/admin/_virtual_entry.js 8:0-80
Module not found: Error: Can't resolve '@medusajs/admin-ui/ui/src/components/atoms/back-button' in '/media/Storage/Projects/Experiments/e-commerce/medusa-plugin-user-roles/dist/admin'
resolve '@medusajs/admin-ui/ui/src/components/atoms/back-button' in '/media/Storage/Projects/Experiments/e-commerce/medusa-plugin-user-roles/dist/admin'
  Parsed request is a module
  using description file: /media/Storage/Projects/Experiments/e-commerce/medusa-plugin-user-roles/package.json (relative path: ./dist/admin)
    Field 'browser' doesn't contain a valid alias configuration
    resolve as module
      /media/Storage/Projects/Experiments/e-commerce/medusa-plugin-user-roles/dist/admin/node_modules doesn't exist or is not a directory
      /media/Storage/Projects/Experiments/e-commerce/medusa-plugin-user-roles/dist/node_modules doesn't exist or is not a directory
      looking for modules in /media/Storage/Projects/Experiments/e-commerce/medusa-plugin-user-roles/node_modules
        /media/Storage/Projects/Experiments/e-commerce/medusa-plugin-user-roles/node_modules/@medusajs/admin-ui doesn't exist
      looking for modules in /media/Storage/Projects/Experiments/e-commerce/node_modules
        /media/Storage/Projects/Experiments/e-commerce/node_modules/@medusajs/admin-ui doesn't exist
      /media/Storage/Projects/Experiments/node_modules doesn't exist or is not a directory
      /media/Storage/Projects/node_modules doesn't exist or is not a directory
      /media/Storage/node_modules doesn't exist or is not a directory
      /media/node_modules doesn't exist or is not a directory
      /node_modules doesn't exist or is not a directory
      looking for modules in /media/Storage/Projects/Experiments/e-commerce/test/node_modules/@medusajs/admin-ui/node_modules
        /media/Storage/Projects/Experiments/e-commerce/test/node_modules/@medusajs/admin-ui/node_modules/@medusajs/admin-ui doesn't exist
 @ ./.cache/admin/src/extensions/_main-entry.ts 3:0-88 7:4-11
 @ ./.cache/admin/src/main.tsx 151:24-152:54

ERROR in ../medusa-plugin-user-roles/dist/admin/_virtual_entry.js 9:0-80
Module not found: Error: Can't resolve '@medusajs/admin-ui/ui/src/components/organisms/body-card' in '/media/Storage/Projects/Experiments/e-commerce/medusa-plugin-user-roles/dist/admin'
resolve '@medusajs/admin-ui/ui/src/components/organisms/body-card' in '/media/Storage/Projects/Experiments/e-commerce/medusa-plugin-user-roles/dist/admin'
  Parsed request is a module
  using description file: /media/Storage/Projects/Experiments/e-commerce/medusa-plugin-user-roles/package.json (relative path: ./dist/admin)
    Field 'browser' doesn't contain a valid alias configuration
    resolve as module
      /media/Storage/Projects/Experiments/e-commerce/medusa-plugin-user-roles/dist/admin/node_modules doesn't exist or is not a directory
      /media/Storage/Projects/Experiments/e-commerce/medusa-plugin-user-roles/dist/node_modules doesn't exist or is not a directory
      looking for modules in /media/Storage/Projects/Experiments/e-commerce/medusa-plugin-user-roles/node_modules
        /media/Storage/Projects/Experiments/e-commerce/medusa-plugin-user-roles/node_modules/@medusajs/admin-ui doesn't exist
      looking for modules in /media/Storage/Projects/Experiments/e-commerce/node_modules
        /media/Storage/Projects/Experiments/e-commerce/node_modules/@medusajs/admin-ui doesn't exist
      /media/Storage/Projects/Experiments/node_modules doesn't exist or is not a directory
      /media/Storage/Projects/node_modules doesn't exist or is not a directory
      /media/Storage/node_modules doesn't exist or is not a directory
      /media/node_modules doesn't exist or is not a directory
      /node_modules doesn't exist or is not a directory
      looking for modules in /media/Storage/Projects/Experiments/e-commerce/test/node_modules/@medusajs/admin-ui/node_modules
        /media/Storage/Projects/Experiments/e-commerce/test/node_modules/@medusajs/admin-ui/node_modules/@medusajs/admin-ui doesn't exist
 @ ./.cache/admin/src/extensions/_main-entry.ts 3:0-88 7:4-11
 @ ./.cache/admin/src/main.tsx 151:24-152:54

webpack 5.94.0 compiled with 2 errors and 188 warnings in 3114 ms

Code snippets

If applicable, add code samples to help explain your problem

Additional context

As a workaround, we are copy pasting the components.

naaa760 commented 1 month ago

Hello @SalahAdDin :)

I think first you have to resolve the error, first, verify that the BackButton and BodyCard components exist in the @medusajs/admin-ui package and are correctly exported in the package.json file. Next, update your import statements to match the correct paths defined in the package's exports. Finally, rebuild your plugin by removing the node_modules directory, reinstalling dependencies, and starting the development server again to check for successful imports.

SalahAdDin commented 1 month ago

Hello @SalahAdDin :)

I think first you have to resolve the error, first, verify that the BackButton and BodyCard components exist in the @medusajs/admin-ui package and are correctly exported in the package.json file. Next, update your import statements to match the correct paths defined in the package's exports. Finally, rebuild your plugin by removing the node_modules directory, reinstalling dependencies, and starting the development server again to check for successful imports.

I checked it and they are not exported, it will be required from the MedusaJS team to export them.

oybek-daniyarov commented 1 month ago

I've encountered the same issue. Components like data tables, route modals, and drawers, data tables would be very beneficial for speeding up development. Currently, we have to manually copy and paste the code from the dashboard package, which is really slowing down the development process.