Skip to content

Commit d2e0254

Browse files
kfuledead-claudia
authored andcommitted
bundler: do not reset the suffix count if there is already a count
For some modules that are imported multiple times, it seems that the suffix count may be reset to 0. As a result, the suffix count does not increase, and a suffix may be added to the suffix, such as `mountRedraw00`. These double suffixes are annoying to fix, and it seems that `mountRedraw00` in the comments is corrected to `mountRedraw0`. This commit prevents double suffixes by preventing the suffix count reset. Some suffixes in the bundled mithril.js will change, but this is because the suffixes are correctly incremented, and the code will not be broken (i.e., mithril.min.js will remain unchanged).
1 parent e37966d commit d2e0254

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

scripts/_bundler-impl.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,9 @@ module.exports = async (input) => {
6464
const include = /(?:((?:var|let|const|,|)[\t ]*)([\w_$\.\[\]"'`]+)(\s*=\s*))?require\(([^\)]+)\)(\s*[`\.\(\[])?/gm
6565
let uuid = 0
6666
async function process(filepath, data) {
67-
for (const [, binding] of matchAll(data, declaration)) bindings.set(binding, 0)
67+
for (const [, binding] of matchAll(data, declaration)) {
68+
if (!bindings.has(binding)) bindings.set(binding, 0)
69+
}
6870

6971
const tasks = []
7072

0 commit comments

Comments
 (0)