mirror of https://github.com/vuejs/core.git
refactor(compiler-vapor): drop browser build
This commit is contained in:
parent
b1260e0dd6
commit
eed7d1d4fd
|
@ -9,7 +9,7 @@
|
||||||
"build-dts": "tsc -p tsconfig.build.json --noCheck && rollup -c rollup.dts.config.js",
|
"build-dts": "tsc -p tsconfig.build.json --noCheck && rollup -c rollup.dts.config.js",
|
||||||
"clean": "rimraf --glob packages/*/dist temp .eslintcache",
|
"clean": "rimraf --glob packages/*/dist temp .eslintcache",
|
||||||
"size": "run-s \"size-*\" && node scripts/usage-size.js",
|
"size": "run-s \"size-*\" && node scripts/usage-size.js",
|
||||||
"size-global": "node scripts/build.js vue vue-vapor runtime-dom runtime-vapor compiler-dom compiler-vapor -f global -p --size",
|
"size-global": "node scripts/build.js vue vue-vapor runtime-dom runtime-vapor compiler-dom -f global -p --size",
|
||||||
"size-esm-runtime": "node scripts/build.js vue vue-vapor -f esm-bundler-runtime",
|
"size-esm-runtime": "node scripts/build.js vue vue-vapor -f esm-bundler-runtime",
|
||||||
"size-esm": "node scripts/build.js runtime-shared runtime-dom runtime-vapor runtime-core reactivity shared -f esm-bundler",
|
"size-esm": "node scripts/build.js runtime-shared runtime-dom runtime-vapor runtime-core reactivity shared -f esm-bundler",
|
||||||
"check": "tsc --incremental --noEmit",
|
"check": "tsc --incremental --noEmit",
|
||||||
|
|
|
@ -1,7 +0,0 @@
|
||||||
'use strict'
|
|
||||||
|
|
||||||
if (process.env.NODE_ENV === 'production') {
|
|
||||||
module.exports = require('./dist/compiler-vapor.cjs.prod.js')
|
|
||||||
} else {
|
|
||||||
module.exports = require('./dist/compiler-vapor.cjs.js')
|
|
||||||
}
|
|
|
@ -5,22 +5,28 @@
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"module": "dist/compiler-vapor.esm-bundler.js",
|
"module": "dist/compiler-vapor.esm-bundler.js",
|
||||||
"types": "dist/compiler-vapor.d.ts",
|
"types": "dist/compiler-vapor.d.ts",
|
||||||
"unpkg": "dist/compiler-vapor.global.js",
|
|
||||||
"jsdelivr": "dist/compiler-vapor.global.js",
|
|
||||||
"files": [
|
"files": [
|
||||||
"index.js",
|
|
||||||
"dist"
|
"dist"
|
||||||
],
|
],
|
||||||
"sideEffects": false,
|
"sideEffects": false,
|
||||||
|
"exports": {
|
||||||
|
".": {
|
||||||
|
"types": "./dist/compiler-vapor.d.ts",
|
||||||
|
"node": "./dist/compiler-vapor.cjs.js",
|
||||||
|
"module": "./dist/compiler-vapor.esm-browser.js",
|
||||||
|
"import": "./dist/compiler-vapor.esm-browser.js",
|
||||||
|
"require": "./dist/compiler-vapor.cjs.js"
|
||||||
|
},
|
||||||
|
"./*": "./*"
|
||||||
|
},
|
||||||
"buildOptions": {
|
"buildOptions": {
|
||||||
"name": "VueCompilerVapor",
|
"name": "VueCompilerVapor",
|
||||||
"compat": true,
|
|
||||||
"formats": [
|
"formats": [
|
||||||
"esm-bundler",
|
|
||||||
"esm-browser",
|
|
||||||
"cjs",
|
"cjs",
|
||||||
"global"
|
"esm-browser"
|
||||||
]
|
],
|
||||||
|
"prod": false,
|
||||||
|
"enableNonBrowserBranches": true
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
|
|
|
@ -40,17 +40,7 @@ export function compile(
|
||||||
): VaporCodegenResult {
|
): VaporCodegenResult {
|
||||||
const onError = options.onError || defaultOnError
|
const onError = options.onError || defaultOnError
|
||||||
const isModuleMode = options.mode === 'module'
|
const isModuleMode = options.mode === 'module'
|
||||||
/* istanbul ignore if */
|
const prefixIdentifiers = options.prefixIdentifiers === true || isModuleMode
|
||||||
if (__BROWSER__) {
|
|
||||||
if (options.prefixIdentifiers === true) {
|
|
||||||
onError(createCompilerError(ErrorCodes.X_PREFIX_ID_NOT_SUPPORTED))
|
|
||||||
} else if (isModuleMode) {
|
|
||||||
onError(createCompilerError(ErrorCodes.X_MODULE_MODE_NOT_SUPPORTED))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const prefixIdentifiers =
|
|
||||||
!__BROWSER__ && (options.prefixIdentifiers === true || isModuleMode)
|
|
||||||
|
|
||||||
if (options.scopeId && !isModuleMode) {
|
if (options.scopeId && !isModuleMode) {
|
||||||
onError(createCompilerError(ErrorCodes.X_SCOPE_ID_NOT_SUPPORTED))
|
onError(createCompilerError(ErrorCodes.X_SCOPE_ID_NOT_SUPPORTED))
|
||||||
|
@ -63,7 +53,7 @@ export function compile(
|
||||||
const [nodeTransforms, directiveTransforms] =
|
const [nodeTransforms, directiveTransforms] =
|
||||||
getBaseTransformPreset(prefixIdentifiers)
|
getBaseTransformPreset(prefixIdentifiers)
|
||||||
|
|
||||||
if (!__BROWSER__ && options.isTS) {
|
if (options.isTS) {
|
||||||
const { expressionPlugins } = options
|
const { expressionPlugins } = options
|
||||||
if (!expressionPlugins || !expressionPlugins.includes('typescript')) {
|
if (!expressionPlugins || !expressionPlugins.includes('typescript')) {
|
||||||
resolvedOptions.expressionPlugins = [
|
resolvedOptions.expressionPlugins = [
|
||||||
|
|
|
@ -15,7 +15,7 @@ export function createVaporCompilerError(
|
||||||
return createCompilerError(
|
return createCompilerError(
|
||||||
code,
|
code,
|
||||||
loc,
|
loc,
|
||||||
__DEV__ || !__BROWSER__ ? VaporErrorMessages : undefined,
|
VaporErrorMessages,
|
||||||
) as VaporCompilerError
|
) as VaporCompilerError
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,6 @@ export function genExpression(
|
||||||
}
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
__BROWSER__ ||
|
|
||||||
!prefixIdentifiers ||
|
!prefixIdentifiers ||
|
||||||
!node.content.trim() ||
|
!node.content.trim() ||
|
||||||
// there was a parsing error
|
// there was a parsing error
|
||||||
|
|
|
@ -102,7 +102,7 @@ export function codeFragmentToString(
|
||||||
} = context
|
} = context
|
||||||
|
|
||||||
let map: CodegenSourceMapGenerator | undefined
|
let map: CodegenSourceMapGenerator | undefined
|
||||||
if (!__BROWSER__ && sourceMap) {
|
if (sourceMap) {
|
||||||
// lazy require source-map implementation, only in non-browser builds
|
// lazy require source-map implementation, only in non-browser builds
|
||||||
map = new SourceMapGenerator() as unknown as CodegenSourceMapGenerator
|
map = new SourceMapGenerator() as unknown as CodegenSourceMapGenerator
|
||||||
map.setSourceContent(filename, context.ir.source)
|
map.setSourceContent(filename, context.ir.source)
|
||||||
|
@ -136,7 +136,7 @@ export function codeFragmentToString(
|
||||||
let [code, newlineIndex = NewlineType.None, loc, name] = frag
|
let [code, newlineIndex = NewlineType.None, loc, name] = frag
|
||||||
codegen += code
|
codegen += code
|
||||||
|
|
||||||
if (!__BROWSER__ && map) {
|
if (map) {
|
||||||
if (loc) addMapping(loc.start, name)
|
if (loc) addMapping(loc.start, name)
|
||||||
if (newlineIndex === NewlineType.Unknown) {
|
if (newlineIndex === NewlineType.Unknown) {
|
||||||
// multiple newlines, full iteration
|
// multiple newlines, full iteration
|
||||||
|
|
|
@ -74,21 +74,21 @@ function transformComponentElement(
|
||||||
) {
|
) {
|
||||||
let asset = true
|
let asset = true
|
||||||
|
|
||||||
if (!__BROWSER__) {
|
const fromSetup = resolveSetupReference(tag, context)
|
||||||
const fromSetup = resolveSetupReference(tag, context)
|
if (fromSetup) {
|
||||||
if (fromSetup) {
|
tag = fromSetup
|
||||||
tag = fromSetup
|
asset = false
|
||||||
|
}
|
||||||
|
|
||||||
|
const dotIndex = tag.indexOf('.')
|
||||||
|
if (dotIndex > 0) {
|
||||||
|
const ns = resolveSetupReference(tag.slice(0, dotIndex), context)
|
||||||
|
if (ns) {
|
||||||
|
tag = ns + tag.slice(dotIndex)
|
||||||
asset = false
|
asset = false
|
||||||
}
|
}
|
||||||
const dotIndex = tag.indexOf('.')
|
|
||||||
if (dotIndex > 0) {
|
|
||||||
const ns = resolveSetupReference(tag.slice(0, dotIndex), context)
|
|
||||||
if (ns) {
|
|
||||||
tag = ns + tag.slice(dotIndex)
|
|
||||||
asset = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (asset) {
|
if (asset) {
|
||||||
context.component.add(tag)
|
context.component.add(tag)
|
||||||
}
|
}
|
||||||
|
@ -304,8 +304,7 @@ function transformProp(
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isBuiltInDirective(name)) {
|
if (!isBuiltInDirective(name)) {
|
||||||
const fromSetup =
|
const fromSetup = resolveSetupReference(`v-${name}`, context)
|
||||||
!__BROWSER__ && resolveSetupReference(`v-${name}`, context)
|
|
||||||
if (fromSetup) {
|
if (fromSetup) {
|
||||||
name = fromSetup
|
name = fromSetup
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -40,14 +40,9 @@ export const transformVBind: DirectiveTransform = (dir, node, context) => {
|
||||||
|
|
||||||
if (!exp) exp = normalizeBindShorthand(arg, context)
|
if (!exp) exp = normalizeBindShorthand(arg, context)
|
||||||
if (!exp.content.trim()) {
|
if (!exp.content.trim()) {
|
||||||
if (!__BROWSER__) {
|
context.options.onError(
|
||||||
// #10280 only error against empty expression in non-browser build
|
createCompilerError(ErrorCodes.X_V_BIND_NO_EXPRESSION, loc),
|
||||||
// because :foo in in-DOM templates will be parsed into :foo="" by the
|
)
|
||||||
// browser
|
|
||||||
context.options.onError(
|
|
||||||
createCompilerError(ErrorCodes.X_V_BIND_NO_EXPRESSION, loc),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
exp = createSimpleExpression('', true, loc)
|
exp = createSimpleExpression('', true, loc)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -46,7 +46,6 @@ export const transformVModel: DirectiveTransform = (dir, node, context) => {
|
||||||
|
|
||||||
const expString = exp.content
|
const expString = exp.content
|
||||||
const maybeRef =
|
const maybeRef =
|
||||||
!__BROWSER__ &&
|
|
||||||
context.options.inline &&
|
context.options.inline &&
|
||||||
(bindingType === BindingTypes.SETUP_LET ||
|
(bindingType === BindingTypes.SETUP_LET ||
|
||||||
bindingType === BindingTypes.SETUP_REF ||
|
bindingType === BindingTypes.SETUP_REF ||
|
||||||
|
|
|
@ -60,7 +60,7 @@ export function resolveExpression(
|
||||||
export function getLiteralExpressionValue(
|
export function getLiteralExpressionValue(
|
||||||
exp: SimpleExpressionNode,
|
exp: SimpleExpressionNode,
|
||||||
): number | string | boolean | null {
|
): number | string | boolean | null {
|
||||||
if (!__BROWSER__ && exp.ast) {
|
if (exp.ast) {
|
||||||
if (
|
if (
|
||||||
['StringLiteral', 'NumericLiteral', 'BigIntLiteral'].includes(
|
['StringLiteral', 'NumericLiteral', 'BigIntLiteral'].includes(
|
||||||
exp.ast.type,
|
exp.ast.type,
|
||||||
|
|
Loading…
Reference in New Issue