Skip to content

Can't use this library with Next.js using a next.config.mjs file #140

Open
@RobotSail

Description

@RobotSail

I'm trying to use this with a next.config.mjs file and am probably using this incorrectly. The issue I'm running into is that there is no place for me to pass my existing NextConfig as an argument into removeImports, since the signature looks like:

declare type PluginOptions = {
    test?: RegExp;
    matchImports?: string;
};
declare const _default: (pluginOptions?: PluginOptions) => (nextConfig?: NextConfig) => NextConfig;

I've tried instead to merge the output from removeImports with my initialized config, but that didn't seem to have any effect:

// @ts-check

import removeImports from 'next-remove-imports'

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


/** @type {import("next").NextConfig} */
const config = {
  reactStrictMode: true,

  /**
   * If you have the "experimental: { appDir: true }" setting enabled, then you
   * must comment the below `i18n` config out.
   *
   * @see https://github.com/vercel/next.js/issues/41980
   */
  i18n: {
    locales: ["en"],
    defaultLocale: "en",
  },
	...removeImports(),
};
export default config;

This must be the case of me doing something incorrectly, but it's blocking my ability to use this package.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions