Skip to content

Commit 08b1037

Browse files
NicolappsConvex, Inc.
authored andcommitted
node-executor: Don’t analyze contents of _deps (#40415)
When node-executor analyzes the contents of a Node module, it shouldn’t take into account chunk files (files in the `_deps` folder). These files are named with temporary names, so it wouldn’t make sense for users to want to expose a function from there. GitOrigin-RevId: 234abcb963f260732f3a4d2a0f7cc778dc544a14
1 parent c0a755d commit 08b1037

File tree

5 files changed

+18
-1
lines changed

5 files changed

+18
-1
lines changed

npm-packages/node-executor/src/source_package.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,10 @@ async function processExternalPackageStream(
304304

305305
type LocalSourcePackage = {
306306
dir: string;
307+
/**
308+
* The modules included in the package and that could contain Convex functions.
309+
* This doesn’t include bundler chunks (files in /_deps/).
310+
*/
307311
modules: Set<CanonicalizedModulePath>;
308312
dynamicallyDownloaded: boolean;
309313
};
@@ -440,7 +444,10 @@ function modulesFromMetadataJson(
440444
): Set<CanonicalizedModulePath> {
441445
const modules: Set<string> = new Set();
442446
for (const path of metadataJson.modulePaths) {
443-
if (path.endsWith(".js")) {
447+
if (path.startsWith("_deps/")) {
448+
// Ignore bundler chunks since they don’t contain Convex function definitions.
449+
continue;
450+
} else if (path.endsWith(".js")) {
444451
// Only load node files.
445452
const environment = metadataJson.moduleEnvironments.get(path);
446453
if (!environment) {

npm-packages/node-executor/test/integration-test.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -485,13 +485,19 @@ async function test_download() {
485485

486486
const local = await maybeDownloadAndLinkPackages(sourcePackage);
487487
const sourceDir = path.join(os.tmpdir(), `source/test_modules_key`);
488+
488489
assert.equal(local.dir, sourceDir);
489490
assert.equal(local.modules.has("a.js"), true);
490491
assert.equal(local.modules.has("someFolder/someFile.js"), true);
492+
491493
// Non-node modules
492494
assert.equal(local.modules.has("third_party.js"), false);
493495
assert.equal(local.modules.has("d.js"), false);
494496

497+
// We don’t include _deps in `.modules` since they can’t contain Convex functions
498+
assert.equal(local.modules.has("_deps/node/sample_node.js"), false);
499+
assert.equal(local.modules.has("_deps/sample_isolate.js"), false);
500+
495501
// Assert external deps package exists after download
496502
const externalDepsDir = path.join(
497503
os.tmpdir(),

npm-packages/node-executor/test/metadata.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
{
22
"modulePaths": [
3+
"_deps/node/sample_node.js",
4+
"_deps/sample_isolate.js",
35
"a.js",
46
"b.js",
57
"c.js",
@@ -18,6 +20,8 @@
1820
"transitive.js"
1921
],
2022
"moduleEnvironments": [
23+
["_deps/node/sample_node.js", "node"],
24+
["_deps/sample_isolate.js", "isolate"],
2125
["a.js", "node"],
2226
["b.js", "isolate"],
2327
["c.js", "isolate"],

npm-packages/node-executor/test/modules/_deps/node/sample_node.js

Whitespace-only changes.

npm-packages/node-executor/test/modules/_deps/sample_isolate.js

Whitespace-only changes.

0 commit comments

Comments
 (0)