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

Import Maps not generated in proper directory when admin route is changed. #8115

Closed
FiniteVoid opened this issue Sep 8, 2024 · 3 comments
Closed
Labels

Comments

@FiniteVoid
Copy link

FiniteVoid commented Sep 8, 2024

Link to reproduction

Steps mentioned below

Environment Info

Pnpm, Bun beta.100 (been happening since 79)

Describe the Bug

Current

  • When the route for admin panel is changed to let's say 'account,' the importMap is generated only in the default src/(payload)/admin. It does not respect the route set in root payload config.
  • Since changing admin route means renaming 'admin' folder (Next JS's app router thing) to 'account,' admin folder doesn't exist anymore and I get:
importMapFolderPath = path.resolve(rootDir, 'src/app/(payload)/admin/');
  95 |     } else {
> 96 |         throw new Error(`Could not find the payload admin directory. Looked in ${path.resolve(rootDir, 'app/(payload)/admin/')} and ${path.resolve(rootDir, 'src/app/(payload)/admin/')}`);
     | ^
  97 |     }

Expected

Payload automatically picks up which folder to overwrite importMap in based on payload config.

Workaround

Duplicate the 'account' folder in app router directories to 'admin,' then whenever a new importMap is generated, manually copy its content over to the importMap in my custom route's folder.

Reproduction Steps

  1. Create-payload-app@beta
  2. Create a custom component somewhere in the project. Mine's in: ./app/customActions/home
  3. Change the admin path in root config:
...
export default buildConfig({
  routes: {
    admin: '/account',
  },
...
  1. Rightfully rename the admin folder in ./app/(payload)/admin to account to make admin panel work.
  2. Add a component to root config and save.
...
export default buildConfig({
  routes: {
    admin: '/account',
  },
  admin: {
    components: { actions: ['./app/customActions/home'] },
...
  1. Notice the failure to generate Import Maps.

Adapters and Plugins

sqlite, mongo

@FiniteVoid FiniteVoid added status: needs-triage Possible bug which hasn't been reproduced yet v3 labels Sep 8, 2024
@r1tsuu r1tsuu added the status: verified If an issue has been reproduced label Sep 8, 2024
@github-actions github-actions bot removed the status: needs-triage Possible bug which hasn't been reproduced yet label Sep 8, 2024
@BlainMaguire
Copy link

This is a duplicate of: #7803

I had the same issue, I created a PR for it here:
#8085

@FiniteVoid
Copy link
Author

Ahh, definitely true, thank you for noticing this. Happy to close this one. Sorry for not doing my due diligence before posting. I looked for issues when it first started happening around 79, but then revisited proj 2 weeks later and assumed things were same when there was no fix.

@github-actions github-actions bot removed the status: verified If an issue has been reproduced label Sep 10, 2024
Copy link

This issue has been automatically locked.
Please open a new issue if this issue persists with any additional detail.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 12, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants