Skip to content

Commit

Permalink
fix: transpile ky (#61)
Browse files Browse the repository at this point in the history
  • Loading branch information
atinux authored and Pooya Parsa committed Jul 24, 2019
1 parent 26fe197 commit 2ce08de
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
11 changes: 11 additions & 0 deletions lib/module.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const path = require('path')
const consola = require('consola')
const semver = require('semver')

const logger = consola.withScope('nuxt:http')

Expand Down Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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==

[email protected]:
version "0.16.2"
resolved "https://registry.yarnpkg.com/send/-/send-0.16.2.tgz#6ecca1e0f8c156d141597559848df64730a6bbc1"
Expand Down

0 comments on commit 2ce08de

Please sign in to comment.