Skip to content
This repository was archived by the owner on Jan 18, 2022. It is now read-only.

build(deps): bump ini from 1.3.5 to 1.3.8 #425

Open
wants to merge 8 commits into
base: next
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
feat: apply esbuild transform during serve
  • Loading branch information
yyx990803 committed Dec 16, 2020
commit 90209a7fffa553a91dcc8fb231908549df2af2d2
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ export default function PluginVue(userOptions: Partial<Options> = {}): Plugin {
// generate an entry module that imports the actual blocks of the SFC
if (!query.vue && filter(id)) {
debug(`transform SFC entry (${id})`)
const output = genSfcFacade(
const output = await genSfcFacade(
code,
id,
options,
Expand Down
22 changes: 18 additions & 4 deletions src/sfcFacade.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { resolveScript } from './script'
import { transformTemplateInMain } from './template'
import { isOnlyTemplateChanged } from './handleHotUpdate'

export function genSfcFacade(
export async function genSfcFacade(
code: string,
filename: string,
options: Options,
Expand Down Expand Up @@ -52,7 +52,7 @@ export function genSfcFacade(
const hasScoped = descriptor.styles.some((s) => s.scoped)

// script
const { code: scriptCode, map } = genScriptCode(
const { code: scriptCode, map } = await genScriptCode(
descriptor,
scopeId,
isProduction,
Expand Down Expand Up @@ -166,7 +166,7 @@ function genTemplateCode(
}
}

function genScriptCode(
async function genScriptCode(
descriptor: SFCDescriptor,
scopeId: string,
isProd: boolean,
Expand All @@ -186,9 +186,23 @@ function genScriptCode(
)
if (script) {
// js or ts can be directly placed in the main module
if ((!script.lang || script.lang === 'ts') && !script.src) {
if (
(!script.lang ||
(script.lang === 'ts' && (pluginContext as any).server)) &&
!script.src
) {
scriptCode = rewriteDefault(script.content, `_sfc_main`)
map = script.map
if (script.lang === 'ts') {
const result = await (pluginContext as any).server.transformWithEsbuild(
scriptCode,
descriptor.filename,
{ loader: 'ts' },
map
)
scriptCode = result.code
map = result.map
}
} else {
const src = script.src || descriptor.filename
const attrsQuery = attrsToQuery(script.attrs, 'js')
Expand Down