Skip to content

Commit

Permalink
Merge pull request #1354 from glimmerjs/loose-lexical-part2
Browse files Browse the repository at this point in the history
Followup for loose-mode lexical scope
  • Loading branch information
rwjblue authored Oct 22, 2021
2 parents b1a69ad + 978c924 commit bdabdc4
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions packages/@glimmer/compiler/lib/compiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,19 +124,17 @@ export function precompile(
isStrictMode: options.strictMode ?? false,
};

if (!options.strictMode) {
if (usedLocals.length === 0) {
delete templateJSONObject.scope;
}

// JSON is javascript
let stringified = JSON.stringify(templateJSONObject);

if (options.strictMode && usedLocals.length > 0) {
if (usedLocals.length > 0) {
let scopeFn = `()=>[${usedLocals.join(',')}]`;

stringified = stringified.replace(`"${SCOPE_PLACEHOLDER}"`, scopeFn);
} else {
stringified = stringified.replace(`"${SCOPE_PLACEHOLDER}"`, 'null');
}

return stringified;
Expand Down

0 comments on commit bdabdc4

Please sign in to comment.