graphile / graphile/worker

Critical dependency warning when running in Next.js

Open
#466 3 comments 2 reactions 0 assignees View on GitHub
enhancement
Dominant language
TypeScript
Stars
2.4k
Forks
126
Avg merge
2d 2h
Merged PRs (30d)
9

Description

### Summary

When including Graphile Worker in a Next.js project, dependency warnings are thrown.

### Steps to reproduce

```typescript
import {quickAddJob} from "graphile-worker";

export async function POST(req: Request) {
const payload = req.text();
const job = await quickAddJob(
{ connectionString: process.env.DATABASE_URL },
"test-task",
{payload},
);
console.log(`Job added: ${job.id}`);
return new Response(null, {status: 200});
}

```

### Expected results

The job gets enqueued.

### Actual results

The job is enqueued, but this warning is shown in the console:

```
[22:10:45.274] WARN (next.js/1652545): ./node_modules/graphile-worker/node_modules/cosmiconfig/dist/loaders.js
Critical dependency: the request of a dependency is an expression

Import trace for requested module:
./node_modules/graphile-worker/node_modules/cosmiconfig/dist/loaders.js
./node_modules/graphile-worker/node_modules/cosmiconfig/dist/index.js
./node_modules/graphile-worker/dist/config.js
./node_modules/graphile-worker/dist/preset.js
./node_modules/graphile-worker/dist/index.js
./src/app/api/test-worker/route.ts
prefix: "warn"
```

### Additional context

I tried modifying my Next.js config as suggested in #345:

```javascript
config.module.rules.push(
{
test: [
path.resolve("node_modules/pg/lib/native"),
path.resolve("node_modules/import-fresh"),
path.resolve("node_modules/graphile-worker/dist/getTasks"),
],
loader: "null-loader",
},
);
```

But that only partly solved the issue. There were more warnings displayed before changing the config, though.

### Possible Solution

I suspect there is some way to exclude a certain module to make the warnings go away, but nothing I have tried has worked so far.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.