Skip to content

Commit 3cd6494

Browse files
NullVoxPopuliclaude
andcommitted
Remove lexicalSymbols from wire format and dead debugSymbols codepath
Now that the scope bag is an object (`Record<string, unknown>`), lexical symbol names are always available via `Object.keys(scope())`. This makes two things redundant: - The optional `lexicalSymbols` slot in `SerializedTemplateBlock` (previously only populated when `emit.debugSymbols` was enabled) - The `emit.debugSymbols` option itself — removed from the compiler, `PrecompileOptionsWithLexicalScope` type, test helpers, and test callsites Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 3deb719 commit 3cd6494

7 files changed

Lines changed: 12 additions & 45 deletions

File tree

packages/@glimmer-workspace/integration-tests/lib/compile.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,6 @@ export function createTemplate(
2929
reifiedScope[key] = scopeValues[key];
3030
}
3131

32-
if ('emit' in options && options.emit?.debugSymbols) {
33-
block.push(usedLocals);
34-
}
35-
3632
let templateBlock: SerializedTemplateWithLazyBlock = {
3733
id: String(templateId++),
3834
block: JSON.stringify(block),

packages/@glimmer-workspace/integration-tests/lib/test-helpers/define.ts

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import type {
55
ModifierManager,
66
Owner,
77
} from '@glimmer/interfaces';
8-
import type { PrecompileOptionsWithLexicalScope } from '@glimmer/syntax';
8+
99
import { registerDestructor } from '@glimmer/destroyable';
1010
import {
1111
helperCapabilities,
@@ -100,29 +100,19 @@ export interface DefineComponentOptions {
100100

101101
// additional strict-mode keywords
102102
keywords?: string[];
103-
104-
emit?: PrecompileOptionsWithLexicalScope['emit'];
105103
}
106104

107105
export function defComponent(
108106
templateSource: string,
109107
options?: {
110108
component?: object | undefined;
111109
scope?: Record<string, unknown> | undefined;
112-
emit?: {
113-
moduleName?: string;
114-
debugSymbols?: boolean;
115-
};
116110
}
117111
) {
118112
let definition = options?.component ?? templateOnlyComponent();
119113
let templateFactory = createTemplate(
120114
templateSource,
121-
{
122-
strictMode: true,
123-
meta: { moduleName: options?.emit?.moduleName },
124-
emit: { debugSymbols: options?.emit?.debugSymbols ?? true },
125-
},
115+
{ strictMode: true },
126116
options?.scope ?? {}
127117
);
128118
setComponentTemplate(templateFactory, definition);
@@ -146,7 +136,7 @@ export function defineComponent(
146136
let definition = options.definition ?? templateOnlyComponent();
147137
let templateFactory = createTemplate(
148138
templateSource,
149-
{ strictMode, keywords, emit: options.emit },
139+
{ strictMode, keywords },
150140
scopeValues ?? {}
151141
);
152142
setComponentTemplate(templateFactory, definition);

packages/@glimmer-workspace/integration-tests/test/debug-render-tree-test.ts

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ class DebugRenderTreeTest extends RenderTest {
8383
const HelloWorld = defComponent('{{@arg}}');
8484
const Root = defComponent(
8585
`<HelloWorld @arg="first"/>{{#if state.showSecond}}<HelloWorld @arg="second"/>{{/if}}`,
86-
{ scope: { HelloWorld, state }, emit: { moduleName: 'root.hbs' } }
86+
{ scope: { HelloWorld, state } }
8787
);
8888

8989
this.renderComponent(Root);
@@ -94,7 +94,7 @@ class DebugRenderTreeTest extends RenderTest {
9494
name: '{ROOT}',
9595
args: { positional: [], named: {} },
9696
instance: null,
97-
template: 'root.hbs',
97+
template: '(unknown template module)',
9898
bounds: this.elementBounds(this.delegate.getInitialElement()),
9999
children: [
100100
{
@@ -111,11 +111,10 @@ class DebugRenderTreeTest extends RenderTest {
111111
]);
112112
}
113113

114-
@test 'strict-mode components without debug symbols preserve names from scope'() {
114+
@test 'strict-mode components preserve names from scope'() {
115115
const HelloWorld = defComponent('{{@arg}}');
116116
const Root = defComponent(`<HelloWorld @arg="first"/>`, {
117117
scope: { HelloWorld },
118-
emit: { moduleName: 'root.hbs', debugSymbols: false },
119118
});
120119

121120
this.renderComponent(Root);
@@ -126,7 +125,7 @@ class DebugRenderTreeTest extends RenderTest {
126125
name: '{ROOT}',
127126
args: { positional: [], named: {} },
128127
instance: null,
129-
template: 'root.hbs',
128+
template: '(unknown template module)',
130129
bounds: this.elementBounds(this.delegate.getInitialElement()),
131130
children: [
132131
{
@@ -152,7 +151,6 @@ class DebugRenderTreeTest extends RenderTest {
152151

153152
const RootDef = defComponent(`<this.HelloWorld @arg="first"/>`, {
154153
component: Root,
155-
emit: { moduleName: 'root.hbs' },
156154
});
157155

158156
this.renderComponent(RootDef);
@@ -173,9 +171,7 @@ class DebugRenderTreeTest extends RenderTest {
173171

174172
@test({ skip: !DEBUG }) 'dynamic component via <@argComponent>'() {
175173
const HelloWorld = defComponent('{{@arg}}');
176-
const Root = defComponent(`<@Greeting @arg="first"/>`, {
177-
emit: { moduleName: 'root.hbs' },
178-
});
174+
const Root = defComponent(`<@Greeting @arg="first"/>`);
179175

180176
this.renderComponent(Root, { Greeting: HelloWorld });
181177

@@ -201,7 +197,7 @@ class DebugRenderTreeTest extends RenderTest {
201197
const noop = defineSimpleModifier(noopFn);
202198
const Root = defComponent(
203199
`<HelloWorld {{noop}} @arg="first"/>{{#if state.showSecond}}<HelloWorld @arg="second"/>{{/if}}`,
204-
{ scope: { HelloWorld, state, noop }, emit: { moduleName: 'root.hbs' } }
200+
{ scope: { HelloWorld, state, noop } }
205201
);
206202

207203
this.renderComponent(Root);
@@ -214,7 +210,7 @@ class DebugRenderTreeTest extends RenderTest {
214210
name: '{ROOT}',
215211
args: { positional: [], named: {} },
216212
instance: null,
217-
template: 'root.hbs',
213+
template: '(unknown template module)',
218214
bounds: this.elementBounds(element),
219215
children: [
220216
{

packages/@glimmer/compiler/lib/compiler.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -123,10 +123,6 @@ export function precompile(
123123
): TemplateJavascript {
124124
const [block, usedLocals] = precompileJSON(source, options);
125125

126-
if ('emit' in options && options.emit?.debugSymbols && usedLocals.length > 0) {
127-
block.push(usedLocals);
128-
}
129-
130126
const moduleName = options.meta?.moduleName;
131127
const idFn = options.id || defaultId;
132128
const blockJSON = JSON.stringify(block);

packages/@glimmer/interfaces/lib/compile/wire-format/api.d.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,6 @@ export type SerializedTemplateBlock = [
373373
statements: Statements.Statement[],
374374
locals: string[],
375375
upvars: string[],
376-
lexicalSymbols?: string[],
377376
];
378377

379378
/**

packages/@glimmer/opcode-compiler/lib/opcode-builder/helpers/shared.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,14 +106,14 @@ export function CompilePositional(
106106
}
107107

108108
export function meta(layout: LayoutWithContext): BlockMetadata {
109-
let [, locals, upvars, lexicalSymbols] = layout.block;
109+
let [, locals, upvars] = layout.block;
110110
let scopeRecord = layout.scope?.() ?? null;
111111

112112
return {
113113
symbols: {
114114
locals,
115115
upvars,
116-
lexical: scopeRecord ? Object.keys(scopeRecord) : lexicalSymbols,
116+
lexical: scopeRecord ? Object.keys(scopeRecord) : undefined,
117117
},
118118
scopeValues: scopeRecord ? Object.values(scopeRecord) : null,
119119
isStrictMode: layout.isStrictMode,

packages/@glimmer/syntax/lib/parser/tokenizer-event-handlers.ts

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -688,16 +688,6 @@ export interface PrecompileOptions extends PreprocessOptions {
688688

689689
export interface PrecompileOptionsWithLexicalScope extends PrecompileOptions {
690690
lexicalScope: (variable: string) => boolean;
691-
692-
/**
693-
* If `emit.debugSymbols` is set to `true`, the name of lexical local variables
694-
* will be included in the wire format.
695-
*/
696-
emit?:
697-
| {
698-
debugSymbols?: boolean;
699-
}
700-
| undefined;
701691
}
702692

703693
export interface PreprocessOptions {

0 commit comments

Comments
 (0)