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

fix: support older node version than 22.12.0 #348

Merged
merged 1 commit into from
Feb 23, 2025
Merged

Conversation

Totto16
Copy link
Collaborator

@Totto16 Totto16 commented Feb 22, 2025

Description

In #342 (8829de8 and 8a99348) I updated some dependencies, that our locale generation script uses. The updates made them ESM only. I used node v22.14.0 and I didn't notice any problem. But after investigating a failure reported in #347 I found out, that that broke support for older node version than 22.12.0. The reason for this is the following timeline:

node version change ref
v20.17.0 --experimental-require-module flag added, default false ref
v22.0.0 --experimental-require-module flag added, default false ref
v22.12.0 --experimental-require-module flag defaults to true ref

The flag --experimental-require-module makes require() calls also support ESM modules, which we need, if we want to use the newest versions of some dependencies.

This feature is under active development, but it's stable in the LTS branches of node

So to fix this issue, I added NODE_OPTIONS='--experimental-require-module' in front of every ts-node call. I also guarded everything with an explicit engines field in the package.json. So we support only the node versions, where this feature can be enabled. I made the engines field strict, so that it can't be circumvented.

This shouldn't introduce problems, as we use node 22 in actions anyway, and we just use this to generate locales.

Fixes #347

Type of change

  • Bug fix (non-breaking change which fixes an issue)

Checklist

  • My code follows the style guidelines of this project
  • My commits follow the commit standards of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have checked my code and corrected any misspellings

- add NODE_OPTIONS="--experimental-require-module" to support some modules in the locale generation process
- make the engine (and package manager) field strict with .npmrc
@Totto16 Totto16 requested a review from oae February 22, 2025 23:56
@Totto16 Totto16 merged commit 6a6368e into master Feb 23, 2025
1 check passed
@Totto16 Totto16 deleted the fix-ts-node-esm-error branch February 23, 2025 02:05
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.

Unable to build: ERR_REQUIRE_ESM
2 participants