Skip to content

Commit 935b4e2

Browse files
committed
fix(compiler-core): remove no longer necessary withScopeId import in generated code
1 parent 72d2b26 commit 935b4e2

File tree

4 files changed

+10
-17
lines changed

4 files changed

+10
-17
lines changed

packages/compiler-core/__tests__/__snapshots__/scopeId.spec.ts.snap

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

33
exports[`scopeId compiler support should push scopeId for hoisted nodes 1`] = `
4-
"import { createElementVNode as _createElementVNode, toDisplayString as _toDisplayString, createTextVNode as _createTextVNode, openBlock as _openBlock, createElementBlock as _createElementBlock, withScopeId as _withScopeId, pushScopeId as _pushScopeId, popScopeId as _popScopeId } from \\"vue\\"
4+
"import { createElementVNode as _createElementVNode, toDisplayString as _toDisplayString, createTextVNode as _createTextVNode, openBlock as _openBlock, createElementBlock as _createElementBlock, pushScopeId as _pushScopeId, popScopeId as _popScopeId } from \\"vue\\"
55
66
_pushScopeId(\\"test\\")
77
const _hoisted_1 = /*#__PURE__*/_createElementVNode(\\"div\\", null, \\"hello\\", -1 /* HOISTED */)
@@ -18,7 +18,7 @@ export function render(_ctx, _cache) {
1818
`;
1919

2020
exports[`scopeId compiler support should wrap default slot 1`] = `
21-
"import { createElementVNode as _createElementVNode, resolveComponent as _resolveComponent, withCtx as _withCtx, openBlock as _openBlock, createBlock as _createBlock, withScopeId as _withScopeId } from \\"vue\\"
21+
"import { createElementVNode as _createElementVNode, resolveComponent as _resolveComponent, withCtx as _withCtx, openBlock as _openBlock, createBlock as _createBlock } from \\"vue\\"
2222
2323
export function render(_ctx, _cache) {
2424
const _component_Child = _resolveComponent(\\"Child\\")
@@ -33,7 +33,7 @@ export function render(_ctx, _cache) {
3333
`;
3434

3535
exports[`scopeId compiler support should wrap dynamic slots 1`] = `
36-
"import { createElementVNode as _createElementVNode, resolveComponent as _resolveComponent, withCtx as _withCtx, renderList as _renderList, createSlots as _createSlots, openBlock as _openBlock, createBlock as _createBlock, withScopeId as _withScopeId } from \\"vue\\"
36+
"import { createElementVNode as _createElementVNode, resolveComponent as _resolveComponent, withCtx as _withCtx, renderList as _renderList, createSlots as _createSlots, openBlock as _openBlock, createBlock as _createBlock } from \\"vue\\"
3737
3838
export function render(_ctx, _cache) {
3939
const _component_Child = _resolveComponent(\\"Child\\")
@@ -60,7 +60,7 @@ export function render(_ctx, _cache) {
6060
`;
6161

6262
exports[`scopeId compiler support should wrap named slots 1`] = `
63-
"import { toDisplayString as _toDisplayString, createTextVNode as _createTextVNode, createElementVNode as _createElementVNode, resolveComponent as _resolveComponent, withCtx as _withCtx, openBlock as _openBlock, createBlock as _createBlock, withScopeId as _withScopeId } from \\"vue\\"
63+
"import { toDisplayString as _toDisplayString, createTextVNode as _createTextVNode, createElementVNode as _createElementVNode, resolveComponent as _resolveComponent, withCtx as _withCtx, openBlock as _openBlock, createBlock as _createBlock } from \\"vue\\"
6464
6565
export function render(_ctx, _cache) {
6666
const _component_Child = _resolveComponent(\\"Child\\")

packages/compiler-core/src/codegen.ts

+2-6
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ import {
4747
CREATE_TEXT,
4848
PUSH_SCOPE_ID,
4949
POP_SCOPE_ID,
50-
WITH_SCOPE_ID,
5150
WITH_DIRECTIVES,
5251
CREATE_ELEMENT_VNODE,
5352
OPEN_BLOCK,
@@ -380,11 +379,8 @@ function genModulePreamble(
380379
) {
381380
const { push, newline, optimizeImports, runtimeModuleName } = context
382381

383-
if (genScopeId) {
384-
ast.helpers.push(WITH_SCOPE_ID)
385-
if (ast.hoists.length) {
386-
ast.helpers.push(PUSH_SCOPE_ID, POP_SCOPE_ID)
387-
}
382+
if (genScopeId && ast.hoists.length) {
383+
ast.helpers.push(PUSH_SCOPE_ID, POP_SCOPE_ID)
388384
}
389385

390386
// generate import statements for helpers

packages/compiler-core/src/runtimeHelpers.ts

-2
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ export const TO_HANDLER_KEY = Symbol(__DEV__ ? `toHandlerKey` : ``)
3434
export const SET_BLOCK_TRACKING = Symbol(__DEV__ ? `setBlockTracking` : ``)
3535
export const PUSH_SCOPE_ID = Symbol(__DEV__ ? `pushScopeId` : ``)
3636
export const POP_SCOPE_ID = Symbol(__DEV__ ? `popScopeId` : ``)
37-
export const WITH_SCOPE_ID = Symbol(__DEV__ ? `withScopeId` : ``)
3837
export const WITH_CTX = Symbol(__DEV__ ? `withCtx` : ``)
3938
export const UNREF = Symbol(__DEV__ ? `unref` : ``)
4039
export const IS_REF = Symbol(__DEV__ ? `isRef` : ``)
@@ -79,7 +78,6 @@ export const helperNameMap: any = {
7978
[SET_BLOCK_TRACKING]: `setBlockTracking`,
8079
[PUSH_SCOPE_ID]: `pushScopeId`,
8180
[POP_SCOPE_ID]: `popScopeId`,
82-
[WITH_SCOPE_ID]: `withScopeId`,
8381
[WITH_CTX]: `withCtx`,
8482
[UNREF]: `unref`,
8583
[IS_REF]: `isRef`,

packages/compiler-ssr/__tests__/ssrScopeId.spec.ts

+4-5
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@ describe('ssr: scopeId', () => {
1010
mode: 'module'
1111
}).code
1212
).toMatchInlineSnapshot(`
13-
"import { withScopeId as _withScopeId } from \\"vue\\"
14-
import { ssrRenderAttrs as _ssrRenderAttrs } from \\"@vue/server-renderer\\"
13+
"import { ssrRenderAttrs as _ssrRenderAttrs } from \\"@vue/server-renderer\\"
1514
1615
export function ssrRender(_ctx, _push, _parent, _attrs) {
1716
_push(\`<div\${_ssrRenderAttrs(_attrs)} data-v-xxxxxxx><span data-v-xxxxxxx>hello</span></div>\`)
@@ -27,7 +26,7 @@ describe('ssr: scopeId', () => {
2726
mode: 'module'
2827
}).code
2928
).toMatchInlineSnapshot(`
30-
"import { resolveComponent as _resolveComponent, withCtx as _withCtx, createTextVNode as _createTextVNode, withScopeId as _withScopeId } from \\"vue\\"
29+
"import { resolveComponent as _resolveComponent, withCtx as _withCtx, createTextVNode as _createTextVNode } from \\"vue\\"
3130
import { ssrRenderComponent as _ssrRenderComponent } from \\"@vue/server-renderer\\"
3231
3332
export function ssrRender(_ctx, _push, _parent, _attrs) {
@@ -56,7 +55,7 @@ describe('ssr: scopeId', () => {
5655
mode: 'module'
5756
}).code
5857
).toMatchInlineSnapshot(`
59-
"import { resolveComponent as _resolveComponent, withCtx as _withCtx, createVNode as _createVNode, withScopeId as _withScopeId } from \\"vue\\"
58+
"import { resolveComponent as _resolveComponent, withCtx as _withCtx, createVNode as _createVNode } from \\"vue\\"
6059
import { ssrRenderComponent as _ssrRenderComponent } from \\"@vue/server-renderer\\"
6160
6261
export function ssrRender(_ctx, _push, _parent, _attrs) {
@@ -85,7 +84,7 @@ describe('ssr: scopeId', () => {
8584
mode: 'module'
8685
}).code
8786
).toMatchInlineSnapshot(`
88-
"import { resolveComponent as _resolveComponent, withCtx as _withCtx, createVNode as _createVNode, withScopeId as _withScopeId } from \\"vue\\"
87+
"import { resolveComponent as _resolveComponent, withCtx as _withCtx, createVNode as _createVNode } from \\"vue\\"
8988
import { ssrRenderComponent as _ssrRenderComponent } from \\"@vue/server-renderer\\"
9089
9190
export function ssrRender(_ctx, _push, _parent, _attrs) {

0 commit comments

Comments
 (0)