diff --git a/crates/turborepo/tests/query.rs b/crates/turborepo/tests/query.rs index 09dfa06c8ec258..d46b6df73029e6 100644 --- a/crates/turborepo/tests/query.rs +++ b/crates/turborepo/tests/query.rs @@ -62,7 +62,6 @@ fn test_trace() -> Result<(), anyhow::Error> { "get `import_value_and_type.ts` with all dependencies" => "query { file(path: \"import_value_and_type.ts\") { path dependencies(importType: ALL) { files { items { path } } } } }", "get `import_value_and_type.ts` with type dependencies" => "query { file(path: \"import_value_and_type.ts\") { path dependencies(importType: TYPES) { files { items { path } } } } }", "get `import_value_and_type.ts` with value dependencies" => "query { file(path: \"import_value_and_type.ts\") { path dependencies(importType: VALUES) { files { items { path } } } } }", - "get `export_conditions` with dependencies" => "query { file(path: \"export_conditions.js\") { path dependencies(depth: 1) { files { items { path } } } } }", "get `incorrect_extension.mjs` with dependencies" => "query { file(path: \"incorrect_extension.mjs\") { path dependencies(depth: 1) { files { items { path } } } } }", ); diff --git a/crates/turborepo/tests/snapshots/query__turbo_trace_get_`export_conditions`_with_dependencies_(npm@10.5.0).snap b/crates/turborepo/tests/snapshots/query__turbo_trace_get_`export_conditions`_with_dependencies_(npm@10.5.0).snap index f014e64198a2b0..54a3d9b644064f 100644 --- a/crates/turborepo/tests/snapshots/query__turbo_trace_get_`export_conditions`_with_dependencies_(npm@10.5.0).snap +++ b/crates/turborepo/tests/snapshots/query__turbo_trace_get_`export_conditions`_with_dependencies_(npm@10.5.0).snap @@ -10,7 +10,7 @@ expression: query_output "files": { "items": [ { - "path": "node_modules/swr/dist/core/index.mjs" + "path": "node_modules/swr/dist/core/index.d.mts" } ] } diff --git a/crates/turborepo/tests/snapshots/query__turbo_trace_get_`main.ts`_with_ast_(npm@10.5.0).snap b/crates/turborepo/tests/snapshots/query__turbo_trace_get_`main.ts`_with_ast_(npm@10.5.0).snap index 886d8e1495543b..411469777270d8 100644 --- a/crates/turborepo/tests/snapshots/query__turbo_trace_get_`main.ts`_with_ast_(npm@10.5.0).snap +++ b/crates/turborepo/tests/snapshots/query__turbo_trace_get_`main.ts`_with_ast_(npm@10.5.0).snap @@ -10,7 +10,7 @@ expression: query_output "type": "Module", "span": { "start": 1, - "end": 173 + "end": 119 }, "body": [ { @@ -91,49 +91,11 @@ expression: query_output "with": null, "phase": "evaluation" }, - { - "type": "ImportDeclaration", - "span": { - "start": 65, - "end": 100 - }, - "specifiers": [ - { - "type": "ImportDefaultSpecifier", - "span": { - "start": 72, - "end": 78 - }, - "local": { - "type": "Identifier", - "span": { - "start": 72, - "end": 78 - }, - "ctxt": 0, - "value": "repeat", - "optional": false - } - } - ], - "source": { - "type": "StringLiteral", - "span": { - "start": 84, - "end": 99 - }, - "value": "repeat-string", - "raw": "\"repeat-string\"" - }, - "typeOnly": false, - "with": null, - "phase": "evaluation" - }, { "type": "VariableDeclaration", "span": { - "start": 102, - "end": 130 + "start": 66, + "end": 94 }, "ctxt": 0, "kind": "const", @@ -142,14 +104,14 @@ expression: query_output { "type": "VariableDeclarator", "span": { - "start": 108, - "end": 129 + "start": 72, + "end": 93 }, "id": { "type": "Identifier", "span": { - "start": 108, - "end": 114 + "start": 72, + "end": 78 }, "ctxt": 0, "value": "button", @@ -159,15 +121,15 @@ expression: query_output "init": { "type": "NewExpression", "span": { - "start": 117, - "end": 129 + "start": 81, + "end": 93 }, "ctxt": 0, "callee": { "type": "Identifier", "span": { - "start": 121, - "end": 127 + "start": 85, + "end": 91 }, "ctxt": 0, "value": "Button", @@ -183,27 +145,27 @@ expression: query_output { "type": "ExpressionStatement", "span": { - "start": 132, - "end": 148 + "start": 96, + "end": 112 }, "expression": { "type": "CallExpression", "span": { - "start": 132, - "end": 147 + "start": 96, + "end": 111 }, "ctxt": 0, "callee": { "type": "MemberExpression", "span": { - "start": 132, - "end": 145 + "start": 96, + "end": 109 }, "object": { "type": "Identifier", "span": { - "start": 132, - "end": 138 + "start": 96, + "end": 102 }, "ctxt": 0, "value": "button", @@ -212,8 +174,8 @@ expression: query_output "property": { "type": "Identifier", "span": { - "start": 139, - "end": 145 + "start": 103, + "end": 109 }, "value": "render" } @@ -225,73 +187,21 @@ expression: query_output { "type": "ExpressionStatement", "span": { - "start": 149, - "end": 166 - }, - "expression": { - "type": "CallExpression", - "span": { - "start": 149, - "end": 165 - }, - "ctxt": 0, - "callee": { - "type": "Identifier", - "span": { - "start": 149, - "end": 155 - }, - "ctxt": 0, - "value": "repeat", - "optional": false - }, - "arguments": [ - { - "spread": null, - "expression": { - "type": "StringLiteral", - "span": { - "start": 156, - "end": 161 - }, - "value": "foo", - "raw": "\"foo\"" - } - }, - { - "spread": null, - "expression": { - "type": "NumericLiteral", - "span": { - "start": 163, - "end": 164 - }, - "value": 5.0, - "raw": "5" - } - } - ], - "typeArguments": null - } - }, - { - "type": "ExpressionStatement", - "span": { - "start": 167, - "end": 173 + "start": 113, + "end": 119 }, "expression": { "type": "CallExpression", "span": { - "start": 167, - "end": 172 + "start": 113, + "end": 118 }, "ctxt": 0, "callee": { "type": "Identifier", "span": { - "start": 167, - "end": 170 + "start": 113, + "end": 116 }, "ctxt": 0, "value": "foo", diff --git a/crates/turborepo/tests/snapshots/query__turbo_trace_get_`main.ts`_with_dependencies_(npm@10.5.0).snap b/crates/turborepo/tests/snapshots/query__turbo_trace_get_`main.ts`_with_dependencies_(npm@10.5.0).snap index 60af6161734f8c..8b647d5a2b9af5 100644 --- a/crates/turborepo/tests/snapshots/query__turbo_trace_get_`main.ts`_with_dependencies_(npm@10.5.0).snap +++ b/crates/turborepo/tests/snapshots/query__turbo_trace_get_`main.ts`_with_dependencies_(npm@10.5.0).snap @@ -23,9 +23,6 @@ expression: query_output }, { "path": "foo.js" - }, - { - "path": "node_modules/repeat-string/index.js" } ] } diff --git a/crates/turborepo/tests/snapshots/query__turbo_trace_get_`main.ts`_with_depth_=_0_(npm@10.5.0).snap b/crates/turborepo/tests/snapshots/query__turbo_trace_get_`main.ts`_with_depth_=_0_(npm@10.5.0).snap index d555c7a3902920..30ae77ff69475c 100644 --- a/crates/turborepo/tests/snapshots/query__turbo_trace_get_`main.ts`_with_depth_=_0_(npm@10.5.0).snap +++ b/crates/turborepo/tests/snapshots/query__turbo_trace_get_`main.ts`_with_depth_=_0_(npm@10.5.0).snap @@ -14,9 +14,6 @@ expression: query_output }, { "path": "foo.js" - }, - { - "path": "node_modules/repeat-string/index.js" } ] } diff --git a/crates/turborepo/tests/snapshots/query__turbo_trace_monorepo_get_`apps__my-app__index.ts`_with_dependencies_(npm@10.5.0).snap b/crates/turborepo/tests/snapshots/query__turbo_trace_monorepo_get_`apps__my-app__index.ts`_with_dependencies_(npm@10.5.0).snap index 2c7e1175a20c92..08f519ad0fe36e 100644 --- a/crates/turborepo/tests/snapshots/query__turbo_trace_monorepo_get_`apps__my-app__index.ts`_with_dependencies_(npm@10.5.0).snap +++ b/crates/turborepo/tests/snapshots/query__turbo_trace_monorepo_get_`apps__my-app__index.ts`_with_dependencies_(npm@10.5.0).snap @@ -18,6 +18,9 @@ expression: query_output { "path": "packages/module-package/my-module.mjs" }, + { + "path": "packages/package-with-conditions/index.mjs" + }, { "path": "packages/ship-types/index.ts" }, @@ -26,6 +29,9 @@ expression: query_output }, { "path": "packages/utils/my-hook.ts" + }, + { + "path": "packages/utils/types.ts" } ] }, diff --git a/turborepo-tests/integration/fixtures/turbo_trace/export_conditions.js b/turborepo-tests/integration/fixtures/turbo_trace/export_conditions.js deleted file mode 100644 index 208c8ea240e279..00000000000000 --- a/turborepo-tests/integration/fixtures/turbo_trace/export_conditions.js +++ /dev/null @@ -1 +0,0 @@ -import useSWR from "swr"; diff --git a/turborepo-tests/integration/fixtures/turbo_trace/main.ts b/turborepo-tests/integration/fixtures/turbo_trace/main.ts index eb3cb80424d761..cc2a7cf2a1d1e1 100644 --- a/turborepo-tests/integration/fixtures/turbo_trace/main.ts +++ b/turborepo-tests/integration/fixtures/turbo_trace/main.ts @@ -1,9 +1,7 @@ import { Button } from "./button.tsx"; import foo from "./foo"; -import repeat from "repeat-string"; const button = new Button(); button.render(); -repeat("foo", 5); foo(); diff --git a/turborepo-tests/integration/fixtures/turbo_trace/package.json b/turborepo-tests/integration/fixtures/turbo_trace/package.json index e175c2b051724c..42f5810ec3ba61 100644 --- a/turborepo-tests/integration/fixtures/turbo_trace/package.json +++ b/turborepo-tests/integration/fixtures/turbo_trace/package.json @@ -4,10 +4,6 @@ "engines": { "node": ">=18" }, - "dependencies": { - "repeat-string": "^1.6.1", - "swr": "^2.2.5" - }, "workspaces": [ "apps/*", "packages/*" diff --git a/turborepo-tests/integration/fixtures/turbo_trace_monorepo/apps/my-app/index.ts b/turborepo-tests/integration/fixtures/turbo_trace_monorepo/apps/my-app/index.ts index 1e2dc77fa5fa3e..cc8748eda30285 100644 --- a/turborepo-tests/integration/fixtures/turbo_trace_monorepo/apps/my-app/index.ts +++ b/turborepo-tests/integration/fixtures/turbo_trace_monorepo/apps/my-app/index.ts @@ -4,3 +4,5 @@ import { blackbeard } from "../../packages/another/index.jsx"; import { Pirate } from "@/types.ts"; import { walkThePlank } from "module-package"; import type { Ship } from "ship"; +import type { Sword } from "utils/sword"; +import { catchphrase } from "package-with-conditions"; diff --git a/turborepo-tests/integration/fixtures/turbo_trace_monorepo/apps/my-app/package.json b/turborepo-tests/integration/fixtures/turbo_trace_monorepo/apps/my-app/package.json index 568ed85ca3eb38..521d6f8e04c18f 100644 --- a/turborepo-tests/integration/fixtures/turbo_trace_monorepo/apps/my-app/package.json +++ b/turborepo-tests/integration/fixtures/turbo_trace_monorepo/apps/my-app/package.json @@ -6,6 +6,7 @@ }, "dependencies": { "utils": "*", - "@types/ship": "*" + "@types/ship": "*", + "package-with-conditions": "*" } } diff --git a/turborepo-tests/integration/fixtures/turbo_trace_monorepo/packages/package-with-conditions/index.cjs b/turborepo-tests/integration/fixtures/turbo_trace_monorepo/packages/package-with-conditions/index.cjs new file mode 100644 index 00000000000000..2bd6926f73e2cd --- /dev/null +++ b/turborepo-tests/integration/fixtures/turbo_trace_monorepo/packages/package-with-conditions/index.cjs @@ -0,0 +1 @@ +module.exports = "Shiver me timbers, this be cjs"; diff --git a/turborepo-tests/integration/fixtures/turbo_trace_monorepo/packages/package-with-conditions/index.mjs b/turborepo-tests/integration/fixtures/turbo_trace_monorepo/packages/package-with-conditions/index.mjs new file mode 100644 index 00000000000000..dbe1c80d31a113 --- /dev/null +++ b/turborepo-tests/integration/fixtures/turbo_trace_monorepo/packages/package-with-conditions/index.mjs @@ -0,0 +1 @@ +export const catchphrase = "Shiver me timbers, this be mjs"; diff --git a/turborepo-tests/integration/fixtures/turbo_trace_monorepo/packages/package-with-conditions/package.json b/turborepo-tests/integration/fixtures/turbo_trace_monorepo/packages/package-with-conditions/package.json new file mode 100644 index 00000000000000..e9437e8f90ed67 --- /dev/null +++ b/turborepo-tests/integration/fixtures/turbo_trace_monorepo/packages/package-with-conditions/package.json @@ -0,0 +1,9 @@ +{ + "name": "package-with-conditions", + "exports": { + ".": { + "import": "./index.mjs", + "require": "./index.cjs" + } + } +} diff --git a/turborepo-tests/integration/fixtures/turbo_trace_monorepo/packages/utils/package.json b/turborepo-tests/integration/fixtures/turbo_trace_monorepo/packages/utils/package.json index 2184abb4f49898..dda910bca47d2e 100644 --- a/turborepo-tests/integration/fixtures/turbo_trace_monorepo/packages/utils/package.json +++ b/turborepo-tests/integration/fixtures/turbo_trace_monorepo/packages/utils/package.json @@ -7,6 +7,9 @@ "main": "index.ts", "exports": { ".": "./index.ts", - "./my-hook": "./my-hook.ts" + "./my-hook": "./my-hook.ts", + "./sword": { + "types": "./types.ts" + } } } diff --git a/turborepo-tests/integration/fixtures/turbo_trace_monorepo/packages/utils/types.ts b/turborepo-tests/integration/fixtures/turbo_trace_monorepo/packages/utils/types.ts new file mode 100644 index 00000000000000..e31e045f7c900d --- /dev/null +++ b/turborepo-tests/integration/fixtures/turbo_trace_monorepo/packages/utils/types.ts @@ -0,0 +1 @@ +export type Sword = "Saber" | "Epee" | "Foil";