vitejs / vite

Next generation frontend tooling. It's fast!
http://vitejs.dev
MIT License
67.35k stars 6.06k forks source link

Referenced Project May Not Disable Emit #18139

Open brendanmatkin opened 4 days ago

brendanmatkin commented 4 days ago

Describe the bug

With a brand new svelte-ts app created using create-vite, the tsconfig.json file shows an error at "references": [{ "path": "./tsconfig.node.json" }]: Referenced project '<path to app>/tsconfig.node.json' may not disable emit.ts

The change is relatively recent: https://github.com/vitejs/vite/commit/cf3f40cd383509fdb1294568fb38bacfac419ea1

Possibly the correct setting is emitDeclarationOnly instead of noEmit (tsc maybe depends on the .d.ts files of the referenced project to split up the work, and noEmit prevents those from being created? As per this discussion). The error goes away with emitDeclarationOnly: true, but does that mean tsc is doing extra work that esbuild is already handling?

pnpm build and pnpm check succeed, it's just an annoying error (but maybe is indicative of some type checking actually not happening correctly?). Maybe it is actually a VSCode error?

Reproduction

https://stackblitz.com/edit/vitejs-vite-vrcca7?file=tsconfig.json

Steps to reproduce

pnpm create vite my-app
cd my-app
pnpm install

Then open in VSCode, and look at tsconfig.json. It should have a red squiggle on line 20.

OR run npx tsc

If you change line 9 of tsconfig.node.json from "noEmit": true to "emitDeclarationOnly": true and save, the error goes away (but maybe this setting is undesirable?).

If I do everything again with npm, the result is the same.

NOTE: the error doesn't show in the editor in stackblitz using npm or pnpm, but it does if you run npx tsc!

System Info

System:
    OS: macOS 14.6.1
    CPU: (8) arm64 Apple M1 Pro
    Memory: 82.58 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 20.11.1 - ~/.asdf/installs/nodejs/20.11.1/bin/node
    npm: 10.8.1 - ~/.asdf/plugins/nodejs/shims/npm
    pnpm: 8.15.5 - ~/.asdf/installs/nodejs/20.11.1/bin/pnpm
    bun: 1.1.0 - ~/.bun/bin/bun
  Browsers:
    Chrome: 128.0.6613.138
    Edge: 128.0.2739.79
    Safari: 17.6
  npmPackages:
    vite: ^5.4.1 => 5.4.6 

Others:
  vscode: 1.93.1
  typescript that vs code is using: 5.5.4

Used Package Manager

pnpm

Logs

Click to expand! ```shell vite:config bundled config file loaded in 275.26ms +0ms vite:config using resolved config: { vite:config plugins: [ vite:config 'vite:build-metadata', vite:config 'vite:watch-package-data', vite:config 'vite:pre-alias', vite:config 'alias', vite:config 'vite-plugin-svelte', vite:config 'vite:modulepreload-polyfill', vite:config 'vite:resolve', vite:config 'vite:html-inline-proxy', vite:config 'vite:css', vite:config 'vite:esbuild', vite:config 'vite:json', vite:config 'vite:wasm-helper', vite:config 'vite:worker', vite:config 'vite:asset', vite:config 'vite:wasm-fallback', vite:config 'vite:define', vite:config 'vite:css-post', vite:config 'vite:build-html', vite:config 'vite:worker-import-meta-url', vite:config 'vite:asset-import-meta-url', vite:config 'vite:force-systemjs-wrap-complete', vite:config 'commonjs', vite:config 'vite:data-uri', vite:config 'vite:dynamic-import-vars', vite:config 'vite:import-glob', vite:config 'vite:build-import-analysis', vite:config 'vite:esbuild-transpile', vite:config 'vite:terser', vite:config 'vite:reporter', vite:config 'vite:load-fallback' vite:config ], vite:config build: { vite:config target: [ 'es2020', 'edge88', 'firefox78', 'chrome87', 'safari14' ], vite:config cssTarget: [ 'es2020', 'edge88', 'firefox78', 'chrome87', 'safari14' ], vite:config outDir: 'dist', vite:config assetsDir: 'assets', vite:config assetsInlineLimit: 4096, vite:config cssCodeSplit: true, vite:config sourcemap: false, vite:config rollupOptions: {}, vite:config minify: 'esbuild', vite:config terserOptions: {}, vite:config write: true, vite:config emptyOutDir: null, vite:config copyPublicDir: true, vite:config manifest: false, vite:config lib: false, vite:config ssr: false, vite:config ssrManifest: false, vite:config ssrEmitAssets: false, vite:config reportCompressedSize: true, vite:config chunkSizeWarningLimit: 500, vite:config watch: null, vite:config commonjsOptions: { include: [Array], extensions: [Array] }, vite:config dynamicImportVarsOptions: { warnOnError: true, exclude: [Array] }, vite:config modulePreload: { polyfill: true }, vite:config cssMinify: true vite:config }, vite:config resolve: { vite:config mainFields: [ 'svelte', 'browser', 'module', 'jsnext:main', 'jsnext' ], vite:config conditions: [ 'svelte' ], vite:config extensions: [ vite:config '.mjs', '.js', vite:config '.mts', '.ts', vite:config '.jsx', '.tsx', vite:config '.json' vite:config ], vite:config dedupe: [ vite:config 'svelte/animate', vite:config 'svelte/easing', vite:config 'svelte/internal', vite:config 'svelte/internal/disclose-version', vite:config 'svelte/motion', vite:config 'svelte/ssr', vite:config 'svelte/store', vite:config 'svelte/transition', vite:config 'svelte', vite:config 'svelte-hmr/runtime/hot-api-esm.js', vite:config 'svelte-hmr/runtime/proxy-adapter-dom.js', vite:config 'svelte-hmr' vite:config ], vite:config preserveSymlinks: false, vite:config alias: [ [Object], [Object] ] vite:config }, vite:config optimizeDeps: { vite:config holdUntilCrawlEnd: true, vite:config include: [ vite:config 'svelte/animate', vite:config 'svelte/easing', vite:config 'svelte/internal', vite:config 'svelte/internal/disclose-version', vite:config 'svelte/motion', vite:config 'svelte/store', vite:config 'svelte/transition', vite:config 'svelte' vite:config ], vite:config exclude: [ 'svelte-hmr' ], vite:config esbuildOptions: { preserveSymlinks: false } vite:config }, vite:config ssr: { vite:config target: 'node', vite:config external: [], vite:config noExternal: [ 'svelte', /^svelte\// ], vite:config optimizeDeps: { noDiscovery: true, esbuildOptions: [Object] } vite:config }, vite:config experimental: { importGlobRestoreExtension: false, hmrPartialAccept: true }, vite:config configFile: '/my-app/vite.config.ts', vite:config configFileDependencies: [ '/my-app/vite.config.ts' ], vite:config inlineConfig: { vite:config root: undefined, vite:config base: undefined, vite:config mode: undefined, vite:config configFile: undefined, vite:config logLevel: undefined, vite:config clearScreen: undefined, vite:config build: {} vite:config }, vite:config root: '/my-app', vite:config base: '/', vite:config decodedBase: '/', vite:config rawBase: '/', vite:config publicDir: '/my-app/public', vite:config cacheDir: '/my-app/node_modules/.vite', vite:config command: 'build', vite:config mode: 'production', vite:config isWorker: false, vite:config mainConfig: null, vite:config bundleChain: [], vite:config isProduction: true, vite:config css: { lightningcss: undefined }, vite:config esbuild: { jsxDev: false }, vite:config server: { vite:config preTransformRequests: true, vite:config sourcemapIgnoreList: [Function: isInNodeModules$1], vite:config middlewareMode: false, vite:config fs: { vite:config strict: true, vite:config allow: [Array], vite:config deny: [Array], vite:config cachedChecks: undefined vite:config } vite:config }, vite:config preview: { vite:config port: undefined, vite:config strictPort: undefined, vite:config host: undefined, vite:config https: undefined, vite:config open: undefined, vite:config proxy: undefined, vite:config cors: undefined, vite:config headers: undefined vite:config }, vite:config envDir: '/my-app', vite:config env: { BASE_URL: '/', MODE: 'production', DEV: false, PROD: true }, vite:config assetsInclude: [Function: assetsInclude], vite:config logger: { vite:config hasWarned: false, vite:config info: [Function: info], vite:config warn: [Function: warn], vite:config warnOnce: [Function: warnOnce], vite:config error: [Function: error], vite:config clearScreen: [Function: clearScreen], vite:config hasErrorLogged: [Function: hasErrorLogged] vite:config }, vite:config packageCache: Map(1) { vite:config 'fnpd_/my-app' => { vite:config dir: '/my-app', vite:config data: [Object], vite:config hasSideEffects: [Function: hasSideEffects], vite:config webResolvedImports: {}, vite:config nodeResolvedImports: {}, vite:config setResolvedCache: [Function: setResolvedCache], vite:config getResolvedCache: [Function: getResolvedCache] vite:config }, vite:config set: [Function (anonymous)] vite:config }, vite:config createResolver: [Function: createResolver], vite:config worker: { format: 'iife', plugins: '() => plugins', rollupOptions: {} }, vite:config appType: 'spa', vite:config getSortedPlugins: [Function: getSortedPlugins], vite:config getSortedPluginHooks: [Function: getSortedPluginHooks] vite:config } +29ms vite v5.4.6 building for production... ✓ 32 modules transformed. dist/index.html 0.46 kB │ gzip: 0.30 kB dist/assets/index-DDqFzPXY.css 1.27 kB │ gzip: 0.63 kB dist/assets/index-D0Ffin-u.js 8.08 kB │ gzip: 3.69 kB ✓ built in 177ms ```

Validations

stackblitz[bot] commented 4 days ago

Fix this issue in StackBlitz Codeflow Start a new pull request in StackBlitz Codeflow.