Conversation
There was a problem hiding this comment.
The PR introduces a critical circular self-import bug in lib/index.ts (the module imports from './index' — itself), which will cause all referenced symbols to be undefined at runtime. Additionally, embedding CDS plugin registration side-effects directly in the public lib/index.ts barrel means those side-effects fire for any consumer who imports from the library, not just when the plugin is bootstrapped. Both issues need to be addressed before this can be merged safely.
PR Bot Information
Version: 1.19.1 | 📖 Documentation | 🚨 Create Incident | 💬 Feedback
- Event Trigger:
pull_request.opened - Correlation ID:
e9bc5580-23db-11f1-832f-78869b260faa - LLM:
anthropic--claude-4.6-sonnet
994735c to
0e0b2df
Compare
a19c4ae to
92378da
Compare
92378da to
aceca15
Compare
| "version": "1.0.0", | ||
| "description": "", | ||
| "main": "cds-plugin.ts", | ||
| "main": "cds-plugin.js", |
There was a problem hiding this comment.
dbdcb96 to
ad4470d
Compare
SummaryThe following content is AI-generated and provides a summary of the pull request: Migrate Plugin Entry Point from TypeScript to Compiled JavaScriptRefactor♻️ Refactored the plugin to compile TypeScript sources to a Changes
PR Bot InformationVersion:
💌 Have ideas or want to contribute? Create an issue and share your thoughts with us! Made with ❤️ by Hyperspace. |
There was a problem hiding this comment.
The PR introduces a TypeScript-to-JavaScript compilation pipeline (tsconfig.build.json, npm run compile, JS shim files) to make the plugin publishable as plain JS. The structural changes are mostly sound, but two substantive issues were flagged:
-
Side-effect pollution in the barrel export (
lib/index.ts): Moving CDS event registrations into the shared barrel module means any import fromlib(including in tests) will trigger plugin registration as an unintended side effect. This logic should stay in the dedicatedcds-plugin.tsentry point. -
pretestonly coversnpm test: Sibling scripts liketest:watch,test:hana, andtest:hybridskip thecompilestep and may run against a staledist/directory.
Please address these before merging.
PR Bot Information
Version: 1.19.1 | 📖 Documentation | 🚨 Create Incident | 💬 Feedback
- Correlation ID:
1cac19e0-243a-11f1-895a-ad3474f63ca0 - LLM:
anthropic--claude-4.6-sonnet - Event Trigger:
pull_request.ready_for_review
| "outDir": "./dist", | ||
| "rootDir": "." | ||
| }, | ||
| "include": ["./cds-plugin.ts", "./srv/**/*.ts", "./lib/**/*.ts"], |
There was a problem hiding this comment.
Bug: cds-plugin.ts is included in the build but its compiled output (dist/cds-plugin.js) will never be used at runtime.
The root-level cds-plugin.js shim already requires ./dist/cds-plugin, so dist/cds-plugin.js would just re-export dist/lib/index.js. However, the real entry point consumed by consumers is the root cds-plugin.js → dist/cds-plugin.js → dist/lib/index.js chain. Including ./cds-plugin.ts in the build is harmless but creates an extra indirection layer in the output. More critically, since cds-plugin.ts only does import './lib', the compiled dist/cds-plugin.js will require ./lib — but inside dist/, lib is at dist/lib, not a sibling lib/. The relative path ./lib from dist/cds-plugin.js resolves correctly only if the output mirrors the source structure. With rootDir: "." and outDir: "./dist", dist/cds-plugin.js will emit require("./lib") which resolves to dist/lib/index.js — this is correct. No immediate breakage, but the chain is fragile. Consider verifying the compiled output resolves as expected.
Please provide feedback on the review comment by checking the appropriate box:
- 🌟 Awesome comment, a human might have missed that.
- ✅ Helpful comment
- 🤷 Neutral
- ❌ This comment is not helpful
| ], | ||
| "scripts": { | ||
| "prebuild": "npm run compile", | ||
| "pretest": "npm run compile", |
There was a problem hiding this comment.
Bug: The pretest script runs npm run compile (TypeScript compilation), but the test:watch, test:hana, and test:hybrid scripts bypass pretest entirely since pre* hooks only fire for the exact script name they prefix. Developers running npm run test:hana or npm run test:watch may be testing against a stale dist/.
Consider either adding explicit compile calls in those scripts or documenting that npm test must be run first.
| "pretest": "npm run compile", | |
| "prebuild": "npm run compile", | |
| "pretest": "npm run compile", | |
| "test": "jest --silent --testPathIgnorePatterns=/tests/hybrid/programmaticApproach.test.ts", | |
| "test:watch": "npm run compile && jest --watch", | |
| "test:hana": "npm run compile && jest tests/integration --silent", | |
| "test:hybrid": "npm run compile && jest tests/hybrid --silent", |
Double-check suggestion before committing. Edit this comment for amendments.
Please provide feedback on the review comment by checking the appropriate box:
- 🌟 Awesome comment, a human might have missed that.
- ✅ Helpful comment
- 🤷 Neutral
- ❌ This comment is not helpful
| import { importProcess } from './processImport'; | ||
|
|
||
| // Register build plugin for annotation validation during cds build | ||
| cds.build?.register?.('process-validation', ProcessValidationPlugin); |
There was a problem hiding this comment.
Logic Error: Side-effect plugin code (CDS event registrations, import handler setup) has been moved into lib/index.ts, which is also a barrel re-export module. Any consumer who imports anything from lib/index.ts (e.g. in tests or programmatically) will inadvertently trigger cds.on('serving', ...), cds.on('served', ...), and cds.build?.register?.(...) as side effects.
This breaks the separation of concerns that existed when the plugin code was isolated in cds-plugin.ts. Consider moving the plugin registration logic back to cds-plugin.ts (importing from ./lib for shared utilities) and keeping lib/index.ts as a pure export barrel.
Please provide feedback on the review comment by checking the appropriate box:
- 🌟 Awesome comment, a human might have missed that.
- ✅ Helpful comment
- 🤷 Neutral
- ❌ This comment is not helpful
Have you...