diff --git a/.npmignore b/.npmignore deleted file mode 100644 index c2658d7d..00000000 --- a/.npmignore +++ /dev/null @@ -1 +0,0 @@ -node_modules/ diff --git a/lib/requesttoken.ts b/lib/requesttoken.ts index 0d7bb9c2..0110b0f5 100644 --- a/lib/requesttoken.ts +++ b/lib/requesttoken.ts @@ -31,7 +31,7 @@ export function onRequestTokenUpdate(observer: CsrfTokenObserver): void { } // Listen to server event and keep token in sync -subscribe('csrf-token-update', e => { +subscribe('csrf-token-update', (e: any) => { token = e.token observers.forEach(observer => { diff --git a/package.json b/package.json index 6e7a231f..2eb4d0fd 100644 --- a/package.json +++ b/package.json @@ -2,20 +2,21 @@ "name": "@nextcloud/auth", "version": "2.2.1", "description": "Nextcloud helpers related to authentication and the current user", - "main": "dist/index.js", + "type": "module", + "main": "dist/index.cjs", "types": "dist/index.d.ts", "exports": { "types": "./dist/index.d.ts", - "import": "./dist/index.es.mjs", - "require": "./dist/index.js" + "import": "./dist/index.mjs", + "require": "./dist/index.cjs" }, "files": [ "dist/" ], "scripts": { - "build": "rollup --config rollup.config.mjs", + "build": "vite --mode production build", "build:doc": "typedoc --out dist/doc lib/index.ts && touch dist/doc/.nojekyll", - "check-types": "tsc --noEmit", + "dev": "vite --mode development run --watch", "dev": "rollup --config rollup.config.mjs --watch", "test": "jest", "test:watch": "jest --watchAll" @@ -35,16 +36,13 @@ }, "devDependencies": { "@nextcloud/typings": "^1.8.0", - "@rollup/plugin-typescript": "^11.1.6", - "jest": "^29.7.0", - "jest-environment-jsdom": "^29.7.0", - "rollup": "^4.16.0", - "tslib": "^2.6.2", + "@nextcloud/vite-config": "^1.2.2", "typedoc": "^0.25.13", - "typescript": "^5.4.5" + "typescript": "^5.4.5", + "vite": "^5.2.10" }, "engines": { "node": "^20.0.0", "npm": "^9.0.0" } -} \ No newline at end of file +} diff --git a/rollup.config.mjs b/rollup.config.mjs deleted file mode 100644 index 10826516..00000000 --- a/rollup.config.mjs +++ /dev/null @@ -1,35 +0,0 @@ -import typescript from '@rollup/plugin-typescript' - -const external = ['@nextcloud/event-bus'] - -export default [ - { - input: './lib/index.ts', - external, - plugins: [ - typescript({ - tsconfig: './tsconfig.json', - compilerOptions: { target: 'es5' }, - }), - ], - output: [ - { - dir: 'dist', - format: 'cjs', - sourcemap: true, - }, - ], - }, - { - input: 'lib/index.ts', - external, - plugins: [typescript()], - output: [ - { - file: 'dist/index.es.mjs', - format: 'esm', - sourcemap: true, - }, - ], - }, -] diff --git a/tsconfig.json b/tsconfig.json index 1ca50354..166786b7 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,10 +1,10 @@ { - "include": ["./lib/**/*.ts"], + "include": ["./lib/**.ts"], "compilerOptions": { "allowSyntheticDefaultImports": true, - "moduleResolution": "node", + "moduleResolution": "Bundler", "target": "ESNext", - "module": "esnext", + "module": "ESNext", "declaration": true, "strict": true, "noImplicitAny": false, diff --git a/vite.config.ts b/vite.config.ts new file mode 100644 index 00000000..4dc61393 --- /dev/null +++ b/vite.config.ts @@ -0,0 +1,10 @@ +import { createLibConfig } from '@nextcloud/vite-config' + +export default createLibConfig( + { + index: `${__dirname}/lib/index.ts`, + }, + { + libraryFormats: ['cjs', 'es'], + }, +)