Skip to content

Commit 082c583

Browse files
authored
Fix excludeBuiltins (#292)
1 parent 3fd937f commit 082c583

File tree

4 files changed

+15
-12
lines changed

4 files changed

+15
-12
lines changed

scripts/get-browser-globals.mjs

-3
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,6 @@ async function getBrowserGlobals() {
307307
{
308308
shouldExclude,
309309
isWritable,
310-
excludeBuiltins: true,
311310
},
312311
);
313312
}
@@ -320,7 +319,6 @@ async function getWebWorkerGlobals() {
320319
{
321320
shouldExclude: name => name.startsWith('__'),
322321
isWritable: name => name.startsWith('on'),
323-
excludeBuiltins: true,
324322
},
325323
);
326324
}
@@ -337,7 +335,6 @@ async function getServiceWorkerGlobals() {
337335
{
338336
shouldExclude: name => name.startsWith('__'),
339337
isWritable: name => name.startsWith('on'),
340-
excludeBuiltins: true,
341338
},
342339
);
343340
}

scripts/get-node-builtin-globals.mjs

-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ export default function getNodeBuiltinGlobals() {
55
getGlobalThisProperties(),
66
{
77
shouldExclude: name => name.startsWith('__'),
8-
excludeBuiltins: true,
98
},
109
);
1110
}

scripts/update.mjs

+2
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ async function run(options) {
5858
: ALL_JOBS;
5959

6060
for (const {environment, getGlobals, incremental = true} of jobs) {
61+
const excludeBuiltins = environment !== 'builtin';
6162
const {
6263
added,
6364
removed,
@@ -68,6 +69,7 @@ async function run(options) {
6869
getGlobals,
6970
dryRun: options.dry,
7071
incremental: options.clean ? false : incremental,
72+
excludeBuiltins,
7173
});
7274

7375
console.log(`✅ ${environment} globals updated.`);

scripts/utilities.mjs

+13-8
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,26 @@ const writeGlobals = async (environment, globals) => {
1919
await fs.writeFile(file, code + '\n');
2020
};
2121

22-
async function updateGlobals({environment, getGlobals, dryRun, incremental}) {
22+
async function updateGlobals({
23+
environment,
24+
getGlobals,
25+
dryRun,
26+
incremental,
27+
excludeBuiltins,
28+
}) {
2329
let updated = await getGlobals();
2430
const original = await readGlobals(environment, {ignoreNonExits: true});
2531

2632
if (incremental) {
2733
updated = {...original, ...updated};
2834
}
2935

36+
if (excludeBuiltins) {
37+
for (const name of Object.keys(await readGlobals('builtin'))) {
38+
delete updated[name];
39+
}
40+
}
41+
3042
if (!dryRun) {
3143
await writeGlobals(environment, updated);
3244
}
@@ -58,20 +70,13 @@ function getGlobalThisProperties() {
5870
async function createGlobals(names, {
5971
shouldExclude,
6072
isWritable = () => false,
61-
excludeBuiltins,
6273
}) {
6374
names = unique(names);
6475

6576
if (shouldExclude) {
6677
names = names.filter(name => !shouldExclude(name));
6778
}
6879

69-
if (excludeBuiltins) {
70-
const builtinGlobals = new Set(Object.keys(await readGlobals('builtin')));
71-
72-
names = names.filter(name => !builtinGlobals.has(name));
73-
}
74-
7580
return Object.fromEntries(names.map(name => [name, isWritable(name) ?? false]));
7681
}
7782

0 commit comments

Comments
 (0)