Skip to content

Commit d6cb51f

Browse files
authored
feat: migrate to tsdown (#266)
* feat: migrate to `tsdown` * chore: update * chore: get `name` and `version` from `package.json` directly * chore: update * chore: update * build: remove `sourceMap` in `tsconfig` * chore: update * chore: update tsconfig * chore: cleanup some configs relate to output * chore: update and fix test * chore: remove invalid script
1 parent 4e48327 commit d6cb51f

File tree

11 files changed

+45
-87
lines changed

11 files changed

+45
-87
lines changed

.gitignore

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
/.temp
21
/coverage
32
node_modules
43
/test/temp
5-
/index.*
64
/npm-debug.log
75
/test.js
86
/test/fixtures/espree-v8/node_modules
97
/test/fixtures/integrations/**/_actual.json
8+
/dist

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -324,9 +324,8 @@ The `npm install` command installs dependencies.
324324
### Development Tools
325325

326326
- `npm test` runs tests and measures coverage.
327-
- `npm run build` compiles TypeScript source code to `index.js`, `index.js.map`, and `index.d.ts`.
327+
- `npm run build` compiles TypeScript source code to `index.js`, `index.js.map`, and `index.d.ts` in `dist`.
328328
- `npm run coverage` shows the coverage result of `npm test` command with the default browser.
329-
- `npm run clean` removes the temporary files which are created by `npm test` and `npm run build`.
330329
- `npm run lint` runs ESLint.
331330
- `npm run update-fixtures` updates files in `test/fixtures/ast` directory based on `test/fixtures/ast/*/source.vue` files.
332331
- `npm run watch` runs `build`, `update-fixtures`, and tests with `--watch` option.

eslint.config.mjs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,15 @@ const compat = new FlatCompat({
2222
export default [
2323
{
2424
ignores: [
25-
".temp",
2625
"coverage",
26+
"dist",
2727
"**/node_modules",
2828
"src/html/util/alternative-cr.ts",
2929
"src/html/util/attribute-names.ts",
3030
"src/html/util/entities.ts",
3131
"src/html/util/tag-names.ts",
3232
"test/fixtures",
3333
"test/temp",
34-
"index.d.ts",
35-
"index.js",
3634
],
3735
},
3836
...nodeDeps.configs["flat/recommended"],

package.json

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
"name": "vue-eslint-parser",
33
"version": "10.2.0",
44
"description": "The ESLint custom parser for `.vue` files.",
5-
"main": "index.js",
5+
"main": "dist/index.js",
66
"files": [
7-
"index.*"
7+
"dist"
88
],
99
"engines": {
1010
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
@@ -38,7 +38,6 @@
3838
"@vitest/ui": "^3.2.4",
3939
"chokidar": "^3.5.2",
4040
"cross-spawn": "^7.0.3",
41-
"dts-bundle": "^0.7.3",
4241
"eslint": "^9.19.0",
4342
"eslint-plugin-eslint-comments": "^3.2.0",
4443
"eslint-plugin-jsonc": "^2.19.1",
@@ -50,22 +49,16 @@
5049
"jsonc-eslint-parser": "^2.0.3",
5150
"npm-run-all": "^4.1.5",
5251
"prettier": "^3.4.2",
53-
"rimraf": "^3.0.2",
54-
"rollup": "^2.60.0",
55-
"rollup-plugin-node-resolve": "^5.2.0",
56-
"rollup-plugin-replace": "^2.2.0",
57-
"rollup-plugin-sourcemaps": "^0.6.3",
5852
"ts-node": "^10.9.2",
53+
"tsdown": "^0.12.9",
5954
"typescript": "~5.7.3",
6055
"vite": "^6.3.5",
6156
"vitest": "^3.2.4",
6257
"wait-on": "^6.0.0",
6358
"warun": "^1.0.0"
6459
},
6560
"scripts": {
66-
"prebuild": "npm run -s clean",
67-
"build": "tsc --module es2015 && rollup -c -o index.js && dts-bundle --name vue-eslint-parser --main .temp/index.d.ts --out ../index.d.ts",
68-
"clean": "rimraf .temp index.*",
61+
"build": "tsdown",
6962
"coverage": "vitest --coverage --ui",
7063
"lint": "eslint src test package.json",
7164
"test": "vitest",
@@ -74,11 +67,9 @@
7467
"preversion": "npm test",
7568
"version": "npm run -s build",
7669
"postversion": "git push && git push --tags",
77-
"prewatch": "npm run -s clean",
7870
"watch": "run-p watch:*",
79-
"watch:tsc": "tsc --module es2015 --watch",
80-
"watch:rollup": "wait-on .temp/index.js && rollup -c -o index.js --watch",
81-
"watch:update-ast": "wait-on index.js && warun index.js \"test/fixtures/ast/*/*.vue\" -- ts-node scripts/update-fixtures-ast.js"
71+
"watch:tsdown": "tsdown --watch",
72+
"watch:update-ast": "wait-on dist/index.js && warun dist/index.js \"test/fixtures/ast/*/*.vue\" -- ts-node scripts/update-fixtures-ast.js"
8273
},
8374
"repository": {
8475
"type": "git",

rollup.config.js

Lines changed: 0 additions & 35 deletions
This file was deleted.

src/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import {
2525
import { parseStyleElements } from "./style/index"
2626
import { analyzeScope } from "./script/scope-analyzer"
2727
import { analyzeScriptSetupScope } from "./script-setup/scope-analyzer"
28+
import { name, version } from "../package.json" with { type: "json" }
2829

2930
const STARTS_WITH_LT = /^\s*</u
3031

@@ -211,7 +212,6 @@ function parseAsScript(code: string, options: ParserOptions) {
211212
}
212213

213214
export const meta = {
214-
name: "vue-eslint-parser",
215-
// eslint-disable-next-line no-process-env
216-
version: process.env.PACKAGE_VERSION,
215+
name,
216+
version,
217217
}

test/fixtures/.eslintrc.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"parser": "../../index.js"
2+
"parser": "../../dist/index.js"
33
}

test/integrations.test.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,14 @@ const FIXTURE_DIR = path.join(__dirname, "fixtures/integrations")
2222

2323
describe("Integration tests", () => {
2424
beforeAll(async () => {
25-
await import("ts-node/register")
25+
const { register } = await import("ts-node")
26+
register({
27+
transpileOnly: true,
28+
compilerOptions: {
29+
module: "commonjs",
30+
moduleResolution: "node",
31+
},
32+
})
2633
})
2734
for (const target of fs.readdirSync(FIXTURE_DIR)) {
2835
it(target, async () => {

tsconfig.json

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
{
2-
"compileOnSave": true,
32
"compilerOptions": {
43
"allowJs": false,
54
"allowSyntheticDefaultImports": true,
@@ -8,35 +7,28 @@
87
"alwaysStrict": true,
98
"baseUrl": ".",
109
"checkJs": false,
11-
"declaration": true,
1210
"esModuleInterop": true,
1311
"forceConsistentCasingInFileNames": true,
14-
"inlineSources": true,
1512
"lib": ["es2023"],
16-
"module": "commonjs",
17-
"moduleResolution": "node",
13+
"module": "preserve",
14+
"moduleResolution": "bundler",
1815
"newLine": "LF",
19-
"noEmitOnError": true,
16+
"noEmit": true,
2017
"noFallthroughCasesInSwitch": true,
2118
"noImplicitAny": true,
2219
"noImplicitReturns": true,
2320
"noImplicitThis": true,
2421
"noUnusedLocals": true,
2522
"noUnusedParameters": true,
26-
"outDir": ".temp",
2723
"paths": {
2824
"*": ["typings/*"]
2925
},
30-
"pretty": true,
31-
"removeComments": true,
32-
"sourceMap": true,
33-
"sourceRoot": "src",
26+
"resolveJsonModule": true,
3427
"strict": true,
3528
"strictNullChecks": true,
3629
"target": "ES2024",
3730

3831
"skipLibCheck": true
3932
},
40-
"include": ["src/**/*.ts"],
41-
"references": [{ "path": "./tsconfig.test.json" }]
33+
"include": ["**/*.ts"]
4234
}

tsconfig.test.json

Lines changed: 0 additions & 12 deletions
This file was deleted.

0 commit comments

Comments
 (0)