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

Registering custom hook extension fails when using plaiceholder package #11360

Closed
3 tasks done
polynook opened this issue Jan 31, 2022 · 3 comments
Closed
3 tasks done
Labels

Comments

@polynook
Copy link

Preflight Checklist

Describe the Bug

I'm trying to use plaiceholder inside a custom hook but having problems.

The custom hook extension as the following index.ts file:
Screenshot 2022-01-31 182208

I build the extension, place it inside Directus app and run npx directus start. I get the following error:

Screenshot 2022-01-31 101421

The same code works fine when executed in Next.js app getServerSideProps function.

As the error suggested, I tried configuring @rollup/plugin-commonjs by going by the instructions I found in the docs here https://docs.directus.io/extensions/creating-extensions/#configuring-the-cli :

Screenshot 2022-01-31 110535

With this config, the previous error is gone but I get a different one:
Screenshot 2022-01-31 110648

To Reproduce

  1. npm init directus-extension -> hook -> typescript -> name: custom-hook
  2. npm init directus-project example-project -> sqlite/postgres
  3. Change @directus/extensions-sdk and directus package versions from 9.5.0 to 9.4.3 because of Building and running extensions is broken #11275
  4. cd custom-hook npm install plaiceholder
  5. import getPlaiceholder function inside src/index.ts and console.log it inside any of the hooks (as shown in the first image in Describe the Bug section).
  6. Build extension with npm run build
  7. Copy index.js from dist folder into Directus app at example-project/extensions/hooks/custom-hook/
  8. npx directus start

Errors Shown

Screenshot 2022-01-31 101421
Screenshot 2022-01-31 110648

What version of Directus are you using?

9.4.3

What version of Node.js are you using?

v16.13.1

What database are you using?

Postgres 14.1

What browser are you using?

Chrome

What operating system are you using?

Windows 10

How are you deploying Directus?

running locally

@Lerado

This comment was marked as duplicate.

@rijkvanzanten
Copy link
Member

Linear: ENG-273

@rijkvanzanten
Copy link
Member

I believe this is resolved with the switch to ESM and plaiceholder v3. Happy to reopen if not.

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

No branches or pull requests

5 participants