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",
|
||||
"clean": "rimraf --glob packages/*/dist temp .eslintcache",
|
||||
"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": "node scripts/build.js runtime-shared runtime-dom runtime-vapor runtime-core reactivity shared -f esm-bundler",
|
||||
"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",
|
||||
"module": "dist/compiler-vapor.esm-bundler.js",
|
||||
"types": "dist/compiler-vapor.d.ts",
|
||||
"unpkg": "dist/compiler-vapor.global.js",
|
||||
"jsdelivr": "dist/compiler-vapor.global.js",
|
||||
"files": [
|
||||
"index.js",
|
||||
"dist"
|
||||
],
|
||||
"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": {
|
||||
"name": "VueCompilerVapor",
|
||||
"compat": true,
|
||||
"formats": [
|
||||
"esm-bundler",
|
||||
"esm-browser",
|
||||
"cjs",
|
||||
"global"
|
||||
]
|
||||
"esm-browser"
|
||||
],
|
||||
"prod": false,
|
||||
"enableNonBrowserBranches": true
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
|
|
@ -40,17 +40,7 @@ export function compile(
|
|||
): VaporCodegenResult {
|
||||
const onError = options.onError || defaultOnError
|
||||
const isModuleMode = options.mode === 'module'
|
||||
/* istanbul ignore if */
|
||||
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)
|
||||
const prefixIdentifiers = options.prefixIdentifiers === true || isModuleMode
|
||||
|
||||
if (options.scopeId && !isModuleMode) {
|
||||
onError(createCompilerError(ErrorCodes.X_SCOPE_ID_NOT_SUPPORTED))
|
||||
|
@ -63,7 +53,7 @@ export function compile(
|
|||
const [nodeTransforms, directiveTransforms] =
|
||||
getBaseTransformPreset(prefixIdentifiers)
|
||||
|
||||
if (!__BROWSER__ && options.isTS) {
|
||||
if (options.isTS) {
|
||||
const { expressionPlugins } = options
|
||||
if (!expressionPlugins || !expressionPlugins.includes('typescript')) {
|
||||
resolvedOptions.expressionPlugins = [
|
||||
|
|
|
@ -15,7 +15,7 @@ export function createVaporCompilerError(
|
|||
return createCompilerError(
|
||||
code,
|
||||
loc,
|
||||
__DEV__ || !__BROWSER__ ? VaporErrorMessages : undefined,
|
||||
VaporErrorMessages,
|
||||
) as VaporCompilerError
|
||||
}
|
||||
|
||||
|
|
|
@ -28,7 +28,6 @@ export function genExpression(
|
|||
}
|
||||
|
||||
if (
|
||||
__BROWSER__ ||
|
||||
!prefixIdentifiers ||
|
||||
!node.content.trim() ||
|
||||
// there was a parsing error
|
||||
|
|
|
@ -102,7 +102,7 @@ export function codeFragmentToString(
|
|||
} = context
|
||||
|
||||
let map: CodegenSourceMapGenerator | undefined
|
||||
if (!__BROWSER__ && sourceMap) {
|
||||
if (sourceMap) {
|
||||
// lazy require source-map implementation, only in non-browser builds
|
||||
map = new SourceMapGenerator() as unknown as CodegenSourceMapGenerator
|
||||
map.setSourceContent(filename, context.ir.source)
|
||||
|
@ -136,7 +136,7 @@ export function codeFragmentToString(
|
|||
let [code, newlineIndex = NewlineType.None, loc, name] = frag
|
||||
codegen += code
|
||||
|
||||
if (!__BROWSER__ && map) {
|
||||
if (map) {
|
||||
if (loc) addMapping(loc.start, name)
|
||||
if (newlineIndex === NewlineType.Unknown) {
|
||||
// multiple newlines, full iteration
|
||||
|
|
|
@ -74,21 +74,21 @@ function transformComponentElement(
|
|||
) {
|
||||
let asset = true
|
||||
|
||||
if (!__BROWSER__) {
|
||||
const fromSetup = resolveSetupReference(tag, context)
|
||||
if (fromSetup) {
|
||||
tag = fromSetup
|
||||
const fromSetup = resolveSetupReference(tag, context)
|
||||
if (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
|
||||
}
|
||||
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) {
|
||||
context.component.add(tag)
|
||||
}
|
||||
|
@ -304,8 +304,7 @@ function transformProp(
|
|||
}
|
||||
|
||||
if (!isBuiltInDirective(name)) {
|
||||
const fromSetup =
|
||||
!__BROWSER__ && resolveSetupReference(`v-${name}`, context)
|
||||
const fromSetup = resolveSetupReference(`v-${name}`, context)
|
||||
if (fromSetup) {
|
||||
name = fromSetup
|
||||
} else {
|
||||
|
|
|
@ -40,14 +40,9 @@ export const transformVBind: DirectiveTransform = (dir, node, context) => {
|
|||
|
||||
if (!exp) exp = normalizeBindShorthand(arg, context)
|
||||
if (!exp.content.trim()) {
|
||||
if (!__BROWSER__) {
|
||||
// #10280 only error against empty expression in non-browser build
|
||||
// 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),
|
||||
)
|
||||
}
|
||||
context.options.onError(
|
||||
createCompilerError(ErrorCodes.X_V_BIND_NO_EXPRESSION, loc),
|
||||
)
|
||||
exp = createSimpleExpression('', true, loc)
|
||||
}
|
||||
|
||||
|
|
|
@ -46,7 +46,6 @@ export const transformVModel: DirectiveTransform = (dir, node, context) => {
|
|||
|
||||
const expString = exp.content
|
||||
const maybeRef =
|
||||
!__BROWSER__ &&
|
||||
context.options.inline &&
|
||||
(bindingType === BindingTypes.SETUP_LET ||
|
||||
bindingType === BindingTypes.SETUP_REF ||
|
||||
|
|
|
@ -60,7 +60,7 @@ export function resolveExpression(
|
|||
export function getLiteralExpressionValue(
|
||||
exp: SimpleExpressionNode,
|
||||
): number | string | boolean | null {
|
||||
if (!__BROWSER__ && exp.ast) {
|
||||
if (exp.ast) {
|
||||
if (
|
||||
['StringLiteral', 'NumericLiteral', 'BigIntLiteral'].includes(
|
||||
exp.ast.type,
|
||||
|
|
Loading…
Reference in New Issue