Skip to content

10.8.0 breaks Java/Go transliteration for downstream jsii-rosetta consumers #2879

Description

@jsteinich

What happened

10.8.0 changed jsii.tsc: { outDir: "lib", rootDir: "src" } to jsii.tsconfig + validateTsconfig in package.json. That drops jsii.tsc.outDir, which downstream consumers need in order to map the shipped lib/*.d.ts paths back to the src/... symbol ids recorded in the assembly.

The consequence is that any tool transliterating TypeScript that imports constructs now emits incorrect Java and Go imports:

language expected actual on 10.8.0
Java import software.constructs.Construct; import constructs.Construct;
Go "github.com/aws/constructs-go/constructs" "github.com/aws-samples/dummy/constructs"

Python and C# are unaffected, but only coincidentally — rosetta's fallback name derivation (constructs, Constructs) happens to match the correct target names for those two languages.

The failure is silent: the assembly loads fine and the lookup just degrades to "not a jsii symbol", so the output looks plausible.

Reproduction

mkdir repro && cd repro && npm init -y
npm install jsii-rosetta@6.0.7 constructs@10.8.0

cat > snippet.ts <<'EOF'
import { Construct } from "constructs";
export class Foo extends Construct {
  constructor(scope: Construct, id: string) { super(scope, id); }
}
EOF

cat > run.js <<'EOF'
const rosetta = require("jsii-rosetta");
const fs = require("fs"), path = require("path");
const file = {
  contents: fs.readFileSync(path.join(__dirname, "snippet.ts"), "utf8"),
  fileName: path.join(__dirname, "snippet.ts"),
};
console.log("constructs", require("constructs/package.json").version);
for (const [name, V] of [["java", rosetta.JavaVisitor], ["go", rosetta.GoVisitor]]) {
  const { translation } = rosetta.translateTypeScript(file, new V(), {});
  console.log(" ", name.padEnd(4), "->", translation.split("\n").find((l) => /constructs/i.test(l)).trim());
}
EOF

node run.js
npm install constructs@10.7.2 && node run.js

10.7.2 is correct; 10.8.0 is not. Patching jsii.tsc back into the installed 10.8.0 package.json restores correct output with nothing else changed, which isolates it to this field.

Reproduced on both jsii-rosetta@5.9.39 and jsii-rosetta@6.0.7, so it is not resolved by consumers upgrading to the jsii 6.x toolchain.

Note

The underlying gap is in jsii itself: symbolIdentifier() falls back to assembly.metadata.tscRootDir when jsii.tsc.rootDir is absent, but has no equivalent fallback for outDir, and tsconfig.json is not published in the npm tarball. I have filed that separately as aws/jsii-compiler#2740.

Raising it here as well since constructs is likely the most widely consumed package to adopt jsii.tsconfig, and it may be worth restoring jsii.tsc.outDir/rootDir in a patch release until the jsii-side fix ships.

Environment

  • constructs 10.8.0 (broken) vs 10.7.2 (fine)
  • jsii-rosetta 6.0.7 / jsii 6.0.7, also 5.9.39 / 5.9.x
  • Node.js v22.22.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions