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

How to use on Nest monorepo structure ? #916

Open
fluffy-kaiju opened this issue Jun 16, 2024 · 2 comments
Open

How to use on Nest monorepo structure ? #916

fluffy-kaiju opened this issue Jun 16, 2024 · 2 comments
Assignees
Labels
help wanted Extra attention is needed

Comments

@fluffy-kaiju
Copy link

Question

Hi!
I need to use Nestia on a Nest project with monorepo structure. Sadly, I get this error after enable monorepo mode.

Error: Error on nestia.core.TypedRoute.Get(): no transform has been configured. Run "npx typia setup" command, or check if you're using non-standard TypeScript compiler like Babel or SWC.

Running npx typia setup don't help, by default, nest seems to use webpack [1] and the "plugin" [2] option is setup in tsconfig.json

// project-name-npm-mono/nest-cli.json:
...
  "compilerOptions": {
    "deleteOutDir": true,
    "webpack": true, // <<---- [1]
    "tsConfigPath": "apps/project-name-npm/tsconfig.app.json"
  },
...
// project-name-npm-mono/tsconfig.json:
...
    "plugins": [ // <<--- [2]
      {
        "transform": "@nestia/core/lib/transform",
        /**
         * Validate request body.
         * 
         *   - "assert": Use typia.assert() function
         *   - "is": Use typia.is() function
         *   - "validate": Use typia.validate() function
         *   - "assertEquals": Use typia.assertEquals() function
         *   - "equals": Use typia.equals() function
         *   - "validateEquals": Use typia.validateEquals() function
         */
        "validate": "assert",
        /**
         * Validate JSON typed response body.
         * 
         *   - "assert": Use typia.assertStringify() function
         *   - "is": Use typia.isStringify() function
         *   - "validate": Use typia.validateStringify() function
         *   - "stringify": Use typia.stringify() function, but dangerous
         *   - null: Just use JSON.stringify() function, without boosting
         */
        "stringify": "assert"
      },
      {
        "transform": "typia/lib/transform"
      }
    ],
...

I don't find any resource about using Nestia on monorepo, did I miss something ?

Here I've created a repo with the walkthrough of my test https://github.com/fluffy-kaiju/nestia-v3.2.1-nestjs-monorepo-issue

Thanks for your help 😄

@samchon samchon added the help wanted Extra attention is needed label Jun 18, 2024
@samchon
Copy link
Owner

samchon commented Jun 20, 2024

Currently, to make monorepo SDK generation working, you should generate SDK library per each package.

I'll study how to, but cannot sure to be succeeded.

@samchon samchon self-assigned this Jun 20, 2024
@honguyenhaituan
Copy link

honguyenhaituan commented Jul 10, 2024

@fluffy-kaiju When use nestia you must compile your app by tsc and the default repo nestjs generate use webpack: true. So you have two way to make run correctly:

  • turn off webpack
// project-name-npm-mono/nest-cli.json:
...
  "compilerOptions": {
    "deleteOutDir": true,
    "webpack": false, // <<---- [1]
    "tsConfigPath": "apps/project-name-npm/tsconfig.app.json"
  },
...

or create config webpack config use tsc as compiler and transpileOnly: false

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants