diff --git a/bin/ts-json-schema-generator.js b/bin/ts-json-schema-generator.js index 2177a3c7f..bfb576487 100755 --- a/bin/ts-json-schema-generator.js +++ b/bin/ts-json-schema-generator.js @@ -1,2 +1,4 @@ #!/usr/bin/env node -import("../dist/ts-json-schema-generator.js"); + +// eslint-disable-next-line @typescript-eslint/no-require-imports +require("../dist/ts-json-schema-generator.js"); diff --git a/eslint.config.js b/eslint.config.mjs similarity index 95% rename from eslint.config.js rename to eslint.config.mjs index 74c0e841a..58245e816 100644 --- a/eslint.config.js +++ b/eslint.config.mjs @@ -6,7 +6,7 @@ import eslintPluginPrettierRecommended from "eslint-plugin-prettier/recommended" /** @type {import('@types/eslint').Linter.FlatConfig[]} */ export default tseslint.config( { - ignores: ["dist", "cjs", "build"], + ignores: ["dist", "cjs", "build", "eslint.config.mjs"], }, eslint.configs.recommended, { @@ -21,7 +21,7 @@ export default tseslint.config( ], extends: tseslint.configs.recommendedTypeChecked, languageOptions: { - sourceType: "module", + sourceType: "commonjs", parserOptions: { project: "tsconfig.eslint.json", tsconfigRootDir: import.meta.dirname, @@ -71,6 +71,7 @@ export default tseslint.config( languageOptions: { globals: { ...globals.jest, + ...globals.commonjs, }, }, }, diff --git a/package.json b/package.json index 71a932062..76483cf59 100644 --- a/package.json +++ b/package.json @@ -2,20 +2,18 @@ "name": "ts-json-schema-generator", "version": "2.0.0", "description": "Generate JSON schema from your Typescript sources", - "module": "dist/index.js", - "types": "dist/index.d.ts", - "type": "module", - "bin": { - "ts-json-schema-generator": "./bin/ts-json-schema-generator.js" - }, - "files": [ - "dist", - "cjs", - "src", - "factory", - "index.*", - "ts-json-schema-generator.*" + "keywords": [ + "ts", + "typescript", + "json", + "schema", + "jsonschema" ], + "repository": { + "type": "git", + "url": "git+https://github.com/vega/ts-json-schema-generator.git" + }, + "license": "MIT", "author": { "name": "Alexander Evtushenko", "email": "aevtushenko@xiag.ch" @@ -30,24 +28,32 @@ "email": "mooyoul@gmail.com" } ], - "repository": { - "type": "git", - "url": "https://github.com/vega/ts-json-schema-generator.git" + "type": "commonjs", + "main": "dist/index.js", + "types": "dist/index.d.ts", + "bin": { + "ts-json-schema-generator": "bin/ts-json-schema-generator.js" }, - "license": "MIT", - "keywords": [ - "ts", - "typescript", - "json", - "schema", - "jsonschema" + "files": [ + "dist", + "src", + "factory", + "index.*", + "ts-json-schema-generator.*" ], - "engines": { - "node": ">=18.0.0" - }, - "exports": { - "import": "./dist/index.js", - "require": "./cjs/index.js" + "scripts": { + "build": "tsc", + "debug": "tsx --inspect-brk ts-json-schema-generator.ts", + "format": "eslint --fix", + "lint": "eslint", + "prepublishOnly": "yarn build", + "release": "yarn build && auto shipit", + "run": "tsx ts-json-schema-generator.ts", + "test": "jest test/ --verbose", + "test:coverage": "yarn jest test/ --collectCoverage=true", + "test:fast": "cross-env FAST_TEST=1 jest test/ --verbose", + "test:update": "cross-env UPDATE_SCHEMA=true yarn test:fast", + "watch": "tsc -w" }, "dependencies": { "@types/json-schema": "^7.0.15", @@ -87,20 +93,7 @@ "vega": "^5.28.0", "vega-lite": "^5.18.0" }, - "scripts": { - "prepublishOnly": "yarn build", - "build": "npm run build:cjs && npm run build:esm", - "build:cjs": "tsc -p tsconfig.cjs.json", - "build:esm": "tsc -p tsconfig.json", - "watch": "tsc -w", - "lint": "eslint", - "format": "eslint --fix", - "test": "jest test/ --verbose", - "test:fast": "cross-env FAST_TEST=1 jest test/ --verbose", - "test:coverage": "yarn jest test/ --collectCoverage=true", - "test:update": "cross-env UPDATE_SCHEMA=true yarn test:fast", - "debug": "tsx --inspect-brk ts-json-schema-generator.ts", - "run": "tsx ts-json-schema-generator.ts", - "release": "yarn build && auto shipit" + "engines": { + "node": ">=18.0.0" } } diff --git a/tsconfig.cjs.json b/tsconfig.cjs.json deleted file mode 100644 index de02fb0c0..000000000 --- a/tsconfig.cjs.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "extends": "./tsconfig.json", - "compilerOptions": { - "target": "ES2022", - "module": "CommonJS", - "moduleResolution": "Node", - "outDir": "cjs" - }, - "files": ["ts-json-schema-generator.ts", "index.ts"], - "include": ["src/**/*.ts", "factory/**/*.ts"], - "exclude": ["node_modules", "dist", "cjs"] -} diff --git a/tsconfig.json b/tsconfig.json index d0f20b4a0..d049d7d24 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,8 +1,8 @@ { "compilerOptions": { "target": "ES2022", - "module": "NodeNext", - "moduleResolution": "Node16", + "module": "CommonJS", + "moduleResolution": "Node", "esModuleInterop": true, "isolatedModules": false, "experimentalDecorators": true,