fix: transpile ky (#61)

master
Sébastien Chopin 2019-07-24 13:29:26 +02:00 committed by Pooya Parsa
parent 26fe197933
commit 2ce08de2ec
3 changed files with 18 additions and 1 deletions

View File

@ -1,5 +1,6 @@
const path = require('path')
const consola = require('consola')
const semver = require('semver')
const logger = consola.withScope('nuxt:http')
@ -90,6 +91,16 @@ function httpModule(_moduleOptions) {
typeof options.proxy === 'object' ? options.proxy : {}
])
}
// Add `ky` to build.transpile
this.options.build = this.options.build || {}
this.options.build.transpile = this.options.build.transpile || {}
// transpile only for non-modern build
// istanbul ignore if
if (semver.gte(semver.coerce(this.nuxt.constructor.version), '2.9.0')) {
this.options.build.transpile.push(({ isLegacy }) => isLegacy && 'ky')
} else {
this.options.build.transpile.push('ky')
}
// Set _HTTP_BASE_URL_ for dynamic SSR baseURL
process.env._HTTP_BASE_URL_ = options.baseURL

View File

@ -24,7 +24,8 @@
"@nuxtjs/proxy": "^1.3.3",
"consola": "^2.9.0",
"ky": "^0.11.1",
"ky-universal": "^0.2.2"
"ky-universal": "^0.2.2",
"semver": "^6.3.0"
},
"devDependencies": {
"@babel/core": "latest",

View File

@ -8233,6 +8233,11 @@ semver@^6.0.0:
resolved "https://registry.yarnpkg.com/semver/-/semver-6.0.0.tgz#05e359ee571e5ad7ed641a6eec1e547ba52dea65"
integrity sha512-0UewU+9rFapKFnlbirLi3byoOuhrSsli/z/ihNnvM24vgF+8sNBiI1LZPBSH9wJKUwaUbw+s3hToDLCXkrghrQ==
semver@^6.3.0:
version "6.3.0"
resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.0.tgz#ee0a64c8af5e8ceea67687b133761e1becbd1d3d"
integrity sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==
send@0.16.2:
version "0.16.2"
resolved "https://registry.yarnpkg.com/send/-/send-0.16.2.tgz#6ecca1e0f8c156d141597559848df64730a6bbc1"