Skip to content
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

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

Closed
1 of 4 tasks
zivattias opened this issue Mar 7, 2024 · 1 comment · Fixed by #22614
Closed
1 of 4 tasks

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

zivattias opened this issue Mar 7, 2024 · 1 comment · Fixed by #22614
Assignees
Labels
outdated scope: bundlers Issues related to webpack, rollup type: bug

Comments

@zivattias
Copy link

zivattias commented Mar 7, 2024

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

@zivattias zivattias 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 Mar 7, 2024
@FrozenPandaz FrozenPandaz added the scope: bundlers Issues related to webpack, rollup label Mar 15, 2024
Copy link

github-actions bot commented May 3, 2024

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 3, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
outdated scope: bundlers Issues related to webpack, rollup type: bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants