Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Build error on other workspace typescript packages in Nodejs middleware #75840

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

Open
IncognitoTGT opened this issue Feb 9, 2025 · 2 comments
Open
Labels
Middleware Related to Next.js Middleware.

Comments

@IncognitoTGT
Copy link
Contributor

Link to the code that reproduces this issue

https://github.com/spaceness/stardust/tree/nextjs-canary/apps/web

To Reproduce

  1. Start the application in development or attempt a build (no need to setup anything)
  2. See the logs in the console:
Failed to compile.

../../packages/common/auth/index.ts
Module parse failed: Unexpected token (4:14)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
| import db from "@stardust/db";
| import * as authSchema from "@stardust/db/schema/auth";
> import { type BetterAuthPlugin, betterAuth } from "better-auth";
| import { drizzleAdapter } from "better-auth/adapters/drizzle";
| import { nextCookies } from "better-auth/next-js";

Import trace for requested module:
../../packages/common/auth/index.ts


> Build failed because of webpack errors

4:14 is the end of the type keyword.

I tried using ts-loader, which works (showing it's due to .ts) but I wasn't sure if it would interfere with the normal compilation process, and another webpack loader shouldn't be required for this.

Current vs. Expected behavior

Following the steps from the previous section, I expected the middleware to build, but instead it failed.

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 24.1.0: Thu Oct 10 21:02:45 PDT 2024; root:xnu-11215.41.3~2/RELEASE_ARM64_T8112
  Available memory (MB): 24576
  Available CPU cores: 8
Binaries:
  Node: 22.10.0
  npm: 10.9.0
  Yarn: 1.22.19
  pnpm: 9.4.0
Relevant Packages:
  next: 15.2.0-canary.47 // Latest available version is detected (15.2.0-canary.47).
  eslint-config-next: N/A
  react: 19.0.0-rc-66855b96-20241106
  react-dom: 19.0.0-rc-66855b96-20241106
  typescript: 5.5.4
Next.js Config:
  output: N/A

Which area(s) are affected? (Select all that apply)

Middleware

Which stage(s) are affected? (Select all that apply)

next build (local)

Additional context

I tested my app on 15.2.0-canary-47. NodeJS middleware support was introduced in .40, and there weren't any changes relating to normal SSR middleware since that release.

@github-actions github-actions bot added the Middleware Related to Next.js Middleware. label Feb 9, 2025
@samdenty
Copy link
Member

this is because it's inside node_modules

@samdenty
Copy link
Member

samdenty commented Apr 30, 2025

This option fixes it:

const shouldIncludeExternalDirs =
config.experimental.externalDir || !!config.transpilePackages

#26420

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

No branches or pull requests

2 participants