Skip to content

Commit

Permalink
Merge pull request #678 from nextcloud-libraries/feat/migrate-vite
Browse files Browse the repository at this point in the history
feat: Migrate to Vite for building and Vitest for testing
  • Loading branch information
susnux authored Apr 22, 2024
2 parents 9999cad + 2392809 commit 8504f30
Show file tree
Hide file tree
Showing 9 changed files with 3,594 additions and 776 deletions.
18 changes: 0 additions & 18 deletions .travis.yml

This file was deleted.

8 changes: 0 additions & 8 deletions jest.config.ts

This file was deleted.

4,250 changes: 3,551 additions & 699 deletions package-lock.json

Large diffs are not rendered by default.

27 changes: 11 additions & 16 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,35 +22,30 @@
"exports": {
".": {
"types": "./dist/index.d.ts",
"import": "./dist/index.es.mjs",
"import": "./dist/index.mjs",
"require": "./dist/index.cjs"
}
},
"scripts": {
"build": "rollup --config rollup.config.js",
"build": "vite --mode production build",
"build:doc": "typedoc --out dist/doc lib/index.ts && touch dist/doc/.nojekyll",
"check-types": "tsc --noEmit",
"dev": "rollup --config rollup.config.js --watch",
"dev": "vite --mode development build --watch",
"lint": "eslint lib test *.ts",
"lint:fix": "eslint --fix lib test *.ts",
"test": "jest",
"test:coverage": "jest --coverage",
"test:watch": "jest --watchAll"
"test": "vitest run",
"test:coverage": "vitest run --coverage",
"test:watch": "vitest watch"
},
"devDependencies": {
"@jest/globals": "^29.7.0",
"@nextcloud/eslint-config": "^8.3.0",
"@rollup/plugin-typescript": "^11.1.6",
"@nextcloud/vite-config": "^1.2.2",
"@types/node": "^20.12.7",
"@vitest/coverage-v8": "^1.5.0",
"eslint": "^8.57.0",
"jest": "^29.7.0",
"jest-environment-jsdom": "^29.7.0",
"rollup": "^4.16.0",
"ts-jest": "^29.1.2",
"ts-node": "^10.9.2",
"tslib": "^2.6.2",
"typedoc": "^0.25.13",
"typescript": "^5.4.5"
"typescript": "^5.4.5",
"vite": "^5.2.10",
"vitest": "^1.5.0"
},
"engines": {
"node": "^20.0.0",
Expand Down
31 changes: 0 additions & 31 deletions rollup.config.js

This file was deleted.

2 changes: 1 addition & 1 deletion test/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { expect, test } from 'vitest'
import { loadState } from '../lib'
import { expect, test } from '@jest/globals'

test('throw if nothing found', () => {
expect(() => loadState('test', 'key')).toThrow(new Error('Could not find initial state key of test'))
Expand Down
6 changes: 3 additions & 3 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"include": [
"./lib/**/*.ts"
"./lib/**.ts"
],
"compilerOptions": {
"allowSyntheticDefaultImports": true,
"moduleResolution": "node",
"moduleResolution": "Bundler",
"target": "ESNext",
"module": "esnext",
"module": "ESNext",
"declaration": true,
"strict": true,
"noImplicitAny": false,
Expand Down
10 changes: 10 additions & 0 deletions vite.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { createLibConfig } from '@nextcloud/vite-config'

export default createLibConfig(
{
index: `${__dirname}/lib/index.ts`,
},
{
libraryFormats: ['es', 'cjs'],
},
)
18 changes: 18 additions & 0 deletions vitest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import type { UserConfig } from 'vite'
import viteConfig from './vite.config'

export default async (env) => {
const config = typeof viteConfig === 'function' ? await viteConfig(env) : viteConfig
// node-externals conflicts with vitest
config.plugins = config.plugins!.filter((plugin) => plugin && (!('name' in plugin) || plugin?.name !== 'node-externals'))

return {
...config,
test: {
environment: 'jsdom',
coverage: {
reporter: ['text', 'lcov'],
},
},
} as UserConfig
}

0 comments on commit 8504f30

Please sign in to comment.