Project
ide
Description
The TypeScript plugin scaffolder produces an inconsistent module system configuration that breaks the generated build at runtime.
The generated tsconfig.json sets:
{
"compilerOptions": {
"target": "ES2020",
"module": "ESNext",
"moduleResolution": "node",
...
"outDir": "./dist"
}
}
The generated src/index.ts uses ES module syntax throughout: export const PLUGIN_ID = "...", export function init(): number {...}, export function shutdown(): number {...}, export function cmd_example(args: string[]): number {...}.
The generated package.json does NOT contain "type": "module":
{
"name": "my-ts-plugin",
"version": "0.1.0",
"description": "...",
"main": "dist/index.js",
"scripts": {
"build": "tsc",
"watch": "tsc --watch"
},
"devDependencies": {
"typescript": "^5.0.0"
}
}
When npm run build runs, tsc honours "module": "ESNext" and emits dist/index.js containing real export statements. But because package.json lacks "type": "module", Node interprets the .js extension as CommonJS and the very first export token throws SyntaxError: Unexpected token 'export' whenever the host tries to load the plugin. The scaffolded TypeScript plugin is not actually loadable as-is.
Error Message
$ node dist/index.js
file:///.../my-ts-plugin/dist/index.js:2
export const PLUGIN_ID = "my-ts-plugin";
^^^^^^
SyntaxError: Unexpected token 'export'
Debug Logs
System Information
Windows 11, cortex v0.0.7, Node.js v20.x
Screenshots

Steps to Reproduce
cortex plugin new my-ts-plugin --typescript
cd my-ts-plugin && npm install && npm run build
node dist/index.js (or any host that loads dist/index.js) → SyntaxError: Unexpected token 'export'
- Inspect the three files:
tsconfig.json says "module": "ESNext", src/index.ts uses ESM export syntax, package.json has no "type" key
Expected Behavior
The generated package.json should include "type": "module" so that the ESM-syntax dist/index.js produced by tsc is correctly treated as a Node ES module. Alternatively, tsconfig.json should set "module": "CommonJS" to match the implicit Node interpretation. Either choice is fine, but the three files must agree.
Actual Behavior
tsconfig.json and src/index.ts agree on ES modules; package.json does not. tsc produces ESM-syntax JavaScript that Node refuses to execute. The scaffolded TypeScript plugin is broken out of the box and cannot be loaded by any standard Node-based plugin host.
Additional Context
This is a functional bug: the scaffold does not just have cosmetic issues — it produces a build artifact that fails at the very first load attempt. Two trivial fixes exist (add "type": "module" to package.json, OR change tsconfig.json "module" from "ESNext" to "CommonJS"); the scaffolder picks neither and ships an inconsistent template.
Project
ide
Description
The TypeScript plugin scaffolder produces an inconsistent module system configuration that breaks the generated build at runtime.
The generated
tsconfig.jsonsets:{ "compilerOptions": { "target": "ES2020", "module": "ESNext", "moduleResolution": "node", ... "outDir": "./dist" } }The generated
src/index.tsuses ES module syntax throughout:export const PLUGIN_ID = "...",export function init(): number {...},export function shutdown(): number {...},export function cmd_example(args: string[]): number {...}.The generated
package.jsondoes NOT contain"type": "module":{ "name": "my-ts-plugin", "version": "0.1.0", "description": "...", "main": "dist/index.js", "scripts": { "build": "tsc", "watch": "tsc --watch" }, "devDependencies": { "typescript": "^5.0.0" } }When
npm run buildruns,tschonours"module": "ESNext"and emitsdist/index.jscontaining realexportstatements. But becausepackage.jsonlacks"type": "module", Node interprets the.jsextension as CommonJS and the very firstexporttoken throwsSyntaxError: Unexpected token 'export'whenever the host tries to load the plugin. The scaffolded TypeScript plugin is not actually loadable as-is.Error Message
Debug Logs
System Information
Screenshots
Steps to Reproduce
cortex plugin new my-ts-plugin --typescriptcd my-ts-plugin && npm install && npm run buildnode dist/index.js(or any host that loadsdist/index.js) →SyntaxError: Unexpected token 'export'tsconfig.jsonsays"module": "ESNext",src/index.tsuses ESMexportsyntax,package.jsonhas no"type"keyExpected Behavior
The generated
package.jsonshould include"type": "module"so that the ESM-syntaxdist/index.jsproduced bytscis correctly treated as a Node ES module. Alternatively,tsconfig.jsonshould set"module": "CommonJS"to match the implicit Node interpretation. Either choice is fine, but the three files must agree.Actual Behavior
tsconfig.jsonandsrc/index.tsagree on ES modules;package.jsondoes not.tscproduces ESM-syntax JavaScript that Node refuses to execute. The scaffolded TypeScript plugin is broken out of the box and cannot be loaded by any standard Node-based plugin host.Additional Context
This is a functional bug: the scaffold does not just have cosmetic issues — it produces a build artifact that fails at the very first load attempt. Two trivial fixes exist (add
"type": "module"topackage.json, OR changetsconfig.json"module"from"ESNext"to"CommonJS"); the scaffolder picks neither and ships an inconsistent template.