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

Redefine the engine requirement and the typescript config #402

Open
aurelticot opened this issue Feb 7, 2024 · 0 comments
Open

Redefine the engine requirement and the typescript config #402

aurelticot opened this issue Feb 7, 2024 · 0 comments

Comments

@aurelticot
Copy link
Member

aurelticot commented Feb 7, 2024

Caution

Changing the engine requirement and the build target is a breaking change!

The engine requirement in package.json is a result of the compilation of the code, which itself is defined based on the environments the SDK is expected to run.

ES2020 ES2021 ES2022
Node 14 (unmaintained) No Yes Yes
Node 16 (unmaintained) Yes Yes Yes
Node 18 (maintenance) Yes Yes Yes
Node 20 (current LTS) Yes Yes Yes
Browser 93% of all users 92% of all users 85-91% of all users
React Native JSC ? ? ?
React Native Hermes ? ? ?

By seeing the current support, ES2020 is widespread enough for browser support and Node under maintenance. By choosing ES2020, we can set the engine requirement to Node 16 to still allow projects stuck with that version.

We'd still have to check the dependencies are compatible (if not, look at updating them)

Recommended values:

  • Typescript target: es2020 (would result in a more optimised code than the current es5)
  • Typescript lib: es2020 (same as target)
  • Typescript module: commonjs
  • package.json engine: node >= 16 (breaking change)

Other recommendations:

  • All packages must have the same target in their respective tsconfig
    • Suggest using a base tsconfig extended by each package's tsconfig, so the common configuration is defined once, in the base
  • All packages must defined the same engine requirements in their respective package.json
    • To be fair, it's already the case
  • Run the tests in the CI with a matrix of Node versions
    • Testing and building from the minimum version of Node supported (engine requirement) to the current LTS, and even to the latest: Node 16, 18, 20, 21.
    • If not, at least the version defined in .nvmrc
  • .nvmrc is only used for dev, test and build, not runtime
    • Recommendation to use the LTS, currently Node 20 (lts/iron)
      • But only if the tests are run with a matrix checking the lowest version support
    • If tests not run with a matrix, .nvmrc should be aligned with the engine requirements
      • Ensure we develop, test and build with the lowest supported version
    • Use the name instead of a defined version: lts/hydrogen for node 18
  • The actual build being published should be done with the version defined in .nvmrc
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

No branches or pull requests

1 participant