Skip to content

Commit 50516ed

Browse files
wjhsfjhefferman-sfdc
authored andcommitted
chore: rename ephemeral placeholder variable (#5210)
1 parent 807f4d6 commit 50516ed

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

packages/@lwc/ssr-compiler/src/compile-js/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ const visitors: Visitors = {
244244
},
245245
Identifier(path, _state) {
246246
const { node } = path;
247-
if (node?.name.startsWith('__lwc') && node.name.endsWith('__')) {
247+
if (node?.name.startsWith('__lwc')) {
248248
// TODO [#5032]: Harmonize errors thrown in `@lwc/ssr-compiler`
249249
throw new Error(`LWCTODO: identifier name '${node.name}' cannot start with '__lwc'`);
250250
}

packages/@lwc/ssr-compiler/src/estemplate.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@ import type { Checker } from 'estree-toolkit/dist/generated/is-type';
2020
/** Placeholder value to use to opt out of validation. */
2121
const NO_VALIDATION = false;
2222

23+
/**
24+
* `esTemplate` generates JS code with "holes" to be filled later. In order to have a valid AST,
25+
* it uses identifiers with this prefix at the location of the holes.
26+
*/
27+
const PLACEHOLDER_PREFIX = '__lwc_ESTEMPLATE_PLACEHOLDER__';
28+
2329
/** A function that accepts a node and checks that it is a particular type of node. */
2430
type Validator<T extends EsNode | null = EsNode | null> = (
2531
node: EsNode | null | undefined
@@ -65,8 +71,6 @@ type ToReplacementParameters<Arr extends unknown[]> = Arr extends [infer Head, .
6571
[ValidatedType<Head>, ...ToReplacementParameters<Rest>]
6672
: []; // `Arr` is an empty array -- nothing to transform
6773

68-
const PLACEHOLDER_PREFIX = `__ESTEMPLATE_${Math.random().toString().slice(2)}_PLACEHOLDER__`;
69-
7074
interface TraversalState {
7175
placeholderToValidator: Map<number, Validator>;
7276
replacementNodes: Array<EsNode | EsNode[] | null>;

0 commit comments

Comments
 (0)