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

feat: externalize typescript support #5858

Merged
merged 27 commits into from
Jul 24, 2019
Merged

Conversation

kevinmarrec
Copy link
Contributor

@kevinmarrec kevinmarrec commented Jun 3, 2019

Types of changes

  • Bug fix (a non-breaking change which fixes an issue)
  • New feature (a non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Description

External repo : https://github.com/nuxt/typescript

TODO before ready

  • Refactor core to be able to externalize TypeScript Support implementation (refactor: prepare for external typescript support #5854)
  • Merge the refactor in dev & merge dev into the branch related to this PR
  • Implement TypeScript support in external repo
  • Write new tests in external repo
  • Move and update examples in external repo
  • Publish new @nuxt/typescript-build, @nuxt/typescript-runtime & @nuxt/types packages
  • Prepare docs for migration (https://github.com/nuxt/typescript/docs)

Notes for Nuxt 2.9 migration

TypeScript support has been externalized in dedicated packages and have been removed from core starting Nuxt 2.9. Here are the guidelines to migrate your existing Nuxt TypeScript project to 2.9 without any trouble.

The following migration guide works for either nuxt or nuxt-edge.

1) Migrate dependencies

yarn remove @nuxt/typescript
yarn add -D @nuxt/typescript-build @nuxt/types

Use npm uninstall and npm install -D instead if you're using npm

2) Replace @nuxt/vue-app and @nuxt/config by @nuxt/types in your tsconfig.json

// tsconfig.json

"compilerOptions": {
  "types": [
     "@nuxt/types"
  ]
}

If you were importing types from @nuxt/config you need to instead import them from @nuxt/types. Types imports might have changed a little, you can get familiar with them either by triggering intellisense when importing or watch them live here now.

3) Add @nuxt/typescript-build module to your nuxt.config.js

// nuxt.config.js

export default {
  modules: ['@nuxt/typescript-build']
}

4) Move the customized options from build.typescript to module options

// nuxt.config.js

export default {
  typescript: {
    typeCheck: true,
    ignoreNotFoundWarnings: true
  }
}

You can also do it this way :

// nuxt.config.js

export default {
  modules: [
    ['@nuxt/typescript-build', {
      typeCheck: true,
      ignoreNotFoundWarnings: true
    }]
  ]
}

5) [Optional] TypeScript runtime

Install @nuxt/typescript-runtime and use nuxt-ts (or nuxts alias) command instead of nuxt/nuxt-edge to have TypeScript runtime and be able to use TypeScript in files executed at runtime such as configuration (nuxt.config.ts), modules and serverMiddlewares.

yarn add @nuxt/typescript-runtime
// package.json

"scripts": {
  "dev": "nuxt-ts",
  "build": "nuxt-ts build",
  "start": "nuxt-ts start"
  "generate": "nuxt-ts generate"
}

This migration guide & new project guide will be available on https://typescript.nuxtjs.org when the new dedicated documentation will be published. You'll also be able to find the main reasons why we went this way and we're also planning to write a post about the journey of the TypeScript support of Nuxt, from the oldest implementation to now.

Checklist:

  • My change requires a change to the documentation.
  • I have updated the documentation accordingly. (PR: #)
  • I have updated tests to cover my changes (if not applicable, please state why)
  • All new and existing tests are passing.

@codecov-io
Copy link

codecov-io commented Jun 5, 2019

Codecov Report

Merging #5858 into dev will increase coverage by 0.07%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##              dev    #5858      +/-   ##
==========================================
+ Coverage   95.65%   95.73%   +0.07%     
==========================================
  Files          82       80       -2     
  Lines        2695     2651      -44     
  Branches      693      678      -15     
==========================================
- Hits         2578     2538      -40     
+ Misses         99       97       -2     
+ Partials       18       16       -2
Flag Coverage Δ
#e2e 100% <ø> (ø) ⬆️
#fixtures 50.81% <75%> (+0.71%) ⬆️
#unit 92.41% <100%> (-0.39%) ⬇️
Impacted Files Coverage Δ
packages/cli/src/utils/banner.js 100% <ø> (+5.26%) ⬆️
packages/cli/src/imports.js 100% <ø> (ø) ⬆️
packages/utils/src/route.js 100% <ø> (ø) ⬆️
packages/webpack/src/config/base.js 94.73% <ø> (-0.22%) ⬇️
packages/config/src/config/build.js 100% <ø> (ø) ⬆️
packages/cli/src/command.js 98.96% <ø> (-0.03%) ⬇️
packages/webpack/src/config/client.js 98.07% <100%> (-0.11%) ⬇️
packages/cli/src/utils/config.js 96.66% <100%> (+2.91%) ⬆️
packages/config/src/options.js 100% <100%> (ø) ⬆️
packages/builder/src/builder.js 99.6% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b73115e...3a7b0cc. Read the comment docs.

@kevinmarrec kevinmarrec marked this pull request as ready for review July 6, 2019 22:00
@kevinmarrec kevinmarrec requested a review from a team July 6, 2019 22:00
@kevinmarrec
Copy link
Contributor Author

kevinmarrec commented Jul 6, 2019

@nuxt/core-team Alright, I made this PR ready to review.
Some things are still missing but it's not something to do with code changes (docs/examples on external repo).
I just want review for the changes and we'll merge it only on another GO (when docs/examples ready).

Atinux
Atinux previously approved these changes Jul 8, 2019
Copy link
Member

@Atinux Atinux left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lot of cleanup, good for me at first glance 👍

pi0
pi0 previously approved these changes Jul 11, 2019
@pi0 pi0 merged commit 81b5ce2 into nuxt:dev Jul 24, 2019
@pi0 pi0 deleted the typescript-outsourcing branch July 24, 2019 07:26
@pi0 pi0 mentioned this pull request Jul 24, 2019
Atinux pushed a commit that referenced this pull request Jul 30, 2019
pi0 pushed a commit that referenced this pull request Aug 5, 2019
pi0 pushed a commit that referenced this pull request Aug 20, 2019
pi0 pushed a commit that referenced this pull request Aug 20, 2019
sodatea added a commit to vuejs/regression-testing that referenced this pull request Nov 18, 2019
@danielroe danielroe added the 2.x label Jan 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants