diff --git a/.gitignore b/.gitignore index 387f51ab..f17b5538 100644 --- a/.gitignore +++ b/.gitignore @@ -1,9 +1,8 @@ -/.temp /coverage node_modules /test/temp -/index.* /npm-debug.log /test.js /test/fixtures/espree-v8/node_modules /test/fixtures/integrations/**/_actual.json +/dist diff --git a/.nycrc b/.nycrc deleted file mode 100644 index a31275f2..00000000 --- a/.nycrc +++ /dev/null @@ -1,19 +0,0 @@ -{ - "include": [ - "src/**/*.ts" - ], - "exclude": [ - "src/external/**/*.ts" - ], - "extension": [ - ".ts" - ], - "require": [ - "ts-node/register" - ], - "reporter": [ - "lcov", - "text-summary" - ], - "sourceMap": true -} diff --git a/README.md b/README.md index 57e0668f..0caf445f 100644 --- a/README.md +++ b/README.md @@ -324,7 +324,7 @@ The `npm install` command installs dependencies. ### Development Tools - `npm test` runs tests and measures coverage. -- `npm run build` compiles TypeScript source code to `index.js`, `index.js.map`, and `index.d.ts`. +- `npm run build` compiles TypeScript source code to `index.js`, `index.js.map`, and `index.d.ts` in `dist`. - `npm run coverage` shows the coverage result of `npm test` command with the default browser. - `npm run clean` removes the temporary files which are created by `npm test` and `npm run build`. - `npm run lint` runs ESLint. diff --git a/eslint.config.mjs b/eslint.config.mjs index a46acd53..10f4c73f 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -22,8 +22,8 @@ const compat = new FlatCompat({ export default [ { ignores: [ - ".temp", "coverage", + "dist", "**/node_modules", "src/html/util/alternative-cr.ts", "src/html/util/attribute-names.ts", @@ -31,8 +31,6 @@ export default [ "src/html/util/tag-names.ts", "test/fixtures", "test/temp", - "index.d.ts", - "index.js", ], }, ...nodeDeps.configs["flat/recommended"], diff --git a/package.json b/package.json index b325e750..8e9db395 100644 --- a/package.json +++ b/package.json @@ -2,9 +2,9 @@ "name": "vue-eslint-parser", "version": "10.2.0", "description": "The ESLint custom parser for `.vue` files.", - "main": "index.js", + "main": "dist/index.js", "files": [ - "index.*" + "dist" ], "engines": { "node": "^18.18.0 || ^20.9.0 || >=21.1.0" @@ -38,7 +38,6 @@ "@vitest/ui": "^3.2.4", "chokidar": "^3.5.2", "cross-spawn": "^7.0.3", - "dts-bundle": "^0.7.3", "eslint": "^9.19.0", "eslint-plugin-eslint-comments": "^3.2.0", "eslint-plugin-jsonc": "^2.19.1", @@ -50,12 +49,8 @@ "jsonc-eslint-parser": "^2.0.3", "npm-run-all": "^4.1.5", "prettier": "^3.4.2", - "rimraf": "^3.0.2", - "rollup": "^2.60.0", - "rollup-plugin-node-resolve": "^5.2.0", - "rollup-plugin-replace": "^2.2.0", - "rollup-plugin-sourcemaps": "^0.6.3", "ts-node": "^10.9.2", + "tsdown": "^0.12.9", "typescript": "~5.7.3", "vite": "^6.3.5", "vitest": "^3.2.4", @@ -63,9 +58,7 @@ "warun": "^1.0.0" }, "scripts": { - "prebuild": "npm run -s clean", - "build": "tsc --module es2015 && rollup -c -o index.js && dts-bundle --name vue-eslint-parser --main .temp/index.d.ts --out ../index.d.ts", - "clean": "rimraf .temp index.*", + "build": "tsdown", "coverage": "vitest --coverage --ui", "lint": "eslint src test package.json", "test": "vitest", @@ -76,9 +69,8 @@ "postversion": "git push && git push --tags", "prewatch": "npm run -s clean", "watch": "run-p watch:*", - "watch:tsc": "tsc --module es2015 --watch", - "watch:rollup": "wait-on .temp/index.js && rollup -c -o index.js --watch", - "watch:update-ast": "wait-on index.js && warun index.js \"test/fixtures/ast/*/*.vue\" -- ts-node scripts/update-fixtures-ast.js" + "watch:tsdown": "tsdown --watch", + "watch:update-ast": "wait-on dist/index.js && warun dist/index.js \"test/fixtures/ast/*/*.vue\" -- ts-node scripts/update-fixtures-ast.js" }, "repository": { "type": "git", diff --git a/rollup.config.js b/rollup.config.js deleted file mode 100644 index ce75d20c..00000000 --- a/rollup.config.js +++ /dev/null @@ -1,35 +0,0 @@ -/** - * @author Toru Nagashima - * @copyright 2017 Toru Nagashima. All rights reserved. - * See LICENSE file in root directory for full license. - */ -import resolve from "rollup-plugin-node-resolve" -import sourcemaps from "rollup-plugin-sourcemaps" -import replace from "rollup-plugin-replace" - -const pkg = require("./package.json") -const deps = new Set( - ["assert", "events", "path"].concat(Object.keys(pkg.dependencies)), -) - -export default { - input: ".temp/index.js", - output: { - file: "index.js", - format: "cjs", - sourcemap: true, - sourcemapFile: "index.js.map", - banner: `/** - * @author Toru Nagashima - * See LICENSE file in root directory for full license. - */`, - }, - plugins: [ - sourcemaps(), - resolve(), - replace({ - "process.env.PACKAGE_VERSION": `"${pkg.version}"`, - }), - ], - external: (id) => deps.has(id), -} diff --git a/src/index.ts b/src/index.ts index 45d43d64..2840f8ed 100644 --- a/src/index.ts +++ b/src/index.ts @@ -25,6 +25,7 @@ import { import { parseStyleElements } from "./style/index" import { analyzeScope } from "./script/scope-analyzer" import { analyzeScriptSetupScope } from "./script-setup/scope-analyzer" +import { name, version } from "../package.json" with { type: "json" } const STARTS_WITH_LT = /^\s* { beforeAll(async () => { - await import("ts-node/register") + const { register } = await import("ts-node") + register({ + transpileOnly: true, + compilerOptions: { + module: "commonjs", + moduleResolution: "node", + }, + }) }) for (const target of fs.readdirSync(FIXTURE_DIR)) { it(target, async () => { diff --git a/tsconfig.json b/tsconfig.json index 677d8fec..70087f3e 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,5 +1,4 @@ { - "compileOnSave": true, "compilerOptions": { "allowJs": false, "allowSyntheticDefaultImports": true, @@ -8,35 +7,28 @@ "alwaysStrict": true, "baseUrl": ".", "checkJs": false, - "declaration": true, "esModuleInterop": true, "forceConsistentCasingInFileNames": true, - "inlineSources": true, "lib": ["es2023"], - "module": "commonjs", - "moduleResolution": "node", + "module": "preserve", + "moduleResolution": "bundler", "newLine": "LF", - "noEmitOnError": true, + "noEmit": true, "noFallthroughCasesInSwitch": true, "noImplicitAny": true, "noImplicitReturns": true, "noImplicitThis": true, "noUnusedLocals": true, "noUnusedParameters": true, - "outDir": ".temp", "paths": { "*": ["typings/*"] }, - "pretty": true, - "removeComments": true, - "sourceMap": true, - "sourceRoot": "src", + "resolveJsonModule": true, "strict": true, "strictNullChecks": true, "target": "ES2024", "skipLibCheck": true }, - "include": ["src/**/*.ts"], - "references": [{ "path": "./tsconfig.test.json" }] + "include": ["**/*.ts"] } diff --git a/tsconfig.test.json b/tsconfig.test.json deleted file mode 100644 index a5e080f7..00000000 --- a/tsconfig.test.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "extends": "./tsconfig.json", - "compilerOptions": { - "composite": true, - "paths": { - "*": ["typings/*"] - }, - "module": "esnext", - "moduleResolution": "Bundler" - }, - "include": ["test/**/*.ts", "vitest.config.ts"] -} diff --git a/tsdown.config.ts b/tsdown.config.ts new file mode 100644 index 00000000..8983a22e --- /dev/null +++ b/tsdown.config.ts @@ -0,0 +1,19 @@ +import { defineConfig } from "tsdown" + +const banner = ` +/** + * @author Toru Nagashima + * See LICENSE file in root directory for full license. + */ +`.trim() + +export default defineConfig({ + entry: "./src/index.ts", + target: "es2015", + sourcemap: true, + outputOptions: { + banner, + }, + dts: true, + format: "cjs", +})