diff --git a/src/services/stringCompletions.ts b/src/services/stringCompletions.ts
index 61c23266701fa..df0e24e558983 100644
--- a/src/services/stringCompletions.ts
+++ b/src/services/stringCompletions.ts
@@ -44,6 +44,7 @@ import {
flatten,
forEachAncestorDirectory,
getBaseFileName,
+ getConditions,
getContextualTypeFromParent,
getDirectoryPath,
getEffectiveTypeRoots,
@@ -924,7 +925,7 @@ function getCompletionEntriesForNonRelativeModules(
}
const keys = getOwnKeys(exports);
const fragmentSubpath = components.join("/") + (components.length && hasTrailingDirectorySeparator(fragment) ? "/" : "");
- const conditions = mode === ModuleKind.ESNext ? ["node", "import", "types"] : ["node", "require", "types"];
+ const conditions = getConditions(compilerOptions, mode === ModuleKind.ESNext);
addCompletionEntriesFromPathsOrExports(
result,
fragmentSubpath,
diff --git a/tests/cases/fourslash/pathCompletionsPackageJsonExportsBundlerNoNodeCondition.ts b/tests/cases/fourslash/pathCompletionsPackageJsonExportsBundlerNoNodeCondition.ts
new file mode 100644
index 0000000000000..13134b69605f3
--- /dev/null
+++ b/tests/cases/fourslash/pathCompletionsPackageJsonExportsBundlerNoNodeCondition.ts
@@ -0,0 +1,31 @@
+///
+
+// @moduleResolution: bundler
+
+// @Filename: /node_modules/foo/package.json
+//// {
+//// "name": "foo",
+//// "exports": {
+//// "./only-for-node": {
+//// "node": "./something.js"
+//// },
+//// "./for-everywhere": "./other.js",
+//// }
+//// }
+
+// @Filename: /node_modules/foo/something.d.ts
+//// export const index = 0;
+
+// @Filename: /node_modules/foo/other.d.ts
+//// export const index = 0;
+
+// @Filename: /index.ts
+//// import { } from "foo//**/";
+
+verify.completions({
+ marker: "",
+ isNewIdentifierLocation: true,
+ exact: [
+ { name: "for-everywhere", kind: "script", kindModifiers: "" },
+ ]
+});
diff --git a/tests/cases/fourslash/pathCompletionsPackageJsonExportsCustomConditions.ts b/tests/cases/fourslash/pathCompletionsPackageJsonExportsCustomConditions.ts
new file mode 100644
index 0000000000000..749bd13855f11
--- /dev/null
+++ b/tests/cases/fourslash/pathCompletionsPackageJsonExportsCustomConditions.ts
@@ -0,0 +1,28 @@
+///
+
+// @module: nodenext
+// @customConditions: custom-condition
+
+// @Filename: /node_modules/foo/package.json
+//// {
+//// "name": "foo",
+//// "exports": {
+//// "./only-with-custom-conditions": {
+//// "custom-condition": "./something.js"
+//// },
+//// }
+//// }
+
+// @Filename: /node_modules/foo/something.d.ts
+//// export const index = 0;
+
+// @Filename: /index.ts
+//// import { } from "foo//**/";
+
+verify.completions({
+ marker: "",
+ isNewIdentifierLocation: true,
+ exact: [
+ { name: "only-with-custom-conditions", kind: "script", kindModifiers: "" },
+ ]
+});