Skip to content

Conversation

@Raina451
Copy link
Collaborator

@Raina451 Raina451 commented Oct 3, 2025

SDK should be fully compatible across:

  • Node.js
  • Web browsers
  • All bundlers (Webpack, Vite, Rollup, etc.)
  • All frameworks (React, Vue, Angular, Next.js, etc.)
  • Both ESM and CJS module systems

Issues:

  • Single index.d.ts file was being used for both ESM and CommonJS, causing TypeScript to incorrectly identify the module format.
  • Node.js-specific dependencies were breaking browser bundles
  • Module Resolution Conflicts

Fix:

  • Updated entry points: main → CJS, module → ESM with proper extensions
  • added conditional exports with format-specific type mappings
  • added optionaldependencies in package.json (npm installs them automatically but doesn't fail if installation fails (browser environments))
  • Gets externalized by Rollup automatically (in our allDependencies array)

rollup.config.js

  • Added UMD browser bundle with Node.js dependency exclusions

  • Created separate type declaration builds (.mts, .cts, .d.ts)

  • Added environment-specific bundling logic

  • index.d.mts → ESM type declarations

  • index.d.cts → CommonJS type declarations

  • index.d.ts → Fallback for legacy tools

Removing unused pkg dependnecies from package.json
removing content-type from upload file method of buckets, as content type is not needed

Tested across:

  • react (create react app)
  • react + ts + vite
  • vue
  • webpack react
  • nodejs
  • nextjs
    • server side
    • client side
  • cjs
Screenshot 2025-10-03 at 4 19 44 PM

@Raina451 Raina451 requested a review from swati354 October 6, 2025 03:59
@Raina451 Raina451 requested a review from swati354 October 7, 2025 03:54
@swati354
Copy link
Collaborator

swati354 commented Oct 7, 2025

Since we removed the content-type parameter from uploadFile method, we would need to update the comments on that method as well.
In buckets.ts and buckets.models.ts

@Raina451 Raina451 force-pushed the fix/compatibility branch 3 times, most recently from 922e334 to 521eac2 Compare October 7, 2025 08:15
@Raina451 Raina451 requested a review from swati354 October 7, 2025 08:29
@Raina451 Raina451 changed the title Fix: package compatibility issues across platform and modules - [PLT-87136] Fix: package compatibility issues across platform and modules - [PLT-87136] [PLT-90390] [PLT-90489] Oct 7, 2025
@Raina451 Raina451 merged commit 211e87e into main Oct 7, 2025
5 checks passed
@Raina451 Raina451 deleted the fix/compatibility branch October 7, 2025 12:49
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.

2 participants