#Issue with ImportMap

6 messages · Page 1 of 1 (latest)

unreal grotto
#

Hi all! I have the following admin setup

admin: {
    user: Users.slug,
    components: {
      beforeLogin: ['@/components/BeforeLogin'],
    },
  },
getFromImportMap: PayloadComponent not found in importMap {
  key: '@/components/BeforeLogin#default',
  PayloadComponent: '@/components/BeforeLogin',
} 

I have verified that my paths are correct by manually adding the component into the importMap
like this (I got the same hash from the website template)

  "@/components/BeforeLogin#default": default_8a7ab0eb7ab5c511aba12e68480bfe5e
   import { default as default_8a7ab0eb7ab5c511aba12e68480bfe5e } from '@/components/BeforeLogin'

So when I run npm run dev the custom component renders as expected... however when I remove my manually added code inside of the ImportMap and run again-- it doesn't generate a new map.

So I tried to manually do it with npx payload generate:importmap and get the following...

TypeError [ERR_INVALID_ARG_TYPE]: The "data" argument must be of type string or an instance of Buffer, TypedArray, or DataView. Received undefined
    at Hash.update (node:internal/crypto/hash:115:11)
    at addPayloadComponentToImportMap (/Users/mo/Desktop/Dev/wizards/node_modules/payload/src/bin/generateImportMap/index.ts:61:49)
    at addToImportMap (/Users/mo/Desktop/Dev/wizards/node_modules/payload/src/bin/generateImportMap/index.ts:167:7)
    at iterateCollections (/Users/mo/Desktop/Dev/wizards/node_modules/payload/src/bin/generateImportMap/iterateCollections.ts:34:5)
    at iterateConfig (/Users/mo/Desktop/Dev/wizards/node_modules/payload/src/bin/generateImportMap/iterateConfig.ts:22:3)
    at generateImportMap (/Users/mo/Desktop/Dev/wizards/node_modules/payload/src/bin/generateImportMap/index.ts:176:3)
    at bin (/Users/mo/Desktop/Dev/wizards/node_modules/payload/dist/bin/index.js:73:16)
    at async start (file:///Users/mo/Desktop/Dev/wizards/node_modules/payload/bin.js:30:7) {
  code: 'ERR_INVALID_ARG_TYPE'
}
unreal grotto
#

Any pointers or advice would be greatly appreciated!

uncut lodge
#

Hi!

I don't know if this helps but your component for BeforeLogin should be

export default BeforeLogin;

so that you can use the '@/components/BeforeLogin' without the '#'.

in my case, i deleted everything in importMap leaving only

export const importMap = {}

^ not too sure if deleting everything is necessary

then re-run

pnpm payload generate:importmap

and everything required in importMap was regenerated for me with the correct linking.

unreal grotto
#

Hi thank you for helping!

Unfortunately my component already has the proper export.

import React from 'react'

const BeforeLogin: React.FC = () => {
  return (
    <div>
      <p>
        <b>Welcome to your dashboard!</b>
        {' This is where site admins will log in to manage your website.'}
      </p>
    </div>
  )
}

export default BeforeLogin

It's just an example component from the payload-website template.

I've tried to delete the the importMap file contents and try as well-- no luck so far.

proud oyster
#

Yeah, I was also having issues with the importMap yesterday. I noticed that it worked if I manually changed the import, but it automatically rewrites anyway, so that's not a real solution: #1328026228556566571 message