contentful-sdk-core icon indicating copy to clipboard operation
contentful-sdk-core copied to clipboard

modern esm support

Open axe312ger opened this issue 1 year ago • 3 comments

This PR, building upon #437, introduces comprehensive and up-to-date ESM support for the SDK-CORE, CMA, and CDA libraries.

Our goal is to transition these user-facing libraries to dual packages (both CommonJS and ESM compatible) as outlined in the Node.js documentation, with an added browser bundle for broader accessibility.

The SDK core will adopt an ESM-only format to guarantee compatibility with ESM-only dependencies, catering to our diverse range of customers by ensuring optimal usability across various JavaScript environments.

Complementary PRs for CDA and CMA are forthcoming. There's a potential need to standardize the CDA and CMA libraries on TypeScript and webpack for consistency, which I believe is crucial.

Change Summary

  • Upgraded to the latest versions of TypeScript and numerous other dependencies.
  • Incorporated the latest ESM-only dependencies, such as p-throttle.
  • Eliminated Rollup and bundle configurations, considering bundles are less ideal for node.js libraries intended as dependencies for other projects.
  • Transitioned from Jest to Vitest, allowing us to remove Babel and to finally get proper TS+ESM support in tests.
  • Discontinued the browser-specific build variant, acknowledging this package's primary function as a utility that does not run directly in browsers.
  • Simplified NPM scripts and streamlined package.json for better clarity.
  • The README has been updated to accurately reflect these modifications, along with previously unmentioned changes.
  • Cleaned up outdated elements, including remnants of chai, and removed workarounds for the prepublish script issue, which executed on every install.

Where we have to be careful

  • We should still ensure everything works well on all common environments
  • Our browser/node environment detection may not work anymore as expected. We could include testing the header into the test suite.

axe312ger avatar Feb 19 '24 16:02 axe312ger

The code itself looks great to me! This is a significant improvement and jumps out to me as a methodical approach to making it happen.

A few questions I have about the outstanding work:

1. This is a semantic version major/breaking release yes? Seems obvious but I'm not sure we've discussed it.

Yes, definitely a breaking change!

2. What is your thought on the testing process for this? I'd love to be able to deploy a canary/beta version of this for testing (+the CMA/CDA js changes), and can help out with that if so, though I don't have much experience working in this repo generally. I can also help out with some manual testing as needed.

I am testing currently extended on a local verdaccio server. As soon I am happy with it, I'll fix all the urls in the lock files to use public servers and we can deploy a public alpha version!

axe312ger avatar May 28 '24 18:05 axe312ger

Will fix:

  • https://github.com/contentful/contentful-sdk-core/issues/324

axe312ger avatar Jun 26 '24 12:06 axe312ger

This is published as 8.1.5-9.x-alpha.1 (Will be later published as v9 due to breaking changes)

axe312ger avatar Jul 13 '24 10:07 axe312ger

@mgoudy91 isnt the contenful.js already released using this?

We probably should release this then as well.

axe312ger avatar Sep 25 '24 12:09 axe312ger

:tada: This PR is included in version 9.0.0 :tada:

The release is available on:

Your semantic-release bot :package::rocket: