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

Custom generators are not working #384

Open
misterx opened this issue Apr 4, 2024 · 1 comment
Open

Custom generators are not working #384

misterx opened this issue Apr 4, 2024 · 1 comment

Comments

@misterx
Copy link

misterx commented Apr 4, 2024

API Platform version(s) affected: 3.2.20

Description
When I'm trying to get the custom generator working, it fails with an error stating that BaseGenerator is not exported.

Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './lib/generators/BaseGenerator' is not defined by "exports" in /app/generator/node_modules/@api-platform/create-client/package.json imported from /app/generator/Generator.js
at new NodeError (node:internal/errors:405:5)
    at exportsNotFound (node:internal/modules/esm/resolve:366:10)
    at packageExportsResolve (node:internal/modules/esm/resolve:713:9)
    at packageResolve (node:internal/modules/esm/resolve:899:14)
    at moduleResolve (node:internal/modules/esm/resolve:973:20)
    at defaultResolve (node:internal/modules/esm/resolve:1193:11)
    at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:404:12)
    at ModuleLoader.resolve (node:internal/modules/esm/loader:373:25)
    at ModuleLoader.getModuleJob (node:internal/modules/esm/loader:250:38)
    at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:76:39) {
  code: 'ERR_PACKAGE_PATH_NOT_EXPORTED'
}

How to reproduce
Use the following package.json file:

{
  "name": "test-generator",
  "version": "1.0.0",
  "type": "module",
  "dependencies": {
    "@api-platform/create-client": "^0.10.0"
  }
}

Take generator and template from documentation https://api-platform.com/docs/create-client/custom/

Execute:

npm install
npm init @api-platform/client https://demo.api-platform.com/ ../test -- --generator "$(pwd)/Generator.js"

Additional Context

From what I see in the package.json file at https://github.com/api-platform/create-client/blob/main/package.json#L65, custom generators are tested only inside the create-client module.

@J3m5
Copy link

J3m5 commented Apr 9, 2024

Hello @misterx,

Thank you for bringing this to our attention.
We plan to address this issue in an upcoming release.
Please stay tuned for updates!

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

No branches or pull requests

2 participants