Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Plugin export method not accessible #11662

Open
Nicolas-Mousten opened this issue Feb 28, 2025 · 1 comment
Open

[Bug]: Plugin export method not accessible #11662

Nicolas-Mousten opened this issue Feb 28, 2025 · 1 comment

Comments

@Nicolas-Mousten
Copy link

Nicolas-Mousten commented Feb 28, 2025

Package.json file

Plugin package.json:
{
  "name": "report-plugin",
  "version": "0.0.1",
  "description": "A starter for Medusa plugins.",
  "author": "Medusa (https://medusajs.com)",
  "license": "MIT",
  "types": "./.medusa/server/src/admin/index.d.ts",
  "files": [
    ".medusa/server"
  ],
  "exports": {
    "./package.json": "./package.json",
    "./workflows": "./.medusa/server/src/workflows/index.js",
    "./.medusa/server/src/modules/*": "./.medusa/server/src/modules/*/index.js",
    "./modules/*": "./.medusa/server/src/modules/*/index.js",
    "./providers/*": "./.medusa/server/src/providers/*/index.js",
    "./*": "./.medusa/server/src/*.js",
    "./admin": "./.medusa/server/src/admin/index.js",
    "./admin/*": "./.medusa/server/src/admin/*.js"
  },
  "keywords": [
    "medusa",
    "plugin",
    "medusa-plugin-other",
    "medusa-plugin",
    "medusa-v2"
  ],
  "scripts": {
    "build": "medusa plugin:build",
    "dev": "medusa plugin:develop",
    "prepublishOnly": "medusa plugin:build",
    "start-medusa": "yalc publish && npm --prefix ../../my-medusa-store run dev"
  },
  "devDependencies": {
    "@medusajs/admin-sdk": "2.4.0",
    "@medusajs/cli": "2.4.0",
    "@medusajs/framework": "2.4.0",
    "@medusajs/icons": "2.4.0",
    "@medusajs/medusa": "2.4.0",
    "@medusajs/test-utils": "2.4.0",
    "@medusajs/ui": "4.0.3",
    "@mikro-orm/cli": "6.4.3",
    "@mikro-orm/core": "6.4.3",
    "@mikro-orm/knex": "6.4.3",
    "@mikro-orm/migrations": "6.4.3",
    "@mikro-orm/postgresql": "6.4.3",
    "@swc/core": "1.5.7",
    "@types/node": "^20.0.0",
    "@types/react": "^18.3.2",
    "@types/react-dom": "^18.2.25",
    "awilix": "^8.0.1",
    "pg": "^8.13.0",
    "prop-types": "^15.8.1",
    "react": "^18.2.0",
    "react-dom": "^18.2.0",
    "ts-node": "^10.9.2",
    "typescript": "^5.6.2",
    "vite": "^5.2.11",
    "yalc": "^1.0.0-pre.53"
  },
  "peerDependencies": {
    "@medusajs/admin-sdk": "2.4.0",
    "@medusajs/cli": "2.4.0",
    "@medusajs/framework": "2.4.0",
    "@medusajs/icons": "2.4.0",
    "@medusajs/medusa": "2.4.0",
    "@medusajs/test-utils": "2.4.0",
    "@medusajs/ui": "4.0.3",
    "@mikro-orm/cli": "6.4.3",
    "@mikro-orm/core": "6.4.3",
    "@mikro-orm/knex": "6.4.3",
    "@mikro-orm/migrations": "6.4.3",
    "@mikro-orm/postgresql": "6.4.3",
    "awilix": "^8.0.1",
    "pg": "^8.13.0"
  },
  "engines": {
    "node": ">=20"
  },
  "dependencies": {
    "@radix-ui/react-switch": "^1.1.3"
  }
}

main medusa package.json:
{
  "name": "my-medusa-store",
  "version": "0.0.1",
  "description": "A starter for Medusa projects.",
  "author": "Medusa (https://medusajs.com)",
  "license": "MIT",
  "keywords": [
    "sqlite",
    "postgres",
    "typescript",
    "ecommerce",
    "headless",
    "medusa"
  ],
  "scripts": {
    "build": "medusa build",
    "seed": "medusa exec ./src/scripts/seed.ts",
    "start": "medusa start",
    "dev": "npx medusa plugin:add report-plugin && medusa develop",
    "test:integration:http": "TEST_TYPE=integration:http NODE_OPTIONS=--experimental-vm-modules jest --silent=false --runInBand --forceExit",
    "test:integration:modules": "TEST_TYPE=integration:modules NODE_OPTIONS=--experimental-vm-modules jest --silent --runInBand --forceExit",
    "test:unit": "TEST_TYPE=unit NODE_OPTIONS=--experimental-vm-modules jest --silent --runInBand --forceExit",
    "dev:debug": "npx medusa plugin:add report-plugin && npx --node-arg=--inspect=9229 medusa develop",
    "auto": "npx medusa db:migrate && npx medusa exec ./src/scripts/seed.ts && npx medusa user -e [email protected] -p 123 && npm run dev"
  },
  "dependencies": {
    "@medusajs/admin-sdk": "2.4.0",
    "@medusajs/cli": "2.4.0",
    "@medusajs/framework": "2.4.0",
    "@medusajs/medusa": "2.4.0",
    "@mikro-orm/core": "6.4.3",
    "@mikro-orm/knex": "6.4.3",
    "@mikro-orm/migrations": "6.4.3",
    "@mikro-orm/postgresql": "6.4.3",
    "@types/qs": "^6.9.18",
    "awilix": "^8.0.1",
    "chart.js": "^4.4.7",
    "pg": "^8.13.0",
    "qs": "^6.14.0",
    "report-plugin": "file:.yalc/report-plugin"
  },
  "devDependencies": {
    "@faker-js/faker": "^9.4.0",
    "@medusajs/test-utils": "2.4.0",
    "@mikro-orm/cli": "6.4.3",
    "@swc/core": "1.5.7",
    "@swc/jest": "^0.2.36",
    "@types/jest": "^29.5.13",
    "@types/node": "^20.0.0",
    "@types/react": "^18.3.2",
    "@types/react-dom": "^18.2.25",
    "jest": "^29.7.0",
    "prop-types": "^15.8.1",
    "react": "^18.2.0",
    "react-dom": "^18.2.0",
    "ts-node": "^10.9.2",
    "typescript": "^5.6.2",
    "vite": "^5.2.11",
    "yalc": "^1.0.0-pre.53"
  },
  "engines": {
    "node": ">=20"
  }
}

Node.js version

v22.13.1

Database and its version

PostgreSQL 17

Operating system name and version

Windows 10

Browser name

Chrome

What happended?

I am trying to access a method for registering a customComponent that is meant to be shown in the page the plugin makes. The method takes an id, name and the react component. i works fine when i use it from the plugin but when i try to access it from the main medusa application it keeps not recognizing the method, but i can se in .yalc that the plugin with the method is in the dependencies.

Expected behavior

Able to access the method and call it.

Actual behavior

Keeps giving me this error or saying it can't find the module:
Could not find a declaration file for module 'report-plugin/admin'. 'c:/Users/****/Desktop/Medus Projects/my-medusa-store/node_modules/report-plugin/.medusa/server/src/admin/index.js' implicitly has an 'any' type.
Try npm i --save-dev @types/report-plugin if it exists or add a new declaration (.d.ts) file containing declare module 'report-plugin/admin';ts(7016)

Link to reproduction repo

https://github.com/Nicolas-Mousten/MedusaTest

@Nicolas-Mousten
Copy link
Author

I feel like i am out on deep water, am i misunderstanding something here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant