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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(vue-app): universal fetch #5028

Merged
merged 13 commits into from
Feb 14, 2019
Merged

feat(vue-app): universal fetch #5028

merged 13 commits into from
Feb 14, 2019

Conversation

pi0
Copy link
Member

@pi0 pi0 commented Feb 13, 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

Add universal fetch support to Nuxt.js 馃挜 (Original idea credits: @Atinux)

Users can control over disabling externals using the new fetch option. Defaults:

{
  fetch: {
    server: true,
    client: true
  }
}

Polyfill Overhead

Tested on basic fixture

Bundle Analyzer

Gzip: 78.65 KiB ~> 79.42 KiB (0.77 KiB)
Normal: 216.73 KiB ~> 219.17 KiB (+2.44 KiB)

app Chunk Size

  • Server: 31.3 KiB ~> 31.4 KiB
  • Client: 41.7 KiB ~> 44.1 KiB

Install Size Additions

For nuxt-start we have to add node-fetch because of externalization.

  • unfetch: install size
  • node-fetch: install size

Checklist:

  • My change requires a change to the documentation.
  • I have updated the documentation accordingly. (PR: #)
  • I have added 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 Feb 13, 2019

Codecov Report

Merging #5028 into dev will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##              dev    #5028   +/-   ##
=======================================
  Coverage   94.93%   94.93%           
=======================================
  Files          72       72           
  Lines        2408     2408           
  Branches      609      609           
=======================================
  Hits         2286     2286           
  Misses        102      102           
  Partials       20       20
Impacted Files Coverage 螖
packages/builder/src/context/template.js 100% <酶> (酶) 猬嗭笍
packages/config/src/config/_app.js 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 636e7e1...76f5e98. Read the comment docs.

@@ -13,6 +13,11 @@ export default () => ({
script: []
},

fetch: {
server: true,
Copy link
Member

Choose a reason for hiding this comment

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

A good way for excluding package from bundles

@Atinux Atinux merged commit 2015140 into dev Feb 14, 2019
@Atinux Atinux deleted the feat/universal-fetch branch February 14, 2019 15:57
@husayt
Copy link
Contributor

husayt commented Feb 14, 2019

I guess, bye-bye axios

@pi0
Copy link
Member Author

pi0 commented Feb 14, 2019

@husayt no actually. Axios still rocks but we have even better plans 馃槉

@husayt
Copy link
Contributor

husayt commented Feb 14, 2019

@pi0 I am intrigued now. At least give a clue, please

@husayt
Copy link
Contributor

husayt commented Feb 15, 2019

It is now asking for node-fetch to be installed

ERROR Please install missing dependencies:
npm i node-fetch@^2.3.0

@pi0 pi0 mentioned this pull request Mar 14, 2019
@pi0
Copy link
Member Author

pi0 commented Apr 9, 2019

@husayt It is in public beta now: https://github.com/nuxt/http :)

@pi0
Copy link
Member Author

pi0 commented Apr 9, 2019

Regarding the error, if other dependency installs 1.x version of node-fetch Nuxt.js detects it and requires manually installing to the root of the project to prevent inconsistencies.

@kingda
Copy link

kingda commented Jun 15, 2019

how can i find the example to use it ?

@pi0
Copy link
Member Author

pi0 commented Jun 15, 2019

@kingda, it is simply fetch() function usable in asyncData and components

https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API

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

Successfully merging this pull request may close these issues.

None yet

8 participants