Skip to content
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

feat: Refine CJS/ESM build configuration for browser SDK. #640

Merged
merged 16 commits into from
Oct 29, 2024

Conversation

kinyoklion
Copy link
Member

@kinyoklion kinyoklion commented Oct 28, 2024

The goals here are to:

  • Make the build simpler.
  • Make the build "modern".

Currently we have worked around some build issues in other packages. Mainly with node module resolution. Despite the settings in the package.json node wants certain file extensions for certain types including .cts for the CJS type definitions.

So far tsup seems to be the simplest way to get all things with expected names without a multi-step process. Or without having to make a hack package.json that just has the modules type.

Please review #637 first.

"outDir": "dist",
"skipLibCheck": true,
// enables importers to jump to source
"sourceMap": true,
"sourceMap": false,
Copy link
Member Author

Choose a reason for hiding this comment

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

For the bundle-size task I will add some conditional configuration to a dev build and source maps.

Copy link
Member Author

Choose a reason for hiding this comment

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

The esbuild support actually means it can generate a meta data file, which can be used for the analysis instead. So no debug builds for now.

splitting: false,
sourcemap: false,
clean: true,
noExternal: ['@launchdarkly/js-sdk-common', '@launchdarkly/js-client-sdk-common'],
Copy link
Member Author

@kinyoklion kinyoklion Oct 28, 2024

Choose a reason for hiding this comment

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

So, the one thing that wasn't great about tsup is that it doesn't bundle dependencies unless they are dev dependencies. Which sounds fine, but then you need to figure out how to handle the typescript for those packages.

It has a method to bundle the typescript into .d.ts files as well, but that very much didn't work.

So this instructs it to not treat these as external. It does mean that you get these installed for a production build even though they are not then used. But that has been the precedent.

If the bundling of the typing worked, then that would be a reasonable alternative.

@kinyoklion kinyoklion marked this pull request as ready for review October 28, 2024 21:22
@kinyoklion kinyoklion requested a review from a team as a code owner October 28, 2024 21:22
Base automatically changed from rlamb/sdk-766/backward-compatibility-shim to main October 29, 2024 15:42
An error occurred while trying to automatically change base from rlamb/sdk-766/backward-compatibility-shim to main October 29, 2024 15:42
// So start of line followed by a character that isn't followed by m or underscore, but we
// want other things that do start with m, so we need to progressively handle more characters
// of meta with exclusions.
// eslint-disable-next-line no-param-reassign
Copy link
Member Author

Choose a reason for hiding this comment

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

The interface works by modifying the input options, which means re-assigning.

@kinyoklion kinyoklion marked this pull request as draft October 29, 2024 15:50
@kinyoklion kinyoklion marked this pull request as ready for review October 29, 2024 15:50
@kinyoklion
Copy link
Member Author

I need to appease tsdoc. Which may be some minor changes.

@kinyoklion kinyoklion merged commit ec4377c into main Oct 29, 2024
20 checks passed
@kinyoklion kinyoklion deleted the rlamb/SDK-819/refine-build-configuration branch October 29, 2024 15:55
@github-actions github-actions bot mentioned this pull request Oct 29, 2024
kinyoklion pushed a commit that referenced this pull request Oct 29, 2024
🤖 I have created a release *beep* *boop*
---


<details><summary>js-client-sdk: 0.2.0</summary>

##
[0.2.0](js-client-sdk-v0.1.0...js-client-sdk-v0.2.0)
(2024-10-29)


### Features

* Add a module for increased backward compatibility.
([#637](#637))
([44a2237](44a2237))
* Refine CJS/ESM build configuration for browser SDK.
([#640](#640))
([ec4377c](ec4377c))
* Vendor escapeStringRegexp to simplify builds.
([48cac54](48cac54))


### Dependencies

* The following workspace dependencies were updated
  * dependencies
    * @launchdarkly/js-client-sdk-common bumped from 1.10.0 to 1.11.0
</details>

<details><summary>js-client-sdk-common: 1.11.0</summary>

##
[1.11.0](js-client-sdk-common-v1.10.0...js-client-sdk-common-v1.11.0)
(2024-10-29)


### Features

* Add a module for increased backward compatibility.
([#637](#637))
([44a2237](44a2237))
</details>

<details><summary>react-native-client-sdk: 10.9.1</summary>

##
[10.9.1](react-native-client-sdk-v10.9.0...react-native-client-sdk-v10.9.1)
(2024-10-29)


### Dependencies

* The following workspace dependencies were updated
  * dependencies
    * @launchdarkly/js-client-sdk-common bumped from 1.10.0 to 1.11.0
</details>

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
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