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

@adminjs/nestjs is not supporting swc builder in NestJs10 #58

Open
davvar opened this issue Jul 7, 2023 · 5 comments
Open

@adminjs/nestjs is not supporting swc builder in NestJs10 #58

davvar opened this issue Jul 7, 2023 · 5 comments

Comments

@davvar
Copy link

davvar commented Jul 7, 2023

After changing the builder to swc app stopped working

// nest-cli.json
{
  "$schema": "https://json.schemastore.org/nest-cli",
  "collection": "@nestjs/schematics",
  "sourceRoot": "src",
  "compilerOptions": {
    "deleteOutDir": true,
    "builder": "swc",
    "typeCheck": true
  }
}

[Nest] 23394  - 07/07/2023, 2:06:43 PM   ERROR [ExceptionHandler] No "exports" main defined in /node_modules/@adminjs/nestjs/package.json
Error: No "exports" main defined in /node_modules/@adminjs/nestjs/package.json
    at new NodeError (node:internal/errors:399:5)
    at exportsNotFound (node:internal/modules/esm/resolve:361:10)
    at packageExportsResolve (node:internal/modules/esm/resolve:641:13)
    at resolveExports (node:internal/modules/cjs/loader:565:36)
    at Function.Module._findPath (node:internal/modules/cjs/loader:634:31)
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:1061:27)
    at Function.Module._load (node:internal/modules/cjs/loader:920:27)
    at Module.require (node:internal/modules/cjs/loader:1141:19)
    at require (node:internal/modules/cjs/helpers:110:18)
    at /dist/configs/admin-dashboard/admin-dashboard.module.js:68:84

And this is my module that is simply being imported in app.module.ts

@Module({
imports: [
  // AdminJS version 7 is ESM-only. In order to import it, you have to use dynamic imports.
  Promise.all([
    import('@adminjs/nestjs'),
    import('@adminjs/typeorm'),
    import('adminjs'),
  ]).then(
    ([{ AdminModule }, { Database, Resource }, { default: AdminJS }]) => {
      AdminJS.registerAdapter({ Resource, Database });

      return AdminModule.createAdminAsync({
        useFactory: () => ({
          adminJsOptions: {
            rootPath: '/admin',
            resources: [
              // resources
            ],
          },
          sessionOptions: {
            resave: true,
            saveUninitialized: true,
            secret: 'secret',
          },
        }),
      });
    },
  ),
],
})
export class AdminDashboardModule {}
@davvar davvar changed the title '@adminjs/nestjs' is not supporting swc builder in NestJs10 @adminjs/nestjs is not supporting swc builder in NestJs10 Jul 7, 2023
@rushg171
Copy link

Facing the same problem. Any solution?

@vadolasi
Copy link

Same problem

@pacholoamit
Copy link

Same problem here

1 similar comment
@ArthurRAmaral
Copy link

Same problem here

@GeekDenCode
Copy link

I use webpack, but I had exactly the same error.

I used nodenext to solve it, but it didn't help. However, this is still required.

"module": "nodenext",
"moduleResolution": "nodenext"

After many hours, I found a solution. The problem turned out to be that webpack converted dynamic imports into require(), regardless of the module in tsconfig.

Solution:

import(/* webpackIgnore: true */'@adminjs/nestjs')

I hope this helps you in your search for a solution with a swc. Perhaps it has a similar method for saving dynamic imports inside bundle.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants