Next.js Discord

Discord Forum

Next 14.1+ Compile Error with export enum

Unanswered
Brewer's Blackbird posted this in #help-forum
Open in Discord
Brewer's BlackbirdOP
We're wanting to upgrade from 14.0.x to the latest, we are encountering the following SWC errors during the process. This happens on next@latest and next canary releases, but is fine on 14.0.x which we are currently on.

Failed to compile.
./node_modules/duck-duck-scrape/src/util.ts
Module parse failed: Unexpected token (9:7)
File was processed with these loaders:
* ./node_modules/next/dist/build/webpack/loaders/next-flight-loader/index.js
* ./node_modules/next/dist/build/webpack/loaders/next-swc-loader.js
You may need an additional loader to handle the result of these loaders.


The error originates from the duck-duck-scrape library and seems to be related to the handling of enums in TypeScript. I modified the library and removed the @internal decorators earlier in the file, and the error changed line but was pointing to the same line:


import needle, { NeedleOptions } from 'needle';

/** @internal */
export const SPICE_BASE = 'https://duckduckgo.com/js/spice';
/** @internal */
export const VQD_REGEX = /vqd=['"](\d+-\d+(?:-\d+)?)['"]/;

/** The safe search values when searching DuckDuckGo. */
export enum SafeSearchType { // <<<<<< Errors here.
  /** Strict filtering, no NSFW content. */
  STRICT = 0,
  /** Moderate filtering. */
  MODERATE = -1,
  /** No filtering. */
  OFF = -2
}

Any ideas about how to solve it? Happy to post to github but thought it might be best to try here first.
I dont want to move to babel, as we use next/font heavily and from what I read during build output this cant work with babel.

3 Replies

Brewer's BlackbirdOP
Just bumping this in case anyone has any ideas how to solve the above.
Brewer's BlackbirdOP
Any ideas why the export enum SafeSearchType would cause next 14.1+ to fail but not next 14.0.x?
this is likely a next bug or a swc bug, do make a bug report