Skip to content

fix: correct export paths when sources are emitted to src/generated#3905

Open
Copilot wants to merge 8 commits intomainfrom
copilot/fix-emitter-output-references
Open

fix: correct export paths when sources are emitted to src/generated#3905
Copilot wants to merge 8 commits intomainfrom
copilot/fix-emitter-output-references

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 10, 2026

When the emitter detects an existing src/generated folder and correctly routes generated sources there, the export entries in warp.config.yml and package.json were still hardcoded to ./src/ — causing broken subpath references as shown in the screenshot above.

Changes

  • buildProjectFiles.ts
    • Switched SdkContext import to the local ../utils/interfaces.js version (which carries generationPathDetail)
    • Added getSourceRootPrefix() helper that derives the correct relative prefix (e.g. ./src or ./src/generated) by calling path.relative(rootDir, sourceRoot) against the actual modular sources directory
    • Applied the computed prefix in getModuleExports and buildExportsForMultiClient everywhere ./src/ was previously hardcoded
- ".": "./src/index.ts",
- "./models": "./src/models/index.ts",
- "./api": "./src/api/index.ts"
+ ".": "./src/generated/index.ts",
+ "./models": "./src/generated/models/index.ts",
+ "./api": "./src/generated/api/index.ts"

The prefix falls back to ./src when generationPathDetail is unavailable or the source root is outside the project root, preserving existing behaviour for all non-customised packages.

Copilot AI changed the title [WIP] Fix emitter output references in generated code fix: correct export paths when sources are emitted to src/generated Apr 10, 2026
Copilot AI requested a review from v-jiaodi April 10, 2026 08:22
@v-jiaodi v-jiaodi marked this pull request as ready for review April 14, 2026 05:30
@v-jiaodi
Copy link
Copy Markdown
Member

test result :
image

Copy link
Copy Markdown
Member

@JialinHuang803 JialinHuang803 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you help check if emitTests.ts should be updated?

Copy link
Copy Markdown
Contributor Author

Copilot AI commented Apr 20, 2026

Could you help check if emitTests.ts should be updated?

The hardcoded paths in emitTests.ts (../../src/index.js / ../../../src/index.js) are intentionally pointing to the public API entry point at src/index.ts, not to the internal generated code.

In the customization scenario (src/generated/ exists):

  • Generated code lands at src/generated/index.ts (emitter-owned)
  • The hand-written src/index.ts re-exports everything from src/generated/
  • Test files at test/generated/*.spec.ts import ../../src/index.js → the hand-written re-export → ✅ correct

Tests should always import through the public API (src/index.ts), not the internal generated folder. No changes needed in emitTests.ts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Emitter detects src/generated and used it as output, but references to it are wrong

3 participants