提交 1fa3c412 编写于 作者: fxy060608's avatar fxy060608

wip(ssr): add tranform

上级 f338a300
......@@ -15,6 +15,8 @@ export * from './preprocess'
export * from './postcss'
export * from './filter'
export * from './esbuild'
export * from './vue/transforms'
export { M } from './messages'
export * from './exports'
......
import path from 'path'
import { EmittedAsset } from 'rollup'
import { isComponentTag, LINEFEED } from '@dcloudio/uni-shared'
import {
createSimpleExpression,
ElementTypes,
isCoreComponent,
locStub,
NodeTypes,
RootNode,
TemplateChildNode,
TransformContext,
} from '@vue/compiler-core'
import { LINEFEED } from '@dcloudio/uni-shared'
import { normalizeMiniProgramFilename } from '../utils'
export interface MiniProgramCompilerOptions {
......@@ -110,30 +100,3 @@ export function addMiniProgramTemplateFilter(
templateFiltersCache.set(filename, [filter])
}
}
export function addComponentBindLink(
node: RootNode | TemplateChildNode,
context: TransformContext
) {
if (
node.type === NodeTypes.ELEMENT &&
node.tagType === ElementTypes.COMPONENT
) {
const { tag } = node
if (
isComponentTag(tag) ||
isCoreComponent(tag) ||
context.isBuiltInComponent(tag)
) {
return
}
node.props.push({
type: NodeTypes.DIRECTIVE,
name: 'on',
modifiers: [],
loc: locStub,
arg: createSimpleExpression('__l', true),
exp: createSimpleExpression('__l', true),
})
}
}
export * from './transformComponent'
export * from './transformPageHead'
import { isComponentTag } from '@dcloudio/uni-shared'
import {
createSimpleExpression,
ElementTypes,
isCoreComponent,
locStub,
NodeTypes,
RootNode,
TemplateChildNode,
TransformContext,
} from '@vue/compiler-core'
export function addComponentBindLink(
node: RootNode | TemplateChildNode,
context: TransformContext
) {
if (
node.type === NodeTypes.ELEMENT &&
node.tagType === ElementTypes.COMPONENT
) {
const { tag } = node
if (
isComponentTag(tag) ||
isCoreComponent(tag) ||
context.isBuiltInComponent(tag)
) {
return
}
node.props.push({
type: NodeTypes.DIRECTIVE,
name: 'on',
modifiers: [],
loc: locStub,
arg: createSimpleExpression('__l', true),
exp: createSimpleExpression('__l', true),
})
}
}
import { NodeTransform } from '@vue/compiler-core'
export const transformPageHead: NodeTransform = (_node, _context) => {
// 发现是page-meta下的page-head,直接remove该节点
}
......@@ -13,6 +13,7 @@ import { isSsr } from '../utils'
import { esbuildPrePlugin } from './esbuild/esbuildPrePlugin'
import { external } from './configureServer/ssr'
import { createConfigureServer } from './configureServer'
import { transformPageHead } from './transforms/transformPageHead'
export const UniH5Plugin: UniVitePlugin = {
name: 'vite:uni-h5',
......@@ -26,6 +27,7 @@ export const UniH5Plugin: UniVitePlugin = {
compilerOptions: {
isNativeTag: isH5NativeTag,
isCustomElement: isH5CustomElement,
nodeTransforms: [transformPageHead],
},
},
config(config, env) {
......
import { NodeTransform } from '@vue/compiler-core'
export const transformPageHead: NodeTransform = (node, context) => {
if (!context.ssr) {
return
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册