Skip to content

cadl compile failed when package.json doesn't include all emitters defined in cadl-project.yaml #1457

@dw511214992

Description

@dw511214992

How to reproduce

  1. Get my cadl project
  2. npm install
  3. npx cadl compile . --emit @azure-tools/cadl-java --arg "java-sdk-folder=/tmp/java"

Result

Encounter Error:

error import-not-found: Couldn't resolve import "@azure-tools/cadl-python"
error emitter-not-found: Emitter with name @azure-tools/cadl-python is not found.

Found 2 errors.

Expect

Generate java sdk succesfully.

Root cause analysis:

The package.json's dependencies doesn't include emitter @azure-tools/cadl-python, which is defined in cadl-project.yaml.
As discussed with @weshaggard and @allenjzhang , package.json doesn't include any sdk emitters by default. When running in sdk automation pipeline, we only install the target sdk emitter in package.json. For example, I want to generate java sdk and I have installed @azure-tools/cadl-java in package.json, and then run command npx cadl compile . --emit @azure-tools/cadl-java --arg "java-sdk-folder=/tmp/java", cadl should generate java sdk and don't check whether @azure-tools/cadl-python exist or not when I specify the java emitter in command.
I also test this issue in cadl v0.37.* and it works well. So this issue only exists in v0.38.*.

Metadata

Metadata

Labels

design:neededA design request has been raised that needs a proposal

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions