Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/01_bug_report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ body:
- type: input
attributes:
label: What Node versions, OSs and CPU architectures are you building for?
description: 'For example: default, node18, node18-linux-x64, node16-win-arm64'
description: 'For example: default, node20, node20-linux-x64, node22-win-arm64'
validations:
required: true
- type: textarea
Expand Down
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/02_regression.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ body:
- type: input
attributes:
label: What Node versions, OSs and CPU architectures are you building for?
description: 'For example: default, node18, node18-linux-x64, node16-win-arm64'
description: 'For example: default, node20, node20-linux-x64, node22-win-arm64'
validations:
required: true
- type: textarea
Expand Down
10 changes: 5 additions & 5 deletions .github/copilot-instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ This is a TypeScript-based Node.js project that packages Node.js applications in
`pkg` is a command-line tool that:

- Packages Node.js projects into executables for multiple platforms (Linux, macOS, Windows)
- Supports multiple Node.js versions (node18, node20, etc.)
- Supports multiple Node.js versions (node20, node22, etc.)
- Uses virtual filesystem to bundle application files
- Compiles JavaScript to V8 bytecode for distribution
- Supports native addons (.node files)
Expand Down Expand Up @@ -111,8 +111,8 @@ npm run build
npm test

# Run tests for specific Node.js version
npm run test:18 # Test with Node.js 18
npm run test:20 # Test with Node.js 20
npm run test:22 # Test with Node.js 22
npm run test:host # Test with host Node.js version

# Run specific test pattern
Expand Down Expand Up @@ -268,8 +268,8 @@ The project uses GitHub Actions workflows:

- **ci.yml**: Runs linting and builds on multiple Node.js versions and OS platforms
- **test.yml**: Reusable workflow for running tests
- Matrix strategy tests: Node.js 18.x, 20.x on ubuntu-latest, windows-latest, macos-latest
- Linting only runs on ubuntu-latest with Node.js 18.x
- Matrix strategy tests: Node.js 20.x, 22.x on ubuntu-latest, windows-latest, macos-latest
- Linting only runs on ubuntu-latest with Node.js 20.x

## Support and Resources

Expand All @@ -287,7 +287,7 @@ The project uses GitHub Actions workflows:
2. **ALWAYS check lint before committing**: Run `npm run lint` before every commit and fix all issues - NEVER commit with lint errors
3. **Clean test artifacts before staging**: Remove any test-generated executables (`*.exe`, `*-linux`, `*-macos`, `*-win.exe`) from test directories before committing
4. **Always build before testing**: Run `npm run build` before running any tests
5. **Use correct Node.js version**: The project requires Node.js >= 18.0.0
5. **Use correct Node.js version**: The project requires Node.js >= 20.0.0
6. **Use Yarn for package management**: This project uses `yarn`, not `npm`, for dependency management
7. **Respect TypeScript compilation**: Edit `lib/*.ts` files, not `lib-es5/*.js` files
8. **Maintain test numbering**: When adding tests, choose appropriate test number (XX in test-XX-name)
Expand Down
15 changes: 10 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
strategy:
fail-fast: false # prevent test to stop if one fails
matrix:
node-version: [18.x, 20.x]
node-version: [20.x, 22.x, 24.x]
os: [ubuntu-latest, windows-latest, macos-latest]
runs-on: ${{ matrix.os }}
steps:
Expand All @@ -23,20 +23,25 @@ jobs:

- run: yarn install

- if: matrix['node-version'] == '18.x' && matrix['os'] == 'ubuntu-latest'
- if: matrix['node-version'] == '20.x' && matrix['os'] == 'ubuntu-latest'
run: yarn lint
- run: yarn build
test_host:
uses: ./.github/workflows/test.yml
with:
npm_command: test:host
test_18:

test_22:
uses: ./.github/workflows/test.yml
with:
npm_command: test:18
npm_command: test:22

test_20:
uses: ./.github/workflows/test.yml
with:
npm_command: test:20

test_24:
uses: ./.github/workflows/test.yml
with:
npm_command: test:24
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
strategy:
fail-fast: false # prevent test to stop if one fails
matrix:
node-version: [18.x, 20.x]
node-version: [20.x, 22.x, 24.x]
os: [ubuntu-latest, windows-latest, macos-latest]
runs-on: ${{ matrix.os }}
steps:
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ After installing it, run `pkg --help` without arguments to see list of options:
– Makes executable for particular target machine
$ pkg -t node14-win-arm64 index.js
– Makes executables for target machines of your choice
$ pkg -t node16-linux,node18-linux,node18-win index.js
$ pkg -t node20-linux,node22-linux,node22-win index.js
– Bakes '--expose-gc' and '--max-heap-size=34' into executable
$ pkg --options "expose-gc,max-heap-size=34" index.js
– Consider packageA and packageB to be public
Expand Down Expand Up @@ -82,7 +82,7 @@ The entrypoint of your project is a mandatory CLI argument. It may be:
`pkg` can generate executables for several target machines at a
time. You can specify a comma-separated list of targets via `--targets`
option. A canonical target consists of 3 elements, separated by
dashes, for example `node18-macos-x64` or `node14-linux-arm64`:
dashes, for example `node20-macos-x64` or `node22-linux-arm64`:

- **nodeRange** (node8), node10, node12, node14, node16 or latest
- **platform** alpine, linux, linuxstatic, win, macos, (freebsd)
Expand Down
2 changes: 1 addition & 1 deletion lib/esm-transformer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ export function transformESMtoCJS(
const esbuildOptions: esbuild.TransformOptions = {
loader: 'js',
format: 'cjs',
target: 'node18',
target: 'node20',
sourcemap: false,
minify: false,
keepNames: true,
Expand Down
2 changes: 1 addition & 1 deletion lib/help.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export default function help() {
${pc.gray('–')} Makes executable for particular target machine
${pc.cyan('$ pkg -t node14-win-arm64 index.js')}
${pc.gray('–')} Makes executables for target machines of your choice
${pc.cyan('$ pkg -t node16-linux,node18-linux,node18-win index.js')}
${pc.cyan('$ pkg -t node22-linux,node24-linux,node24-win index.js')}
${pc.gray('–')} Bakes '--expose-gc' and '--max-heap-size=34' into executable
${pc.cyan('$ pkg --options "expose-gc,max-heap-size=34" index.js')}
${pc.gray('–')} Consider packageA and packageB to be public
Expand Down
23 changes: 12 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
"@babel/traverse": "^7.23.0",
"@babel/types": "^7.23.0",
"@yao-pkg/pkg-fetch": "3.5.32",
"esbuild": "^0.25.0",
"into-stream": "^6.0.0",
"esbuild": "^0.27.3",
"into-stream": "^9.1.0",
"minimist": "^1.2.6",
"multistream": "^4.1.0",
"picocolors": "^1.1.0",
Expand All @@ -42,12 +42,12 @@
"unzipper": "^0.12.3"
},
"devDependencies": {
"@release-it/conventional-changelog": "^7.0.2",
"@release-it/conventional-changelog": "^10.0.5",
"@types/babel__generator": "^7.6.5",
"@types/babel__traverse": "^7.20.3",
"@types/minimist": "^1.2.2",
"@types/multistream": "^4.1.0",
"@types/node": "^16.18.113",
"@types/node": "^20.0.0",
"@types/picomatch": "^3.0.1",
"@types/resolve": "^1.20.2",
"@types/stream-meter": "^0.0.22",
Expand All @@ -58,15 +58,15 @@
"esbuild-register": "^3.6.0",
"eslint": "^9.0.0",
"eslint-config-airbnb-base": "^15.0.0",
"eslint-config-airbnb-typescript": "^17.1.0",
"eslint-config-airbnb-typescript": "^18.0.0",
"eslint-config-prettier": "^10.0.0",
"eslint-plugin-import": "^2.31.0",
"globals": "^17.3.0",
"json-stable-stringify": "^1.0.1",
"lint-staged": "^15.2.10",
"lint-staged": "^15.0.0",
"prettier": "^3.0.3",
"release-it": "^17.0.0",
"rimraf": "^3.0.2",
"release-it": "^19.2.4",
"rimraf": "^6.1.2",
"simple-git-hooks": "^2.11.1",
"typescript": "^4.7.2"
},
Expand All @@ -80,9 +80,10 @@
"fix": "npm run lint:style -- -w && npm run lint:code -- --fix",
"prepare": "npm run build",
"prepublishOnly": "npm run lint",
"test": "npm run build && npm run test:host && npm run test:18 && npm run test:20",
"test": "npm run build && npm run test:host && npm run test:20 && npm run test:22 && npm run test:24",
"test:20": "node test/test.js node20 no-npm",
"test:18": "node test/test.js node18 no-npm",
"test:22": "node test/test.js node22 no-npm",
"test:24": "node test/test.js node24 no-npm",
"test:host": "node test/test.js host only-npm",
"bump:fetch": "yarn add @yao-pkg/pkg-fetch --exact",
"release": "read -p 'GITHUB_TOKEN: ' GITHUB_TOKEN && export GITHUB_TOKEN=$GITHUB_TOKEN && release-it"
Expand All @@ -98,7 +99,7 @@
},
"packageManager": "yarn@1.22.22",
"engines": {
"node": ">=18.0.0"
"node": ">=20.0.0"
},
"resolutions": {
"lodash": "^4.17.23",
Expand Down
71 changes: 71 additions & 0 deletions plans/drop-node18-add-node22.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# Plan: Drop node18 target, add node22 target

## Context

The project currently supports `node18` and `node20` as compilation targets (plus `host`). The user wants to drop `node18` and add `node22` instead, updating CI, source code, tests, and documentation accordingly.

## Changes

### 1. CI Workflows

**`.github/workflows/ci.yml`**

- Change build matrix from `[18.x, 20.x]` to `[20.x, 22.x]`
- Change lint condition from `node-version == '18.x'` to `node-version == '20.x'`
- Replace `test_18` job with `test_22` (calling `test:22`)
- Keep `test_20` and `test_host`

**`.github/workflows/test.yml`**

- Change test matrix from `[18.x, 20.x]` to `[20.x, 22.x]`

### 2. Package configuration

**`package.json`**

- Update `engines.node` from `>=18.0.0` to `>=20.0.0`
- Replace `test:18` script with `test:22`: `"node test/test.js node22 no-npm"`
- Update `test` script to call `test:22` instead of `test:18`

### 3. ESM Transformer

**`lib/esm-transformer.ts`** (line 379)

- Change esbuild target from `'node18'` to `'node20'` (new minimum supported version)

### 4. Tests

**`test/test-42-fetch-all/main.js`** (line 18)

- Change `nodeRanges` from `['node18', 'node20', 'node22']` to `['node20', 'node22']`

**`test/test-50-fs-runtime-layer-3/main.js`** (lines 29-32)

- The `node18`-specific branch is no longer needed. Since we only target node20+, the error message is always the ENOENT variant. Remove the `node18` conditional and use the `node20+` behavior unconditionally.

### 5. Documentation & templates

**`lib/help.ts`** (line 35)

- Update example from `node16-linux,node18-linux,node18-win` to `node20-linux,node22-linux,node22-win`

**`README.md`** (lines 56, 85)

- Update example from `node16-linux,node18-linux,node18-win` to `node20-linux,node22-linux,node22-win`
- Update target example from `node18-macos-x64` to `node20-macos-x64`

**`.github/copilot-instructions.md`**

- Update node version references (node18 -> node20, matrix mention, lint reference, engines note)

**`.github/ISSUE_TEMPLATE/01_bug_report.yml`** and **`02_regression.yml`**

- Update example targets from `node18` to `node20`

## Verification

1. `yarn build` β€” ensure TypeScript compiles cleanly
2. `yarn lint` β€” ensure no lint errors
3. `yarn test:host` β€” run host-target tests
4. `yarn test:20` β€” run node20 target tests
5. `yarn test:22` β€” run new node22 target tests
2 changes: 1 addition & 1 deletion test/test-42-fetch-all/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ function nodeRangeToNodeVersion(nodeRange) {
const platformsToTest = ['win', 'linux', 'macos'];

for (const platform of platformsToTest) {
const nodeRanges = ['node18', 'node20', 'node22'];
const nodeRanges = ['node20', 'node22'];
for (const nodeRange of nodeRanges) {
const archs = ['x64'];
if (platform === 'linux' || platform === 'macos') archs.push('arm64');
Expand Down
5 changes: 1 addition & 4 deletions test/test-50-fs-runtime-layer-3/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,7 @@ const errorPath =
process.platform === 'win32'
? 'C:\\snapshot\\test-50-fs-runtime-layer-3\\test-z-asset.css'
: '/snapshot/test-50-fs-runtime-layer-3/test-z-asset.css';
const exception =
target === 'node18'
? 'Cannot write to packaged file\n'
: `ENOENT: no such file or directory, open '${errorPath}'\n`;
const exception = `ENOENT: no such file or directory, open '${errorPath}'\n`;

assert.strictEqual(
right,
Expand Down
5 changes: 4 additions & 1 deletion test/test-99-#420-copy-from-snapshot/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

const path = require('path');
const assert = require('assert');
const { globSync } = require('tinyglobby');
const utils = require('../utils.js');

assert(!module.parent);
Expand All @@ -27,4 +28,6 @@ right = utils.spawn.sync(output, [], {

assert.strictEqual(left, right);
utils.vacuum.sync(path.dirname(output));
utils.vacuum.sync(path.join(__dirname, '/*sync.json'));
for (const f of globSync('*sync.json', { cwd: __dirname })) {
utils.vacuum.sync(path.join(__dirname, f));
}
3 changes: 2 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
"esModuleInterop": true,
"incremental": false,
"resolveJsonModule": true,
"skipLibCheck": true
"skipLibCheck": true,
"types": []
},
"include": ["lib/**/*"]
}
Loading