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

Override of Prettier plugins during code transformation seems not possible with 8.2.1 release #25592

Closed
1 task
vishal423 opened this issue Mar 21, 2024 · 2 comments

Comments

@vishal423
Copy link
Contributor

Overview of the issue

I am trying to upgrade JHipster Svelte blueprint to support 8.2.1 release, however, I don't see an easy way to override the prettier plugins to include prettier-plugin-svelte to transform the svelte code.

If you override to include prettier plugins, code generation fails with below stack trace:

 - applying multi-step templates
✔ Git repository initialized.
   create .prettierrc
   create .prettierignore
✔ prettier configuration files committed to disk
- updating package.json dependencies versions
- prettifying sonar-project.properties
- adding package-info.java files
ERROR! ERROR! function hasPragma(text) {
    return /^\s*<!--\s*@(format|prettier)\W/.test(text);
} could not be cloned.
DOMException [DataCloneError]: function hasPragma(text) {
    return /^\s*<!--\s*@(format|prettier)\W/.test(text);
} could not be cloned.
    at new DOMException (node:internal/per_context/domexception:53:5)
    at WorkerInfo.postTask (/opt/svelte/node_modules/piscina/dist/src/index.js:346:23)
    at ThreadPool.runTask (/opt/svelte/node_modules/piscina/dist/src/index.js:712:20)
    at Piscina.run (/opt/svelte/node_modules/piscina/dist/src/index.js:923:65)
    at Object.<anonymous> (file:///opt/svelte/node_modules/generator-jhipster/dist/generators/bootstrap/support/prettier-support.js:41:53)
    at Object.<anonymous> (file:///opt/svelte/node_modules/p-transform/dist/index.js:13:16)
    at file:///opt/svelte/node_modules/p-transform/dist/queue.js:55:47
    at file:///opt/svelte/node_modules/p-transform/dist/queue.js:69:34
    at file:///opt/svelte/node_modules/p-transform/node_modules/p-queue/dist/index.js:111:37
    at PQueue._PQueue_tryToStartAnother (file:///opt/svelte/node_modules/p-transform/node_modules/p-queue/dist/index.js:285:13)
Error: Process completed with exit code 1.
Motivation for or Use Case
Reproduce the error
Related issues

It seems the issue occurs due to switch to use web workers for prettier and eslint transform tasks. Serialization seems to not work correctly when overriding the plugins.

Suggest a Fix
JHipster Version(s)

8.2.1

JHipster configuration
Entity configuration(s) entityName.json files generated in the .jhipster directory
Browsers and Operating System
  • Checking this box is mandatory (this is just to show you read everything)
@mshima
Copy link
Member

mshima commented Mar 22, 2024

In my tests (using built-in plugins) if you pass the module url it should work:

bootstrapGenerator.prettierOptions.plugins.push(import.meta.resolve('prettier-plugin-svelte', import.meta.url));

@vishal423
Copy link
Contributor Author

Thanks @mshima, the suggested syntax seems to work fine. I will close the ticket

@mraible mraible added this to the 8.3.0 milestone Apr 8, 2024
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

3 participants