Skip to content

Commit 5c04494

Browse files
committed
chore: update tooling config
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
1 parent 0e4db12 commit 5c04494

9 files changed

Lines changed: 165 additions & 53 deletions

File tree

.eslintrc.js

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,23 @@ module.exports = {
1111
extends: [
1212
'plugin:vue/essential',
1313
'eslint:recommended',
14+
'plugin:@typescript-eslint/recommended',
1415
],
1516
parserOptions: {
16-
parser: '@babel/eslint-parser',
17-
requireConfigFile: false,
17+
parser: '@typescript-eslint/parser',
18+
ecmaVersion: 2021,
19+
sourceType: 'module',
1820
},
21+
parser: 'vue-eslint-parser',
22+
overrides: [
23+
{
24+
files: ['tests/**/*.ts'],
25+
env: {
26+
'vitest/globals': true,
27+
},
28+
plugins: ['vitest'],
29+
},
30+
],
1931
rules: {
2032
'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
2133
'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off',

.npmignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,16 @@
44
# Source files
55
src/
66
examples/
7+
tests/
78

89
# Config files
910
.babelrc
1011
.eslintrc.js
11-
vue.config.js
12+
env.d.ts
1213
postcss.config.js
14+
tsconfig.json
15+
vite.config.ts
16+
vitest.config.ts
1317
REUSE.toml
1418
LICENSES/
1519
CONTRIBUTING.md

REUSE.toml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,15 @@ default-copyright = "2025 LibreCode coop and contributors"
1212
path = [
1313
".babelrc",
1414
".eslintrc.js",
15+
"env.d.ts",
1516
"package.json",
1617
"package-lock.json",
1718
"postcss.config.js",
18-
"vue.config.js",
19+
"tsconfig.json",
20+
"vite.config.ts",
21+
"vitest.config.ts",
1922
"examples/**",
23+
"tests/**",
2024
"dist/**",
2125
]
2226
precedence = "aggregate"

env.d.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/// <reference types="vite/client" />
2+
3+
declare module '*.vue' {
4+
import type { DefineComponent } from 'vue'
5+
const component: DefineComponent<{}, {}, any>
6+
export default component
7+
}

package.json

Lines changed: 38 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,18 @@
11
{
22
"name": "@libresign/pdf-elements",
3-
"description": "PDF viewer with draggable and resizable element overlays for Vue 2",
3+
"description": "PDF viewer with draggable and resizable element overlays for Vue 3",
44
"version": "0.4.0",
55
"author": "LibreCode <contact@librecode.coop>",
66
"private": false,
7-
"main": "dist/pdf-elements.umd.js",
8-
"module": "dist/pdf-elements.esm.js",
7+
"main": "dist/index.js",
8+
"module": "dist/index.js",
9+
"types": "dist/index.d.ts",
10+
"exports": {
11+
".": {
12+
"import": "./dist/index.js",
13+
"types": "./dist/index.d.ts"
14+
}
15+
},
916
"repository": {
1017
"type": "git",
1118
"url": "https://github.com/LibreSign/pdf-elements"
@@ -21,31 +28,41 @@
2128
"draggable",
2229
"resizable",
2330
"libresign",
24-
"vue2"
31+
"vue3"
2532
],
2633
"scripts": {
27-
"serve": "vue-cli-service serve",
28-
"build": "vue-cli-service build",
29-
"build:lib": "vue-cli-service build --target lib --name pdf-elements src/index.js",
30-
"lint": "vue-cli-service lint --no-fix",
31-
"lint:fix": "vue-cli-service lint"
34+
"dev": "vite",
35+
"build": "vite build",
36+
"build:report": "vite build --mode report",
37+
"build:demo": "vite build --mode demo",
38+
"preview:demo": "vite preview --outDir dist-demo",
39+
"test": "vitest run",
40+
"test:watch": "vitest",
41+
"lint": "eslint . --ext .vue,.ts,.js --max-warnings=0",
42+
"lint:fix": "eslint . --ext .vue,.ts,.js --fix"
3243
},
3344
"dependencies": {
34-
"pdfjs-dist": "^5.4.530",
35-
"vue": "^2.7.16"
45+
"pdfjs-dist": "^5.4.624",
46+
"vue": "^3.5.28"
3647
},
3748
"devDependencies": {
38-
"@babel/core": "^7.28.6",
39-
"@babel/eslint-parser": "^7.28.6",
40-
"@babel/plugin-transform-private-methods": "^7.28.6",
4149
"@nextcloud/browserslist-config": "^3.1.2",
42-
"@vue/cli-plugin-babel": "^5.0.9",
43-
"@vue/cli-plugin-eslint": "^5.0.9",
44-
"@vue/cli-service": "^5.0.9",
45-
"eslint": "^8.57.1",
46-
"eslint-plugin-vue": "^9.24.0",
50+
"@typescript-eslint/eslint-plugin": "^8.56.0",
51+
"@typescript-eslint/parser": "^8.56.0",
52+
"@vitejs/plugin-vue": "^6.0.4",
53+
"eslint": "^9.0.0",
54+
"eslint-plugin-vue": "^10.8.0",
55+
"eslint-plugin-vitest": "^0.5.4",
56+
"happy-dom": "^20.7.0",
4757
"postcss": "^8.5.6",
48-
"vue-template-compiler": "^2.7.16"
58+
"rollup-plugin-visualizer": "^7.0.0",
59+
"typescript": "^5.9.3",
60+
"vite": "^7.3.1",
61+
"vite-plugin-dts": "^4.5.4",
62+
"vitest": "^4.0.18",
63+
"@vue/test-utils": "^2.4.6",
64+
"vue-eslint-parser": "^10.4.0",
65+
"vue-tsc": "^3.2.4"
4966
},
5067
"browserslist": [
5168
"extends @nextcloud/browserslist-config"
@@ -56,5 +73,6 @@
5673
"COPYING",
5774
"README.md"
5875
],
76+
"sideEffects": false,
5977
"license": "AGPL-3.0-or-later"
6078
}

tsconfig.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"compilerOptions": {
3+
"target": "ES2020",
4+
"module": "NodeNext",
5+
"moduleResolution": "NodeNext",
6+
"lib": ["ES2020", "DOM", "DOM.Iterable"],
7+
"jsx": "preserve",
8+
"strict": false,
9+
"noImplicitAny": false,
10+
"skipLibCheck": true,
11+
"useDefineForClassFields": true,
12+
"resolveJsonModule": true,
13+
"allowSyntheticDefaultImports": true,
14+
"esModuleInterop": true,
15+
"types": ["vite/client", "vitest/globals"]
16+
},
17+
"include": ["env.d.ts", "src", "examples", "tests"]
18+
}

vite.config.ts

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
// SPDX-FileCopyrightText: 2026 LibreCode coop and contributors
2+
// SPDX-License-Identifier: AGPL-3.0-or-later
3+
4+
import path from 'node:path'
5+
import { defineConfig } from 'vite'
6+
import vue from '@vitejs/plugin-vue'
7+
import dts from 'vite-plugin-dts'
8+
9+
export default defineConfig(async ({ command, mode }) => {
10+
const isDemo = command === 'serve' || mode === 'demo'
11+
const plugins = [vue()]
12+
13+
if (!isDemo) {
14+
plugins.push(
15+
dts({
16+
entryRoot: 'src',
17+
outDir: 'dist',
18+
insertTypesEntry: true,
19+
include: ['src'],
20+
exclude: ['examples', 'tests'],
21+
})
22+
)
23+
}
24+
25+
if (mode === 'report') {
26+
const { visualizer } = await import('rollup-plugin-visualizer')
27+
plugins.push(
28+
visualizer({
29+
filename: 'dist/bundle-report.html',
30+
gzipSize: true,
31+
brotliSize: true,
32+
open: false,
33+
})
34+
)
35+
}
36+
37+
return {
38+
root: isDemo ? 'examples' : undefined,
39+
server: {
40+
host: '0.0.0.0',
41+
},
42+
plugins,
43+
build: isDemo
44+
? {
45+
outDir: path.resolve(__dirname, 'dist-demo'),
46+
emptyOutDir: true,
47+
}
48+
: {
49+
lib: {
50+
entry: path.resolve(__dirname, 'src/index.ts'),
51+
name: 'PDFElements',
52+
formats: ['es'],
53+
fileName: 'index',
54+
},
55+
rollupOptions: {
56+
external: ['vue'],
57+
output: {
58+
globals: {
59+
vue: 'Vue',
60+
},
61+
},
62+
},
63+
},
64+
}
65+
})

vitest.config.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// SPDX-FileCopyrightText: 2026 LibreCode coop and contributors
2+
// SPDX-License-Identifier: AGPL-3.0-or-later
3+
4+
import { defineConfig } from 'vitest/config'
5+
import vue from '@vitejs/plugin-vue'
6+
7+
export default defineConfig({
8+
plugins: [vue()],
9+
test: {
10+
environment: 'happy-dom',
11+
include: ['tests/**/*.spec.ts'],
12+
},
13+
})

vue.config.js

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

0 commit comments

Comments
 (0)