Skip to content

Commit

Permalink
fix: lazy require @vue/compiler-dom so it respects NODE_ENV
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed May 26, 2020
1 parent 286fb2f commit e2594df
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/node/build/buildPluginHtml.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import fs from 'fs-extra'
import { isExternalUrl, cleanUrl, isStaticAsset } from '../utils/pathUtils'
import { resolveAsset } from './buildPluginAsset'
import {
parse,
transform,
parse as Parse,
transform as Transform,
NodeTransform,
NodeTypes,
TextNode,
Expand Down Expand Up @@ -130,9 +130,11 @@ const compileHtml = async (
inlineLimit: number,
resolver: InternalResolver
) => {
const { parse, transform } = require('@vue/compiler-dom')

// @vue/compiler-core doesn't like lowercase doctypes
html = html.replace(/<!doctype\s/i, '<!DOCTYPE ')
const ast = parse(html)
const ast = (parse as typeof Parse)(html)

let js = ''
const s = new MagicString(html)
Expand Down Expand Up @@ -188,7 +190,7 @@ const compileHtml = async (
}
}

transform(ast, {
;(transform as typeof Transform)(ast, {
nodeTransforms: [viteHtmlTransfrom]
})

Expand Down

0 comments on commit e2594df

Please sign in to comment.