Repository: marko-js/marko (language: javascript)

Issue:
Specify  Node Engine Constraint  in package.json
### Description
I think it would be better to specify `"engines": { "node": "18 || 20" }` in package.json for the following packages:
`@marko`
`@marko/compiler`
`@marko/babel-utils`
`@marko/translator-default`

### Why
The four packages all depend on `@luxass/strip-json-comments@^1.1.1` either directly or indirectly. The package defines `"engines": { "node": ">=18" }`  in package.json. Including node engine constraint in `package.json` of marko-packages, it could benefit all users in two ways.

Firstly, if users update multiple packages at once and encounter an Unsupported Engine error, they could easily identify the direct dependencies that caused the issue. Secondly, in my case, I rely on Renovate for automated dependency updates. The platform has a setting call [constraintsFiltering](https://docs.renovatebot.com/configuration-options/#constraintsfiltering) which allows developers to filter out all Unsupported Engine packages during updates. The feature only works on direct dependencies, so if we specify the engine constraint, developers using the platform can have a smoother automation process.


### Possible Implementation & Open Questions

https://github.com/marko-js/marko/pull/2097

### Is this something you're interested in working on?
Yes



Discussion / hints:

Fix patch:
diff --git a/.changeset/large-colts-fold.md b/.changeset/large-colts-fold.md
new file mode 100644
index 0000000000..bd622f79b5
--- /dev/null
+++ b/.changeset/large-colts-fold.md
@@ -0,0 +1,8 @@
+---
+"@marko/translator-interop-class-tags": patch
+"marko": patch
+"@marko/runtime-tags": patch
+"@marko/compiler": patch
+---
+
+Add engines field to package.json
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 4a56895e05..9f61e330d7 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -25,7 +25,7 @@ jobs:
       - name: Use node
         uses: actions/setup-node@v4
         with:
-          node-version: 20
+          node-version: 22
           cache: npm
       - name: Install dependencies
         run: npm ci
@@ -39,7 +39,7 @@ jobs:
     strategy:
       fail-fast: false
       matrix:
-        node: [18, 20]
+        node: [18, 20, 22]
     steps:
       - name: Checkout code
         uses: actions/checkout@v4
@@ -66,7 +66,7 @@ jobs:
       - name: Setup node
         uses: actions/setup-node@v4
         with:
-          node-version: 20
+          node-version: 22
           cache: npm
       - name: Install dependencies
         run: npm ci
diff --git a/package-lock.json b/package-lock.json
index e9e6218266..67d5190d65 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -10300,6 +10300,9 @@
       },
       "devDependencies": {
         "marko": "^5.37.8"
+      },
+      "engines": {
+        "node": "18 || 20 || >=22"
       }
     },
     "packages/runtime-class": {
@@ -10325,6 +10328,9 @@
       },
       "bin": {
         "markoc": "bin/markoc"
+      },
+      "engines": {
+        "node": "18 || 20 || >=22"
       }
     },
     "packages/runtime-class/node_modules/brace-expansion": {
@@ -10355,6 +10361,9 @@
         "@marko/compiler": "^5.39.7",
         "csstype": "^3.1.3",
         "magic-string": "^0.30.17"
+      },
+      "engines": {
+        "node": "18 || 20 || >=22"
       }
     },
     "packages/translator-interop": {
@@ -10366,6 +10375,9 @@
         "@marko/runtime-tags": "^0.3.14",
         "marko": "^5.37.8"
       },
+      "engines": {
+        "node": "18 || 20 || >=22"
+      },
       "peerDependencies": {
         "@marko/compiler": "^5.23.0"
       }
diff --git a/packages/compiler/package.json b/packages/compiler/package.json
index 84486e7bc9..a9be2a25dd 100644
--- a/packages/compiler/package.json
+++ b/packages/compiler/package.json
@@ -88,6 +88,9 @@
   "devDependencies": {
     "marko": "^5.37.8"
   },
+  "engines": {
+    "node": "18 || 20 || >=22"
+  },
   "publishConfig": {
     "access": "public"
   },
diff --git a/packages/runtime-class/package.json b/packages/runtime-class/package.json
index 6840a02da0..05e448ed57 100644
--- a/packages/runtime-class/package.json
+++ b/packages/runtime-class/package.json
@@ -85,6 +85,9 @@
     "self-closing-tags": "^1.0.1",
     "warp10": "^2.1.0"
   },
+  "engines": {
+    "node": "18 || 20 || >=22"
+  },
   "logo": {
     "url": "https://raw.githubusercontent.com/marko-js/branding/master/marko-logo-small.png"
   }
diff --git a/packages/runtime-tags/package.json b/packages/runtime-tags/package.json
index b2283e7653..b72ae10b3b 100644
--- a/packages/runtime-tags/package.json
+++ b/packages/runtime-tags/package.json
@@ -43,6 +43,9 @@
     "csstype": "^3.1.3",
     "magic-string": "^0.30.17"
   },
+  "engines": {
+    "node": "18 || 20 || >=22"
+  },
   "exports:override": {
     ".": {
       "types": "./index.d.ts"
diff --git a/packages/translator-interop/package.json b/packages/translator-interop/package.json
index 1714f8964e..4339f90650 100644
--- a/packages/translator-interop/package.json
+++ b/packages/translator-interop/package.json
@@ -36,5 +36,8 @@
   "peerDependencies": {
     "@marko/compiler": "^5.23.0"
   },
+  "engines": {
+    "node": "18 || 20 || >=22"
+  },
   "main:override": "dist/index.js"
 }


Test patch: