Skip to content

Commit 2064baa

Browse files
committed
fix(ci): harden preload bundle checks
1 parent d88a33e commit 2064baa

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

‎.github/workflows/ci.yml‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ on:
66
branches:
77
- main
88

9+
permissions:
10+
contents: read
11+
912
concurrency:
1013
group: ci-${{ github.event.pull_request.number || github.sha }}
1114
cancel-in-progress: ${{ github.event_name == 'pull_request' }}

‎apps/desktop/scripts/verify-preload-bundle.mjs‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,11 @@ const runtimeImports = [...source.matchAll(runtimeImportPattern)].map((match) =>
2121
const runtimeRequireCount = [...source.matchAll(/\brequire\s*\(/g)].length;
2222

2323
if (runtimeImports.length !== runtimeRequireCount) {
24-
throw new Error("Desktop preload bundle contains a dynamic runtime import");
24+
throw new Error("Desktop preload bundle contains a dynamic require() call");
25+
}
26+
27+
if (/\bimport\s*\(/.test(source)) {
28+
throw new Error("Desktop preload bundle contains a dynamic import() call");
2529
}
2630

2731
const sandboxModules = new Set(["electron", "events", "timers", "url"]);

0 commit comments

Comments
 (0)