Skip to content

Conversation

@elylucasctfl
Copy link
Contributor

This pull request introduces significant changes to the build system, package exports, and type exports for the Contentful Management API client. The main focus is on migrating the build process from Babel/Webpack to Rollup, modernizing the package structure for better compatibility with modern bundlers, and improving the type exports for easier consumption. There are also updates to CI/CD workflows and deprecation notices.

Build System and Packaging Modernization:

  • Migrated the build process from Babel/Webpack to Rollup, introducing a new rollup.config.js with configurations for ESM, CommonJS bundles, and type declarations. This change streamlines the build process and improves compatibility with modern JavaScript tooling. [1] [2] [3] [4]
  • Updated the package.json to use the new exports field for conditional exports (ESM, CJS, and types), set the new entry points, and removed legacy build scripts and fields. The minimum Node.js version is now 20. [1] [2] [3]
  • Added new build dependencies for Rollup and related plugins, and removed Babel/Webpack-specific scripts. [1] [2]

Type Exports and API Surface Improvements:

  • Promoted several types that were previously only available via deep imports (e.g., AppActionCallResponse, CommentStatus, EntryReferenceProps, ActionType, ConstraintType, WebhookCallDetailsProps, WebhookCallOverviewProps, WebhookHealthProps) to be exported directly from lib/export-types.ts, making them easier to import and improving DX. [1] [2] [3] [4] [5]
  • Exported OptionalDefaults from lib/plain/wrappers/wrap.ts in the main index, clarifying its intended usage as private and subject to change. [1] [2]

Release and CI/CD Updates:

  • Updated the GitHub Actions workflow to allow releases from a new branch (refs/heads/new-beta), supporting an additional prerelease channel. [1] [2]

Most Important Changes:

Build System and Packaging:

  • Migrated build process to Rollup with a new rollup.config.js, providing ESM, CJS, and type declaration outputs, and updated related scripts and dependencies in package.json. [1] [2] [3] [4]
  • Modernized package.json exports field for better bundler compatibility, updated entry points, and increased minimum Node.js version to 20. [1] [2]

Type Exports and API Surface:

  • Promoted several types for direct export from lib/export-types.ts, eliminating the need for deep imports and improving developer experience. [1] [2] [3] [4] [5]
  • Exported OptionalDefaults in the main index and clarified its private usage in documentation. [1] [2]

Deprecations and CI/CD:

  • Added a deprecation warning to the createClient method, guiding users towards newer alternatives.
  • Updated release workflow to support a new prerelease channel (new-beta). [1] [2]

AppActionCall,
AppActionCallProps,
AppActionCallErrorProps,
AppActionCallResponse, // was previously deep imported in user_interface
Copy link
Contributor Author

Choose a reason for hiding this comment

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

exported a few types that weren't exported before but imported deeply in user_interface

PlainClientAPI,
AppKeyProps,
} from '../../lib/contentful-management'
} from '../../lib/index'
Copy link
Contributor Author

Choose a reason for hiding this comment

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

all these test changes were importing from the main index file instead of contentful-management, which was renamed to index.ts

rollup.config.js Outdated
import commonjs from '@rollup/plugin-commonjs'
import json from '@rollup/plugin-json'
// import alias from '@rollup/plugin-alias'
// import terser from '@rollup/plugin-terser'
Copy link
Contributor Author

Choose a reason for hiding this comment

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

all the commented out code here was in support of creating the browser bundles, which I didn't do initially to save time, and I want to bring it up to the group if this is even worth keeping

types.d.ts Outdated
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this file was how the types were exported before. It was included as a part of the bundle at the root and allowed imports from 'contentful-management/types'

rollup.config.js Outdated
@@ -0,0 +1,221 @@
// import { resolve, dirname } from 'path'
Copy link
Collaborator

Choose a reason for hiding this comment

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

The file needs to be .mjs to work for me

rollup.config.js Outdated
}),
json(),
],
external: [/node_modules\/(?!tslib.*)/],
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
external: [/node_modules\/(?!tslib.*)/],
external: ['contentful-sdk-core', 'fast-copy', 'axios'],

Did this regex work for you? For me, they are not prefixed with node_modules.

When going with a simple array, it works well for me.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

When used in conjunction with nodeResolve, this will make it so no packages in node_modules (except tslib) get included in the bundle. Good precaution in case we add a new dependency and we don't remember to update these arrays.

rollup.config.js Outdated
__VERSION__: JSON.stringify(pkg.version),
}),
],
external: [/node_modules\/(?!tslib.*)/],
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
external: [/node_modules\/(?!tslib.*)/],
external: baseConfig.external,

Maybe using a extra variable for both spots makes more sense here

@axe312ger
Copy link
Collaborator

A few more things I found, and couldn't add a comment as review:

  • webpack config is still there, including some webpack related depdencies
  • .nvmrc is still on v18
  • you miss the updated SDK-Core beta in the package.json

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.

4 participants