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

Build fails missing .nuxt/tsconfig.json #12074

Closed
Tracked by #4
gbicou opened this issue Oct 14, 2021 · 5 comments · Fixed by nuxt/framework#1161
Closed
Tracked by #4

Build fails missing .nuxt/tsconfig.json #12074

gbicou opened this issue Oct 14, 2021 · 5 comments · Fixed by nuxt/framework#1161

Comments

@gbicou
Copy link

gbicou commented Oct 14, 2021

Environment


  • Operating System: Linux
  • Node Version: v14.18.0
  • Nuxt Version: 3-3.0.0-27237303.6acfdcd
  • Package Manager: Yarn
  • Bundler: Webpack
  • User Config: -
  • Runtime Modules: -
  • Build Modules: -

Describe the bug

Build fails with a plugin and tsconfig.json extending generated .nuxt/tsconfig.json

Reproduction

Using a starter with tsconfig.json with :

{
  "extends": "./.nuxt/tsconfig.json"
}

And adding a simple plugins/test.ts :

import { defineNuxtPlugin } from '#app'
export default defineNuxtPlugin(nuxt => {})

Running yarn dev is OK, but yarn build fails

yarn run v1.22.15
$ nuxt build
Nuxt CLI v3.0.0-27237303.6acfdcd                                                                                              22:30:53
✔ Generated nuxt.d.ts                                                                                                         22:30:54

 ERROR  [vite:esbuild] failed to resolve "extends":"./.nuxt/tsconfig.json" in /home/bicou/tmp/nuxt3-app/tsconfig.json         22:30:55
file: /home/bicou/tmp/nuxt3-app/plugins/test.ts


 ERROR  failed to resolve "extends":"./.nuxt/tsconfig.json" in /home/bicou/tmp/nuxt3-app/tsconfig.json                        22:30:55

  at resolveExtends (node_modules/vite/dist/node/chunks/dep-713b45e1.js:22044:11)
  at parseExtends (node_modules/vite/dist/node/chunks/dep-713b45e1.js:22028:34)
  at parse$e (node_modules/vite/dist/node/chunks/dep-713b45e1.js:21979:24)
  at async loadTsconfigJsonForFile (node_modules/vite/dist/node/chunks/dep-713b45e1.js:22311:24)
  at async transformWithEsbuild (node_modules/vite/dist/node/chunks/dep-713b45e1.js:22157:36)
  at async Object.transform (node_modules/vite/dist/node/chunks/dep-713b45e1.js:22241:32)
  at async ModuleLoader.addModuleSource (node_modules/rollup/dist/shared/rollup.js:22105:30)
  at async ModuleLoader.fetchModule (node_modules/rollup/dist/shared/rollup.js:22158:9)
  at async Promise.all (index 2)
  at async ModuleLoader.fetchStaticDependencies (node_modules/rollup/dist/shared/rollup.js:22193:34)

error Command failed with exit code 1.

Additional context

Seems like build command load plugins before generating .nuxt/tsconfig.json ...

Logs

No response

@gbicou gbicou changed the title Build fails whit plugin Build fails with plugin Oct 14, 2021
@wobsoriano
Copy link
Member

wobsoriano commented Oct 15, 2021

Can confirm this. My nuxi info

- Operating System: `Darwin`
- Node Version:     `v16.3.0`
- Nuxt Version:     `3-3.0.0-27235989.d52b1e8`
- Package Manager:  `npm`
- Bundler:          `Webpack`
- User Config:      `-`
- Runtime Modules:  `-`
- Build Modules:    `-`

When running on dev, it creates all necessary files inside .nuxt folder (tsconfig.json included). Running build removes all files inside .nuxt

Edit:

  • Created a fresh app, build works
  • Added a page (index.vue and only template tag), build works
  • Added script tag to index.vue, build failed (looks for tsconfig.json)

@gbicou gbicou changed the title Build fails with plugin Build fails missing .nuxt/tsconfig.json Oct 15, 2021
@gbicou
Copy link
Author

gbicou commented Oct 15, 2021

Maybe ./tsconfig.nuxt.json will be a better location than ./.nuxt/tsconfig.json

@productdevbook
Copy link
Member

@pi0
Copy link
Member

pi0 commented Oct 18, 2021

Hi! This issue is pending for a fix on vite vitejs/vite#5309 to avoid resolving tsconfig. We might use a faster workaround too.

@posva
Copy link
Collaborator

posva commented Oct 18, 2021

This also happens when using lang="ts" on a component. For example, creating a base project with npx nuxi init nuxt3-app and then replacing the app.vue content with

<script setup lang="ts">
const msg = ref('Hello World!')
</script>

<template>
  <h1>{{ msg }}</h1>
  <input v-model="msg">
</template>

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

Successfully merging a pull request may close this issue.

7 participants