question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unable to use "tsconfig.json"'s "extends" key with yarn3

See original GitHub issue

Describe the bug

I’d like to extend a re-usable tsconfig.json (e.g, https://www.npmjs.com/package/@tsconfig/recommended). When adding the option "extends": "@tsconfig/recommended" to my tsconfig.json inside a Vite project (using vite’s react + ts starter) and running yarn build I get:

▲ [WARNING] Cannot find base config file "@tsconfig/recommended"

    tsconfig.json:2:13:
      2 │   "extends": "@tsconfig/recommended",
        ╵              ~~~~~~~~~~~~~~~~~~~~~~~

Reproduction

https://github.com/Alex-Yakubovsky/vite-error-repo

System Info

System:
    OS: macOS 12.2.1
    CPU: (10) arm64 Apple M1 Pro
    Memory: 163.77 MB / 16.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 16.14.2 - ~/.nvm/versions/node/v16.14.2/bin/node
    Yarn: 3.2.1 - ~/.nvm/versions/node/v16.14.2/bin/yarn
    npm: 8.9.0 - ~/.nvm/versions/node/v16.14.2/bin/npm
  Browsers:
    Chrome: 101.0.4951.64
    Safari: 15.3

Used Package Manager

yarn

Logs

▲ [WARNING] Cannot find base config file "@tsconfig/recommended"

    tsconfig.json:2:13:
      2 │   "extends": "@tsconfig/recommended",
        ╵              ~~~~~~~~~~~~~~~~~~~~~~~

  vite:config bundled config file loaded in 97.90ms +0ms
  vite:config using resolved config: {
  vite:config   plugins: [
  vite:config     'vite:build-metadata',
  vite:config     'alias',
  vite:config     'vite:react-babel',
  vite:config     'vite:react-refresh',
  vite:config     'vite:react-jsx',
  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',
  vite:config     'vite:worker',
  vite:config     'vite:asset',
  vite:config     'vite:define',
  vite:config     'vite:css-post',
  vite:config     'vite:build-html',
  vite:config     'vite:worker-import-meta-url',
  vite:config     'vite:watch-package-data',
  vite:config     'commonjs',
  vite:config     'vite:data-uri',
  vite:config     'rollup-plugin-dynamic-import-variables',
  vite:config     'vite:asset-import-meta-url',
  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: [ 'es2019', 'edge88', 'firefox78', 'chrome87', 'safari13.1' ],
  vite:config     polyfillModulePreload: true,
  vite:config     outDir: 'dist',
  vite:config     assetsDir: 'assets',
  vite:config     assetsInlineLimit: 4096,
  vite:config     cssCodeSplit: true,
  vite:config     cssTarget: [ 'es2019', 'edge88', 'firefox78', 'chrome87', 'safari13.1' ],
  vite:config     sourcemap: false,
  vite:config     rollupOptions: {},
  vite:config     minify: 'esbuild',
  vite:config     terserOptions: {},
  vite:config     write: true,
  vite:config     emptyOutDir: null,
  vite:config     manifest: false,
  vite:config     lib: false,
  vite:config     ssr: false,
  vite:config     ssrManifest: 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   },
  vite:config   resolve: { dedupe: [ 'react', 'react-dom' ], alias: [ [Object], [Object] ] },
  vite:config   optimizeDeps: {
  vite:config     include: [ 'react/jsx-dev-runtime' ],
  vite:config     esbuildOptions: { keepNames: undefined, preserveSymlinks: undefined }
  vite:config   },
  vite:config   configFile: '/Users/alexanderyakubovsky/test-vite/test/vite.config.ts',
  vite:config   configFileDependencies: [ '/Users/alexanderyakubovsky/test-vite/test/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: '/Users/alexanderyakubovsky/test-vite/test',
  vite:config   base: '/',
  vite:config   publicDir: '/Users/alexanderyakubovsky/test-vite/test/public',
  vite:config   cacheDir: '/Users/alexanderyakubovsky/test-vite/test/node_modules/.vite',
  vite:config   command: 'build',
  vite:config   mode: 'production',
  vite:config   isWorker: false,
  vite:config   isProduction: true,
  vite:config   server: {
  vite:config     preTransformRequests: true,
  vite:config     fs: { strict: true, allow: [Array], deny: [Array] }
  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   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(0) { set: [Function (anonymous)] },
  vite:config   createResolver: [Function: createResolver],
  vite:config   worker: {
  vite:config     format: 'iife',
  vite:config     plugins: [
  vite:config       [Object], [Object], [Object],
  vite:config       [Object], [Object], [Object],
  vite:config       [Object], [Object], [Object],
  vite:config       [Object], [Object], [Object],
  vite:config       [Object], [Object], [Object],
  vite:config       [Object], [Object], [Object],
  vite:config       [Object], [Object], [Object],
  vite:config       [Object], [Object], [Object],
  vite:config       [Object]
  vite:config     ],
  vite:config     rollupOptions: {}
  vite:config   }
  vite:config } +5ms
vite v2.9.9 building for production...
✓ 34 modules transformed.
dist/assets/favicon.17e50649.svg   1.49 KiB
dist/assets/logo.ecc203fb.svg      2.61 KiB
dist/index.html                    0.46 KiB
dist/assets/index.62f502b0.css     0.75 KiB / gzip: 0.48 KiB
dist/assets/index.2b0e2339.js      140.35 KiB / gzip: 45.10 KiB

Validations

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:1
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

3reactions
swandircommented, Jun 27, 2022

The warning is about the tsconfig for local files, not optimized dependencies. So neither optimizeDeps config option nor optimizer changes are related.

Local files are processed by vite:esbuild plugin here.

Vite loads tsconfigs itself and passes compilerOptions to esbuild.transform.

However, for vite.config.ts Vite uses esbuild.build directly, which means that ESBuild has to locate tsconfigs on its own — and fails in case of Yarn PnP.

So the warning actually is purely about vite.config.ts bundling, and does not affect application code.

Note that adding esbuild-plugin-pnp here won’t help. ESBuild Plugin API does not allow customization of tsconfig loading. The only possible fix on Vite side for now is to use the same approach that the main bundling process uses — that is, use ESBuild transform API and load tsconfigs beforehand.

Here’s a suggestion for adding config loading customization via plugin API I’ve submitted in ESBuild repo some time ago https://github.com/evanw/esbuild/issues/2095

0reactions
jonaskuskecommented, Aug 10, 2022

esbuild just added support for PnP with version 0.15.0: https://github.com/evanw/esbuild/releases/tag/v0.15.0! However, when I force vite to use esbuild@0.15.0 via package.json#resolutions, I still see the warning. 🤔

Read more comments on GitHub >

github_iconTop Results From Across the Web

tsconfig-paths | Yarn - Package Manager
Use this to load modules whose location is specified in the paths section of tsconfig.json or jsconfig.json . Both loading at run-time and...
Read more >
TSConfig Reference - Docs on every TSConfig option
Extends - extends. The value of extends is a string which contains a path to another configuration file to inherit from. The path...
Read more >
How can I generate a tsconfig.json file? - Stack Overflow
json via the command line? I tried command tsc init , but this doesn't work. typescript.
Read more >
Configuring TypeScript for multiple packages in a Lerna + ...
In this article I will be showing you how to leverage the power of Lerna and yarn workspaces in a TypeScript project to...
Read more >
TypeScript errors and how to fix them
Add an import, export, or an empty 'export {}' statement to make it a module. Broken Code ❌. tsconfig.json. 1 2 3
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found