Skip to content

Commit

Permalink
refactor: remove hooks ssr param support (#8491)
Browse files Browse the repository at this point in the history
Co-authored-by: Bjorn Lu <[email protected]>
  • Loading branch information
sapphi-red and bluwy authored Jun 8, 2022
1 parent 0826f7b commit f59adf8
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 13 deletions.
4 changes: 2 additions & 2 deletions packages/plugin-react/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ export default function viteReact(opts: Options = {}): PluginOption[] {
}
},
async transform(code, id, options) {
const ssr = typeof options === 'boolean' ? options : options?.ssr === true
const ssr = options?.ssr === true
// File extension could be mocked/overridden in querystring.
const [filepath, querystring = ''] = id.split('?')
const [extension = ''] =
Expand Down Expand Up @@ -379,7 +379,7 @@ export default function viteReact(opts: Options = {}): PluginOption[] {
/*
resolveId(id: string) {
return id === runtimeId ? id : null
},
},
load(id: string) {
if (id === runtimeId) {
const runtimePath = resolve.sync(runtimeId, {
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-vue-jsx/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ function vueJsxPlugin(options: Options = {}): Plugin {
},

async transform(code, id, opt) {
const ssr = typeof opt === 'boolean' ? opt : (opt && opt.ssr) === true
const ssr = opt?.ssr === true
const {
include,
exclude,
Expand Down
12 changes: 2 additions & 10 deletions packages/plugin-vue/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,14 +107,6 @@ export default function vuePlugin(rawOptions: Options = {}): Plugin {
devToolsEnabled: process.env.NODE_ENV !== 'production'
}

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

return {
name: 'vite:vue',

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

load(id, opt) {
const ssr = isSSR(opt)
const ssr = opt?.ssr === true
if (id === EXPORT_HELPER_ID) {
return helperCode
}
Expand Down Expand Up @@ -202,7 +194,7 @@ export default function vuePlugin(rawOptions: Options = {}): Plugin {
},

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

0 comments on commit f59adf8

Please sign in to comment.