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

Don't bundle declarations due to typescript version #402

Open
3 tasks done
crystalfp opened this issue Dec 23, 2024 · 4 comments
Open
3 tasks done

Don't bundle declarations due to typescript version #402

crystalfp opened this issue Dec 23, 2024 · 4 comments
Labels
upstream Something about upstream packages

Comments

@crystalfp
Copy link

Describe the bug

Running npx vite build with the following options for the plugin:

		dts({
		  tsconfigPath: './tsconfig.json',
		  rollupTypes: true,
		  entryRoot: 'src',
		}),

at the end gives the following error:

[vite:dts] Start rollup declaration files...
Analysis will use the bundled TypeScript version 5.4.2
*** The target project appears to use TypeScript 5.7.2 which is newer than the bundled compiler engine; consider upgrading API Extractor.
[vite:dts] Declaration files built in 9900ms.

And the bundled declaration file appears nowhere in the project.
I installed the current version of @microsoft/api-extractor but nothing changes.

Reproduction

none

Steps to reproduce

Besides providing the full application, I don't know how to create a minimal reproduction.

System Info

System:
    OS: Windows 11 10.0.26100
    CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
    Memory: 12.66 GB / 31.77 GB
  Binaries:
    Node: 23.4.0 - C:\Program Files\nodejs\node.EXE
    npm: 11.0.0 - ~\AppData\Roaming\npm\npm.CMD
  Browsers:
    Chrome: 131.0.6778.205
    Edge: Chromium (130.0.2849.80)
    Internet Explorer: 11.0.26100.1882
  npmPackages:
    @vitejs/plugin-vue: ^5.2.1 => 5.2.1
    vite: ^6.0.5 => 6.0.5
    vite-plugin-dts: ^4.4.0 => 4.4.0

Validations

@qmhc qmhc added the upstream Something about upstream packages label Jan 10, 2025
@qmhc
Copy link
Owner

qmhc commented Jan 10, 2025

Could you try v4.5.0?

@crystalfp
Copy link
Author

Tried 4.5.0 but no success.
Running npm run build gives the usual output with two additions:

[vite:dts] You are building a library that may not need to generate declaration files.

and then:

[vite:dts] Start generate declaration files...
. . . The usual dist/assets generation . . .
[vite:dts] Outside emitted: D:/Projects/STMng/vite.config.d.mts
[vite:dts] Start rollup declaration files...
Analysis will use the bundled TypeScript version 5.7.2
[vite:dts] Declaration files built in 9048ms.

But again I have a small declaration file under dist/ for a single source file. and no sign of vite.config.d.mts
Here is vite.config.mts:

import {defineConfig} from "vite";
import electron from "vite-plugin-electron";
import renderer from "vite-plugin-electron-renderer";
import vueDevTools from "vite-plugin-vue-devtools";
import vue from "@vitejs/plugin-vue";
import {fileURLToPath, URL} from 'node:url';
import dts from "vite-plugin-dts";

// https://vitejs.dev/config/
/** @type {import('vite').UserConfig} */
export default defineConfig({
    resolve: {
        alias: {
            "@": fileURLToPath(new URL('./src', import.meta.url))
        },
        preserveSymlinks: true
    },
    optimizeDeps: {
        exclude: ["doc", "release", "save", "others", "bugs", "test-data"],
        holdUntilCrawlEnd: false
    },
    define: {
        __VUE_PROD_DEVTOOLS__: "false",
    },
    plugins: [
        dts({
            tsconfigPath: './tsconfig.json',
            rollupTypes: true,
            entryRoot: 'src',
        }),
        vue(),
        electron([
            {
                // Main-Process entry file of the Electron App.
                entry: "src/electron/main.ts",
            },
            {
                entry: "src/electron/preload.ts",
                onstart(options): void {
                    // Notify the Renderer-Process to reload the page when the Preload-Scripts build
                    // is complete, instead of restarting the entire Electron App.
                    options.reload();
                },
            },
        ]),
        renderer(),
        vueDevTools(),
    ],
    build: {
        assetsInlineLimit: 8096,
        reportCompressedSize: false,
        emptyOutDir: true,
        chunkSizeWarningLimit: 600,
        rollupOptions: {
            output: {
                manualChunks: {
                    vue: [
                        "vue",
                        "vue-router",
                        "pinia",
                        "vuetify",
                        "@mdi/js",
                    ],
                    three: [
                        "three"
                    ],
                    troika: [
                        "troika-three-text"
                    ]
                }
            },
        }
    },
});

Thanks for your help!

@qmhc
Copy link
Owner

qmhc commented Jan 10, 2025

Could you also provide your ./tsconfig.json file?

@crystalfp
Copy link
Author

Here is my tsconfig.json file

{
  "compilerOptions": {
    "target": "ESNext",
    "module": "Preserve",
    "skipLibCheck": true,
    "verbatimModuleSyntax": true,
    "noErrorTruncation": true,
    "esModuleInterop": true,
    "composite": true,
    "allowSyntheticDefaultImports": true,
    "useUnknownInCatchVariables": true,
    "useDefineForClassFields": true,
    "moduleDetection": "force",

    /* Bundler mode */
    "moduleResolution": "bundler",
    "allowImportingTsExtensions": true,
    "resolveJsonModule": true,
    "isolatedModules": true,
    "isolatedDeclarations": false,
    "noEmit": true,
    "jsx": "preserve",
    "removeComments": true,

    /* Linting */
    "strict": true,
    "noUnusedLocals": true,
    "noUnusedParameters": true,
    "noFallthroughCasesInSwitch": true,
    "noImplicitReturns": true,
    "noImplicitOverride": true,
    "allowUnreachableCode": false,

    "baseUrl": ".",
    "paths": {
      "@/*": ["src/*"]
    },
  },
  "include": [
    "vite.config.mts",
    "troika-three-text.d.ts",
    "src/**/*.ts",
    "src/**/*.vue",
    "package.json"
  ]
}

It is a Vite+Vue+Electron project, so it has noEmit set to true.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
upstream Something about upstream packages
Projects
None yet
Development

No branches or pull requests

2 participants