-
Notifications
You must be signed in to change notification settings - Fork 386
fix(types): expose types when using Webex from plugin-cc #4376
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
📝 WalkthroughWalkthroughThe change updates the exports field in the package.json file of the @webex/plugin-cc package. The previous configuration, which mapped the main export to a single JavaScript file, is replaced with an object specifying separate "import", "require", and "types" entries. This explicitly defines the JavaScript entry points for ES modules and CommonJS, as well as the TypeScript type declarations. The export for "./package" remains unchanged. No code or public API changes are involved; only the package manifest is updated. Possibly related PRs
📜 Recent review detailsConfiguration used: .coderabbit.yaml 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ Context from checks skipped due to timeout of 90000ms (1)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
packages/@webex/plugin-cc/package.json(1 hunks)
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: robstax
PR: webex/webex-js-sdk#3948
File: packages/@webex/webex-core/test/unit/spec/webex-core.js:178-254
Timestamp: 2024-11-01T00:30:53.442Z
Learning: In the webex-js-sdk project, when reviewing changes in `packages/@webex/webex-core/test/unit/spec/webex-core.js`, if the user declines to add negative test cases for invalid interceptor configurations, accept their decision and do not insist.
Learnt from: Kesari3008
PR: webex/webex-js-sdk#4258
File: packages/@webex/plugin-cc/src/webex.js:0-0
Timestamp: 2025-05-13T17:01:05.340Z
Learning: In the webex-js-sdk project, `PACKAGE_VERSION` is a constant that's injected by the build system and doesn't need to be explicitly imported in the source files.
Learnt from: pagour98
PR: webex/webex-js-sdk#4086
File: packages/@webex/plugin-cc/test/unit/spec/services/task/dialer.ts:52-57
Timestamp: 2025-02-12T10:13:06.265Z
Learning: In packages/@webex/plugin-cc tests, catch blocks in test cases follow CC Desktop pattern using `expect(true).toBe(true)` for consistency.
packages/@webex/plugin-cc/package.json (3)
Learnt from: Kesari3008
PR: webex/webex-js-sdk#4258
File: packages/@webex/plugin-cc/src/webex.js:0-0
Timestamp: 2025-05-13T17:01:05.340Z
Learning: In the webex-js-sdk project, `PACKAGE_VERSION` is a constant that's injected by the build system and doesn't need to be explicitly imported in the source files.
Learnt from: pagour98
PR: webex/webex-js-sdk#4086
File: packages/@webex/plugin-cc/test/unit/spec/services/task/dialer.ts:52-57
Timestamp: 2025-02-12T10:13:06.265Z
Learning: In packages/@webex/plugin-cc tests, catch blocks in test cases follow CC Desktop pattern using `expect(true).toBe(true)` for consistency.
Learnt from: robstax
PR: webex/webex-js-sdk#3948
File: packages/@webex/webex-core/test/unit/spec/webex-core.js:178-254
Timestamp: 2024-11-01T00:30:53.442Z
Learning: In the webex-js-sdk project, when reviewing changes in `packages/@webex/webex-core/test/unit/spec/webex-core.js`, if the user declines to add negative test cases for invalid interceptor configurations, accept their decision and do not insist.
⏰ Context from checks skipped due to timeout of 90000ms (2)
- GitHub Check: Initialize Project
- GitHub Check: AWS Amplify Console Web Preview
| ".": { | ||
| "import": "./dist/webex.js", | ||
| "types": "./dist/types/index.d.ts" | ||
| }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
CommonJS require() will throw – add require/default conditions
Node’s resolution algorithm ignores the top-level main field once an exports map is present.
Because the new map only exposes the "import" condition, a consumer that does
require('@webex/plugin-cc') will now receive
Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath '.' is not defined …
Add a require (or at least default) condition that points to the same built file, or publish a dedicated .cjs build if you ship dual bundles.
".": {
"import": "./dist/webex.js",
+ "require": "./dist/webex.js",
+ "default": "./dist/webex.js",
"types": "./dist/types/index.d.ts"
},Failing to do so is a breaking change for every CommonJS consumer of plugin-cc.
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| ".": { | |
| "import": "./dist/webex.js", | |
| "types": "./dist/types/index.d.ts" | |
| }, | |
| ".": { | |
| "import": "./dist/webex.js", | |
| "require": "./dist/webex.js", | |
| "default": "./dist/webex.js", | |
| "types": "./dist/types/index.d.ts" | |
| }, |
🤖 Prompt for AI Agents
In packages/@webex/plugin-cc/package.json around lines 18 to 21, the exports map
only includes the "import" condition, causing CommonJS require() calls to fail
with a package path not exported error. To fix this, add a "require" condition
(or at least a "default" condition) alongside "import" in the exports map that
points to the same built file (e.g., "./dist/webex.js") so CommonJS consumers
can resolve the package correctly without errors.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added require.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Shreyas281299 Perfect! Thank you for adding the require condition to the exports map. This ensures that both ES module imports and CommonJS require() calls will work correctly, preventing the "Package subpath '.' is not defined" error for CommonJS consumers.
The fix maintains backward compatibility while properly exposing the TypeScript types. 🎉
🧠 Learnings used
Learnt from: Kesari3008
PR: webex/webex-js-sdk#4258
File: packages/@webex/plugin-cc/src/webex.js:0-0
Timestamp: 2025-05-13T17:01:05.340Z
Learning: In the webex-js-sdk project, `PACKAGE_VERSION` is a constant that's injected by the build system and doesn't need to be explicitly imported in the source files.
Learnt from: pagour98
PR: webex/webex-js-sdk#4086
File: packages/@webex/plugin-cc/test/unit/spec/services/task/dialer.ts:52-57
Timestamp: 2025-02-12T10:13:06.265Z
Learning: In packages/@webex/plugin-cc tests, catch blocks in test cases follow CC Desktop pattern using `expect(true).toBe(true)` for consistency.
Learnt from: robstax
PR: webex/webex-js-sdk#3948
File: packages/@webex/webex-core/test/unit/spec/webex-core.js:178-254
Timestamp: 2024-11-01T00:30:53.442Z
Learning: In the webex-js-sdk project, when reviewing changes in `packages/@webex/webex-core/test/unit/spec/webex-core.js`, if the user declines to add negative test cases for invalid interceptor configurations, accept their decision and do not insist.
If you found this review helpful, would you consider giving us a shout-out on X?
Thank you for using CodeRabbit!
adhmenon
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's also see if the coderabbit suggestion is valid
|
This pull request is automatically being deployed by Amplify Hosting (learn more). |
COMPLETES # Adhoc
This pull request addresses
by making the following changes
Change Type
The following scenarios were tested
After

The GAI Coding Policy And Copyright Annotation Best Practices
I certified that
Make sure to have followed the contributing guidelines before submitting.