Skip to content

Deprecated vite.config.ts for a @nx/js:lib generated w/ --bundler=viteย #22199

Closed

Description

@zivattias

Current Behavior

In a generated vite.config.ts file of a JS library, generated with --bundler=vite, dts is called with deprecated/renamed parameters - skipDiagnostics & tsConfigFilePath.

Here is the generated Vite config file:

/// <reference types='vitest' />
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
import dts from "vite-plugin-dts";
import * as path from "path";
import { nxViteTsPaths } from "@nx/vite/plugins/nx-tsconfig-paths.plugin";

export default defineConfig({
  root: __dirname,
  cacheDir: "../../../node_modules/.vite/libs/ui-kit/ui",

  plugins: [
    react(),
    nxViteTsPaths(),
    dts({
      entryRoot: "src",
      tsConfigFilePath: path.join(__dirname, "tsconfig.lib.json"),
      skipDiagnostics: true,
    }),
  ],

  // Uncomment this if you are using workers.
  // worker: {
  //  plugins: [ nxViteTsPaths() ],
  // },

  // Configuration for building your library.
  // See: https://vitejs.dev/guide/build.html#library-mode
  build: {
    outDir: "../../../dist/libs/ui-kit/ui",
    reportCompressedSize: true,
    commonjsOptions: {
      transformMixedEsModules: true,
    },
    lib: {
      // Could also be a dictionary or array of multiple entry points.
      entry: "src/index.ts",
      name: "ui-kit-ui",
      fileName: "index",
      // Change this to the formats you want to support.
      // Don't forget to update your package.json as well.
      formats: ["es", "cjs"],
    },
    rollupOptions: {
      // External packages that should not be bundled into your library.
      external: ["react", "react-dom", "react/jsx-runtime"],
    },
  },
});

Expected Behavior

The generated vite.config.ts file should not include skipDiagnostics and tsConfigFilePath should be renamed to tsconfigPath (breaking changes since 3.0.0-beta.2 (2023-06-27)).

GitHub Repo

https://github.com/nrwl/nx-examples

Steps to Reproduce

  1. Run npx nx g @nx/js:lib mylib and choose vite as bundler.
  2. Review broken vite.config.ts.

Nx Report

Node   : 18.17.0
OS     : win32-x64
pnpm   : 8.15.4

nx (global)        : 18.0.5
nx                 : 18.0.5
@nx/js             : 18.0.5
@nx/eslint         : 18.0.5
@nx/workspace      : 18.0.5
@nx/eslint-plugin  : 18.0.5
@nx/react          : 18.0.5
@nx/vite           : 18.0.5
@nx/web            : 18.0.5
typescript         : 5.3.3

Failure Logs

/// <reference types='vitest' />
import { defineConfig } from "vite";
import dts from "vite-plugin-dts";
import * as path from "path";
import { nxViteTsPaths } from "@nx/vite/plugins/nx-tsconfig-paths.plugin";

export default defineConfig({
  root: __dirname,
  cacheDir: "../../node_modules/.vite/libs/test-lib",

  plugins: [
    nxViteTsPaths(),
    dts({
      entryRoot: "src",
      tsConfigFilePath: path.join(__dirname, "tsconfig.lib.json"),
      skipDiagnostics: true,
    }),
  ],

  // Uncomment this if you are using workers.
  // worker: {
  //  plugins: [ nxViteTsPaths() ],
  // },

  // Configuration for building your library.
  // See: https://vitejs.dev/guide/build.html#library-mode
  build: {
    outDir: "../../dist/libs/test-lib",
    reportCompressedSize: true,
    commonjsOptions: {
      transformMixedEsModules: true,
    },
    lib: {
      // Could also be a dictionary or array of multiple entry points.
      entry: "src/index.ts",
      name: "test-lib",
      fileName: "index",
      // Change this to the formats you want to support.
      // Don't forget to update your package.json as well.
      formats: ["es", "cjs"],
    },
    rollupOptions: {
      // External packages that should not be bundled into your library.
      external: [],
    },
  },
});

Package Manager Version

pnpm v8.15.4

Operating System

  • macOS
  • Linux
  • Windows
  • Other (Please specify)

Additional Information

No response

Activity

  1. changed the title [-]Outdated vite.config.ts for a @nx/js:lib generated w/ --bundler=vite[/-] [+]Deprecated vite.config.ts for a @nx/js:lib generated w/ --bundler=vite[/+] on Mar 7, 2024
  2. github-actions commented on May 3, 2024

    @github-actions
    Contributor

    This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context.

  3. locked as resolved and limited conversation to collaborators on May 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions