Skip to content
This repository was archived by the owner on Jul 19, 2025. It is now read-only.

Commit 8ae32d0

Browse files
committed
refactor(compiler-vapor): drop browser build
1 parent b1260e0 commit 8ae32d0

File tree

10 files changed

+33
-53
lines changed

10 files changed

+33
-53
lines changed

package.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"build-dts": "tsc -p tsconfig.build.json --noCheck && rollup -c rollup.dts.config.js",
1010
"clean": "rimraf --glob packages/*/dist temp .eslintcache",
1111
"size": "run-s \"size-*\" && node scripts/usage-size.js",
12-
"size-global": "node scripts/build.js vue vue-vapor runtime-dom runtime-vapor compiler-dom compiler-vapor -f global -p --size",
12+
"size-global": "node scripts/build.js vue vue-vapor runtime-dom runtime-vapor compiler-dom -f global -p --size",
1313
"size-esm-runtime": "node scripts/build.js vue vue-vapor -f esm-bundler-runtime",
1414
"size-esm": "node scripts/build.js runtime-shared runtime-dom runtime-vapor runtime-core reactivity shared -f esm-bundler",
1515
"check": "tsc --incremental --noEmit",
@@ -66,9 +66,9 @@
6666
"@rollup/plugin-json": "^6.1.0",
6767
"@rollup/plugin-node-resolve": "^15.3.0",
6868
"@rollup/plugin-replace": "5.0.4",
69-
"@swc/core": "^1.9.1",
69+
"@swc/core": "^1.7.40",
7070
"@types/hash-sum": "^1.0.2",
71-
"@types/node": "^22.8.7",
71+
"@types/node": "^20.17.1",
7272
"@types/semver": "^7.5.8",
7373
"@types/serve-handler": "^6.1.4",
7474
"@vitest/coverage-v8": "^2.1.1",
@@ -78,8 +78,8 @@
7878
"enquirer": "^2.4.1",
7979
"esbuild": "^0.24.0",
8080
"esbuild-plugin-polyfill-node": "^0.3.0",
81-
"eslint": "^9.14.0",
82-
"eslint-plugin-import-x": "^4.4.0",
81+
"eslint": "^9.13.0",
82+
"eslint-plugin-import-x": "^4.3.1",
8383
"@vitest/eslint-plugin": "^1.0.1",
8484
"estree-walker": "catalog:",
8585
"jsdom": "^25.0.0",
@@ -95,7 +95,7 @@
9595
"pug": "^3.0.3",
9696
"puppeteer": "~23.3.0",
9797
"rimraf": "^6.0.1",
98-
"rollup": "^4.25.0",
98+
"rollup": "^4.24.2",
9999
"rollup-plugin-dts": "^6.1.1",
100100
"rollup-plugin-esbuild": "^6.1.1",
101101
"rollup-plugin-polyfill-node": "^0.13.0",
@@ -104,9 +104,9 @@
104104
"serve-handler": "^6.1.6",
105105
"simple-git-hooks": "^2.11.1",
106106
"todomvc-app-css": "^2.4.3",
107-
"tslib": "^2.8.1",
107+
"tslib": "^2.8.0",
108108
"typescript": "~5.6.2",
109-
"typescript-eslint": "^8.12.2",
109+
"typescript-eslint": "^8.11.0",
110110
"vite": "catalog:",
111111
"vitest": "^2.1.1"
112112
},

packages/compiler-vapor/package.json

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,11 @@
1414
"sideEffects": false,
1515
"buildOptions": {
1616
"name": "VueCompilerVapor",
17-
"compat": true,
1817
"formats": [
1918
"esm-bundler",
20-
"esm-browser",
21-
"cjs",
22-
"global"
23-
]
19+
"cjs"
20+
],
21+
"prod": false
2422
},
2523
"repository": {
2624
"type": "git",

packages/compiler-vapor/src/compile.ts

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -40,17 +40,7 @@ export function compile(
4040
): VaporCodegenResult {
4141
const onError = options.onError || defaultOnError
4242
const isModuleMode = options.mode === 'module'
43-
/* istanbul ignore if */
44-
if (__BROWSER__) {
45-
if (options.prefixIdentifiers === true) {
46-
onError(createCompilerError(ErrorCodes.X_PREFIX_ID_NOT_SUPPORTED))
47-
} else if (isModuleMode) {
48-
onError(createCompilerError(ErrorCodes.X_MODULE_MODE_NOT_SUPPORTED))
49-
}
50-
}
51-
52-
const prefixIdentifiers =
53-
!__BROWSER__ && (options.prefixIdentifiers === true || isModuleMode)
43+
const prefixIdentifiers = options.prefixIdentifiers === true || isModuleMode
5444

5545
if (options.scopeId && !isModuleMode) {
5646
onError(createCompilerError(ErrorCodes.X_SCOPE_ID_NOT_SUPPORTED))
@@ -63,7 +53,7 @@ export function compile(
6353
const [nodeTransforms, directiveTransforms] =
6454
getBaseTransformPreset(prefixIdentifiers)
6555

66-
if (!__BROWSER__ && options.isTS) {
56+
if (options.isTS) {
6757
const { expressionPlugins } = options
6858
if (!expressionPlugins || !expressionPlugins.includes('typescript')) {
6959
resolvedOptions.expressionPlugins = [

packages/compiler-vapor/src/errors.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export function createVaporCompilerError(
1515
return createCompilerError(
1616
code,
1717
loc,
18-
__DEV__ || !__BROWSER__ ? VaporErrorMessages : undefined,
18+
VaporErrorMessages,
1919
) as VaporCompilerError
2020
}
2121

packages/compiler-vapor/src/generators/expression.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ export function genExpression(
2828
}
2929

3030
if (
31-
__BROWSER__ ||
3231
!prefixIdentifiers ||
3332
!node.content.trim() ||
3433
// there was a parsing error

packages/compiler-vapor/src/generators/utils.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ export function codeFragmentToString(
102102
} = context
103103

104104
let map: CodegenSourceMapGenerator | undefined
105-
if (!__BROWSER__ && sourceMap) {
105+
if (sourceMap) {
106106
// lazy require source-map implementation, only in non-browser builds
107107
map = new SourceMapGenerator() as unknown as CodegenSourceMapGenerator
108108
map.setSourceContent(filename, context.ir.source)
@@ -136,7 +136,7 @@ export function codeFragmentToString(
136136
let [code, newlineIndex = NewlineType.None, loc, name] = frag
137137
codegen += code
138138

139-
if (!__BROWSER__ && map) {
139+
if (map) {
140140
if (loc) addMapping(loc.start, name)
141141
if (newlineIndex === NewlineType.Unknown) {
142142
// multiple newlines, full iteration

packages/compiler-vapor/src/transforms/transformElement.ts

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -74,21 +74,21 @@ function transformComponentElement(
7474
) {
7575
let asset = true
7676

77-
if (!__BROWSER__) {
78-
const fromSetup = resolveSetupReference(tag, context)
79-
if (fromSetup) {
80-
tag = fromSetup
77+
const fromSetup = resolveSetupReference(tag, context)
78+
if (fromSetup) {
79+
tag = fromSetup
80+
asset = false
81+
}
82+
83+
const dotIndex = tag.indexOf('.')
84+
if (dotIndex > 0) {
85+
const ns = resolveSetupReference(tag.slice(0, dotIndex), context)
86+
if (ns) {
87+
tag = ns + tag.slice(dotIndex)
8188
asset = false
8289
}
83-
const dotIndex = tag.indexOf('.')
84-
if (dotIndex > 0) {
85-
const ns = resolveSetupReference(tag.slice(0, dotIndex), context)
86-
if (ns) {
87-
tag = ns + tag.slice(dotIndex)
88-
asset = false
89-
}
90-
}
9190
}
91+
9292
if (asset) {
9393
context.component.add(tag)
9494
}
@@ -304,8 +304,7 @@ function transformProp(
304304
}
305305

306306
if (!isBuiltInDirective(name)) {
307-
const fromSetup =
308-
!__BROWSER__ && resolveSetupReference(`v-${name}`, context)
307+
const fromSetup = resolveSetupReference(`v-${name}`, context)
309308
if (fromSetup) {
310309
name = fromSetup
311310
} else {

packages/compiler-vapor/src/transforms/vBind.ts

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,9 @@ export const transformVBind: DirectiveTransform = (dir, node, context) => {
4040

4141
if (!exp) exp = normalizeBindShorthand(arg, context)
4242
if (!exp.content.trim()) {
43-
if (!__BROWSER__) {
44-
// #10280 only error against empty expression in non-browser build
45-
// because :foo in in-DOM templates will be parsed into :foo="" by the
46-
// browser
47-
context.options.onError(
48-
createCompilerError(ErrorCodes.X_V_BIND_NO_EXPRESSION, loc),
49-
)
50-
}
43+
context.options.onError(
44+
createCompilerError(ErrorCodes.X_V_BIND_NO_EXPRESSION, loc),
45+
)
5146
exp = createSimpleExpression('', true, loc)
5247
}
5348

packages/compiler-vapor/src/transforms/vModel.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ export const transformVModel: DirectiveTransform = (dir, node, context) => {
4646

4747
const expString = exp.content
4848
const maybeRef =
49-
!__BROWSER__ &&
5049
context.options.inline &&
5150
(bindingType === BindingTypes.SETUP_LET ||
5251
bindingType === BindingTypes.SETUP_REF ||

packages/compiler-vapor/src/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ export function resolveExpression(
6060
export function getLiteralExpressionValue(
6161
exp: SimpleExpressionNode,
6262
): number | string | boolean | null {
63-
if (!__BROWSER__ && exp.ast) {
63+
if (exp.ast) {
6464
if (
6565
['StringLiteral', 'NumericLiteral', 'BigIntLiteral'].includes(
6666
exp.ast.type,

0 commit comments

Comments
 (0)