Skip to content

Commit fb2343c

Browse files
alexander-akaitclaude
authored andcommitted
fix(javascript): keep the mapped source apart from the printer's state
The map reads the source it points into from its own variable, now that the printer keeps no copy of it; and the closure check from main drops its byte check for what only the two-pass compressor writes. Claude-Session: https://claude.ai/code/session_01Tgxgyb4N35ndP6cC4KcrXC
1 parent 39e558a commit fb2343c

2 files changed

Lines changed: 7 additions & 2 deletions

File tree

‎lib/javascript/syntax-printer.js‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60747,6 +60747,8 @@ const createNodePrinter = (modules) => {
6074760747
// in and where in that node's text it starts, three numbers a child.
6074860748
/** @type {number[] | null} */
6074960749
let placements = null;
60750+
// The source those mappings point into.
60751+
let mappedSource = "";
6075060752
// The child whose text the next piece printed is, 0 for none.
6075160753
let placingChild = 0;
6075260754
// Whether statements, members and cases print on lines of their own.
@@ -68558,7 +68560,10 @@ const createNodePrinter = (modules) => {
6855868560
/** @type {number[]} */
6855968561
const lineStarts = [0];
6856068562
const breaks = /\r\n?|[\n\u2028\u2029]/g;
68561-
while (breaks.exec(sourceText) !== null) lineStarts.push(breaks.lastIndex);
68563+
while (breaks.exec(mappedSource) !== null) {
68564+
lineStarts.push(breaks.lastIndex);
68565+
}
68566+
mappedSource = "";
6856268567
/** @type {number[]} */
6856368568
const mappings = [];
6856468569
/** @type {string[]} */
@@ -68623,6 +68628,7 @@ const createNodePrinter = (modules) => {
6862368628
}
6862468629
inlinesNames = printOptions.inlinesNames === true;
6862568630
placements = context.mapWanted ? [] : null;
68631+
mappedSource = context.mapWanted ? text : "";
6862668632
placingChild = 0;
6862768633
mangledNames = printOptions.names ? printOptions.names.definitions : null;
6862868634
treeAliases = printOptions.names ? printOptions.names.aliases : null;

‎test/configCases/optimization/minify-closure-let-writes/test.config.js‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ module.exports = {
99
path.join(options.output.path, "bundle0.js"),
1010
"utf8"
1111
);
12-
expect(code).not.toContain("lastSeen");
1312
expect(code).toContain("pending=");
1413
expect(code).toContain("seen=");
1514
}

0 commit comments

Comments
 (0)