Skip to content

How to Use Nestia SDK within an Nx Monorepo? #1104

@JeyP90

Description

@JeyP90

Hello,

I am trying to integrate Nestia SDK into an Nx monorepo setup, but I am encountering difficulties in configuring it properly.

Specifically, I created a nestia.config.ts file with the following content:

import { INestiaConfig } from '@nestia/sdk';
import { NestFactory } from '@nestjs/core';
import { AppModule } from './apps/backend/src/app/app.module';

const NESTIA_CONFIG: INestiaConfig = {
    input: async () => {
        const app = await NestFactory.create(AppModule);
        return app;
    },
    output: 'libs/ap-sdk/src/,
};

export default NESTIA_CONFIG;

However, when I try to run the command:

npx nestia sdk

I encounter the following issues:

  • ES-Module Issue: I get the error Must use import to load ES Module, because Nestia tries to load the nestia.config.ts file as a CommonJS? module, but it's written as an ES module due to the import syntax.
  • Unexpected 'export' token: When I try to dynamically import the file using ES module syntax, I get the error: SyntaxError: Unexpected token 'export'.
  • I have also tried adding/removing "type": "module" from the package.json, but then I run into additional issues with handling import/export syntax in the configuration file.

Could you provide guidance on how to correctly set up and use Nestia SDK in an Nx-based monorepo? Any help or examples would be greatly appreciated!

Here is an example repository with a similar setup what im using: https://github.com/JeyP90/nx-nestia-angular-test

Thanks in advance!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions