Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Fix for 1: Syntax error: '(' unexpected' error
Signed-off-by: Pavel Dvorkin <[email protected]>
  • Loading branch information
XxdpavelxX committed Sep 11, 2025
commit 3a32aab8c64d530b68194f9d6a7c39ee0922c0f7
19 changes: 19 additions & 0 deletions bin/auto-changelog.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/usr/bin/env node
(async () => {
try {
await import('../dist/cli.mjs');
} catch (error) {
try {
// Fallback to CommonJS build if ESM import fails
// eslint-disable-next-line @typescript-eslint/no-var-requires, import/no-commonjs, @typescript-eslint/no-require-imports
require('../dist/cli.cjs');
} catch (fallbackError) {
// Prefer showing the original error if present
// eslint-disable-next-line no-console
console.error(error || fallbackError);
process.exit(1);
}
}
})();


4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@
"main": "./dist/index.cjs",
"module": "./dist/index.mjs",
"types": "./dist/index.d.cts",
"bin": "dist/cli.mjs",
"bin": "dist/cli.js",
"files": [
"dist"
],
"scripts": {
"build": "ts-bridge --project tsconfig.build.json --clean",
"changelog": "node dist/cli.js",
"changelog": "node dist/cli.mjs",
Copy link

Choose a reason for hiding this comment

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

Bug: CLI Entry Point Mismatch Causes Runtime Failures

The package.json bin field points to dist/cli.js, while the changelog script uses dist/cli.mjs. This creates an inconsistency in the CLI entry points. Additionally, the intended binary is bin/auto-changelog.js, which isn't referenced by the bin field. This mismatch may cause the globally installed CLI or npm script to use incorrect files, leading to runtime failures.

Fix in Cursor Fix in Web

"lint": "yarn lint:eslint && yarn lint:misc --check",
"lint:eslint": "eslint . --cache --ext js,ts",
"lint:fix": "yarn lint:eslint --fix && yarn lint:misc --write",
Expand Down
1 change: 1 addition & 0 deletions src/cli.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/usr/bin/env node
import { promises as fs, constants as fsConstants } from 'fs';
import path from 'path';
import semver from 'semver';
Expand Down
2 changes: 1 addition & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -873,7 +873,7 @@ __metadata:
peerDependencies:
prettier: ">=3.0.0"
bin:
auto-changelog: dist/cli.mjs
auto-changelog: dist/cli.js
languageName: unknown
linkType: soft

Expand Down
Loading