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

feat/docs: update setup nx #951

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
85 changes: 58 additions & 27 deletions website/pages/docs/setup.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -295,47 +295,78 @@ module.exports = {
<Tabs items={['npm', 'pnpm', 'yarn']}>
<Tab>
```bash filename="Terminal" copy showLineNumbers
npx nestia setup
# NESTIA
npm install --save-dev nestia
npm install --save-dev @nestia/sdk
npm install --save @nestia/core
npm install --save @nestia/e2e
npm install --save typia
```
</Tab>
<Tab>
```bash filename="Terminal" copy showLineNumbers
npx nestia setup --manager pnpm
# NESTIA
pnpm install --save-dev nestia
pnpm install --save-dev @nestia/sdk
pnpm install --save @nestia/core
pnpm install --save @nestia/e2e
pnpm install --save typia
```
</Tab>
<Tab>
```bash filename="Terminal" copy showLineNumbers
npx nestia setup --manager yarn
# NESTIA
yarn add -D nestia
yarn add -D @nestia/sdk
yarn add @nestia/core
yarn add @nestia/e2e
yarn add typia
```
</Tab>
</Tabs>

After install `nestia` like above, you have to modify `project.json` on each app you use typia like below.

```javascript filename="project.json" showLineNumbers copy
"targets": {
Copy link

@BaptisteMahe BaptisteMahe Oct 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is necessary in your project.json inside the nestia app. And should not be removed from the documentation.

"build": {
...
"options": {
...
"target": "node",
"compiler": "tsc",
"transformers": [
"typia/lib/transform",
{
"name": "@nestia/core/lib/transform",
"options": {
"validate": "assert",
"stringify": "assert"
}
}
]
}
},
...
}
After install `nestia` like above, you have to configure tsconfig.base.json (or ts.config.json on app you use nestia) like blow.

```json filename="tsconfig.json" showLineNumbers copy
{
Copy link

@BaptisteMahe BaptisteMahe Oct 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree that this should be added to the documentation.

But I think it's better to recommend not having this inside the global tsconfig.base.json but inside each tsconfig.app.json for each nestia app inside the NX monorepo.

In some cases those plugins can interfere with Angular apps and prevent them from building if this is sets inside the tsconfig.base.json

"strict": true,
"strictNullChecks": true,
"compilerOptions": {
"plugins": [
{ "transform": "typia/lib/transform" },
{
"transform": "@nestia/core/lib/transform",
"validate": "assert",
"stringify": "assert",
},
],
},
}
```

After that you have to turn off option "transpileOnly": false (default nx use option "transpileOnly": true) like blow:

```json filename="webpack.config.js" showLineNumbers copy
const { composePlugins, withNx } = require('@nx/webpack');

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This wasn't necessay in my case


module.exports = composePlugins(withNx({}), (config) => {
config.module?.rules.forEach((rule) => {
if (rule.options?.transpileOnly) {
rule.options.transpileOnly = false;
}
});

config.devtool = 'inline-source-map';
config.plugins = config.plugins?.filter(
(plugin) => plugin.constructor.name !== 'ForkTsCheckerWebpackPlugin'
);
return config;
});
```

See example project at [Commit](https://github.com/honguyenhaituan/nx-typia/commit/c1df98cf949b84633448d9ec4edbcef3635a0927#diff-a0a5604fa921b013eb184e3591b2908eabdca975a41a1134653bc627a55f4d32)





Expand Down