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

[Bug]: Vercel build fails to load next.config.js #142

Open
empz opened this issue May 16, 2024 · 5 comments
Open

[Bug]: Vercel build fails to load next.config.js #142

empz opened this issue May 16, 2024 · 5 comments
Assignees
Labels
bug Something isn't working triage New issues get this label, remove it after triage

Comments

@empz
Copy link

empz commented May 16, 2024

Provide environment information

Next.js 14.2.3
@serwist/next: 9.0.2

Which project is this issue for?

@serwist/next

Link to reproduction - Issues with a link to complete (but minimal) reproduction code help us address them faster

Will include later

To reproduce

  1. Create a T3-App
bun create t3-app@latest
  1. Follow the steps described here:
    https://serwist.pages.dev/docs/next/getting-started

  2. Deploy to Vercel

Describe the bug

Building the app locally works fine, but building in Vercel fails with the following logs/error:

[01:02:29.465]  ⨯ Failed to load next.config.js, see more info here https://nextjs.org/docs/messages/next-config-error
[01:02:29.471] 
[01:02:29.472] > Build error occurred
[01:02:29.473] file:///vercel/path0/node_modules/glob/dist/esm/pattern.js:2
[01:02:29.473] import { GLOBSTAR } from 'minimatch';
[01:02:29.473]          ^^^^^^^^
[01:02:29.473] SyntaxError: Named export 'GLOBSTAR' not found. The requested module 'minimatch' is a CommonJS module, which may not support all module.exports as named exports.
[01:02:29.473] CommonJS modules can always be imported via the default export, for example using:
[01:02:29.473] 
[01:02:29.474] import pkg from 'minimatch';
[01:02:29.474] const { GLOBSTAR } = pkg;
[01:02:29.474] 
[01:02:29.474]     at ModuleJob._instantiate (node:internal/modules/esm/module_job:134:21)
[01:02:29.474]     at async ModuleJob.run (node:internal/modules/esm/module_job:217:5)
[01:02:29.474]     at async ModuleLoader.import (node:internal/modules/esm/loader:316:24)
[01:02:29.474]     at async loadConfig (/vercel/path0/node_modules/next/dist/server/config.js:698:36)
[01:02:29.474]     at async Span.traceAsyncFn (/vercel/path0/node_modules/next/dist/trace/trace.js:154:20)
[01:02:29.474]     at async /vercel/path0/node_modules/next/dist/build/index.js:372:28
[01:02:29.474]     at async Span.traceAsyncFn (/vercel/path0/node_modules/next/dist/trace/trace.js:154:20)
[01:02:29.474]     at async build (/vercel/path0/node_modules/next/dist/build/index.js:366:9)
[01:02:29.480] error: script "vercel-build" exited with code 1
[01:02:29.484] Error: Command "bun run vercel-build" exited with 1

Expected behavior

It should build.

Screenshots (if relevant)

No response

Additional information (if relevant)

next.config.js

import withSerwistInit from "@serwist/next";

const withSerwist = withSerwistInit({
  // Note: This is only an example. If you use Pages Router,
  // use something else that works, such as "service-worker/index.ts".
  swSrc: "src/app/sw.ts",
  swDest: "public/sw.js",
});

/**
 * Run `build` or `dev` with `SKIP_ENV_VALIDATION` to skip env validation. This is especially useful
 * for Docker builds.
 */
await import("./src/env.js");

/** @type {import("next").NextConfig} */
const config = {};

export default withSerwist(config);

Everything else is the default from create-t3-app.

@empz empz added bug Something isn't working triage New issues get this label, remove it after triage labels May 16, 2024
@JesseKoldewijn
Copy link

Sounds like it might be a package resolution issue with serwist + bun. Got multiple projects running serwist (of which, atleast 4 of em are started from the t3-app startingpoint) and when using any other package manager, all is fine.

@DuCanhGH
Copy link
Member

Seems that glob/minimatch's ESM/CJS hybrid support might be a bit weird. Suggest you open a new issue over there!

@andy5090
Copy link

same issue with t3 and bun on Vercel

@JesseKoldewijn
Copy link

same issue with t3 and bun on Vercel

aka, same as OP...

@mrkosima
Copy link

mrkosima commented Jun 8, 2024

I have the same issue with

"next": "^14.3.0-canary.79"
"@serwist/next": "^9.0.2",

But I managed to work it around by running:

bun i minimatch@latest

and amending package.json with

"overrides": {
    "minimatch": "$minimatch"
}

There are still warnings.
But at least I can build the project, while waiting for the proper fix in @serwist/next

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working triage New issues get this label, remove it after triage
Projects
None yet
Development

No branches or pull requests

5 participants