next.js/packages/next/src/build/webpack/loaders/next-invalid-import-error-loader.ts
next-invalid-import-error-loader.ts19 lines655 B
import type webpack from 'webpack'

export type InvalidImportLoaderOpts = { message: string }

const nextInvalidImportErrorLoader: webpack.LoaderDefinitionFunction<InvalidImportLoaderOpts> =
  function () {
    const { message } = this.getOptions()
    const error = new Error(message)
    if (process.env.NEXT_RSPACK) {
      // Rspack uses miette for error formatting, which automatically includes stack
      // traces in the error message. To avoid showing redundant stack information
      // in the final error output, we clear the stack property.
      error.stack = undefined
    }
    throw error
  }

export default nextInvalidImportErrorLoader
Quest for Codev2.0.0
/
SIGN IN