Skip to content

Commit

Permalink
Merge pull request #2840 from cloudflare/dominik/skip-snapshot-imports
Browse files Browse the repository at this point in the history
Don't include implicit stdlib snapshot imports in package snapshot key.
  • Loading branch information
dom96 authored Oct 3, 2024
2 parents 3e6246a + 60b2570 commit e8f21f4
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/pyodide/internal/snapshot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -275,12 +275,17 @@ function memorySnapshotDoImports(Module: Module): Array<string> {
const localModulePaths: Set<string> = new Set<string>(
MetadataReader.getNames()
);
const SNAPSHOT_IMPORTS_SET = new Set(SNAPSHOT_IMPORTS);
const importedModules: Array<string> = ArtifactBundler.constructor
// @ts-ignore parsePythonScriptImports is a static method.
.parsePythonScriptImports(MetadataReader.getWorkerFiles('py'))
.filter((module: string) => {
const moduleFilename = module.replace('.', '/') + '.py';
return !localModulePaths.has(moduleFilename) && module != 'js';
return (
!localModulePaths.has(moduleFilename) &&
module != 'js' &&
!SNAPSHOT_IMPORTS_SET.has(module)
);
});

const deduplicatedModules = [...new Set(importedModules)];
Expand Down

0 comments on commit e8f21f4

Please sign in to comment.