Skip to content

Commit

Permalink
refactor!: plugin hooks ssr param to object (#5253)
Browse files Browse the repository at this point in the history
  • Loading branch information
patak-dev authored Oct 27, 2021
1 parent dd3f750 commit 7da0563
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
3 changes: 2 additions & 1 deletion packages/plugin-vue-jsx/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ function vueJsxPlugin(options = {}) {
}
},

transform(code, id, ssr) {
transform(code, id, opt) {
const ssr = typeof opt === 'boolean' ? opt : (opt && opt.ssr) === true
const {
include,
exclude,
Expand Down
11 changes: 9 additions & 2 deletions packages/plugin-vue/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,11 @@ export default function vuePlugin(rawOptions: Options = {}): Plugin {
sourceMap: true
}

// Temporal handling for 2.7 breaking change
const isSSR = (opt: { ssr?: boolean } | boolean | undefined) =>
opt === undefined ? !!options.ssr :
(typeof opt === 'boolean' ? opt : opt?.ssr === true)

return {
name: 'vite:vue',

Expand Down Expand Up @@ -150,7 +155,8 @@ export default function vuePlugin(rawOptions: Options = {}): Plugin {
}
},

load(id, ssr = !!options.ssr) {
load(id, opt) {
const ssr = isSSR(opt)
if (id === EXPORT_HELPER_ID) {
return helperCode
}
Expand Down Expand Up @@ -182,7 +188,8 @@ export default function vuePlugin(rawOptions: Options = {}): Plugin {
}
},

transform(code, id, ssr = !!options.ssr) {
transform(code, id, opt) {
const ssr = isSSR(opt)
const { filename, query } = parseVueRequest(id)
if (query.raw) {
return
Expand Down

0 comments on commit 7da0563

Please sign in to comment.