Skip to content
This repository has been archived by the owner on Oct 26, 2024. It is now read-only.

Commit

Permalink
Removing lodash and bump dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
guillaumebriday committed Dec 26, 2023
1 parent dbf589b commit 8927490
Show file tree
Hide file tree
Showing 7 changed files with 519 additions and 116 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Chore

- Adding interactive example
- Using a `debounce` function without `lodash.debounce`.

## [5.0.1] - 2023-12-02

Expand Down
19 changes: 10 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,28 +24,29 @@
"scripts": {
"format": "prettier-standard '**/*.{ts,css,html}' --format",
"lint": "prettier-standard '**/*.{ts,css,html}' --lint",
"dev": "vite",
"build": "tsc --noEmit && vite build",
"version": "yarn build",
"np": "np --no-2fa --no-tests"
},
"devDependencies": {
"@babel/core": "7.23.5",
"@babel/core": "7.23.6",
"@babel/plugin-syntax-class-properties": "7.12.13",
"@babel/preset-env": "^7.23.5",
"@babel/preset-env": "^7.23.6",
"@babel/preset-typescript": "^7.23.3",
"@hotwired/stimulus": "^3.2.2",
"@types/lodash": "^4.14.202",
"np": "^9.0.0",
"@hotwired/turbo": "^8.0.0-beta.2",
"autoprefixer": "^10.4.16",
"np": "^9.2.0",
"postcss": "^8.4.32",
"prettier-standard": "16.4.1",
"typescript": "^5.3.2",
"vite": "^5.0.4"
"tailwindcss": "^3.4.0",
"typescript": "^5.3.3",
"vite": "^5.0.10"
},
"peerDependencies": {
"@hotwired/stimulus": "^3.1.1"
},
"dependencies": {
"lodash.debounce": "^4.0.8"
},
"resolutions": {
"prettierx": "~0.19.0"
}
Expand Down
6 changes: 2 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import { Controller } from '@hotwired/stimulus'
import debounce from 'lodash.debounce'
import { debounce } from './utils'

export default class extends Controller {
// @ts-ignore
element: HTMLFormElement
export default class extends Controller<HTMLFormElement> {
delayValue: number

static values = {
Expand Down
11 changes: 11 additions & 0 deletions src/utils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
export function debounce (callback: Function, delay: number) {
let timeout: number

return (...args) => {
clearTimeout(timeout)

timeout = setTimeout(() => {
callback.apply(this, args)
}, delay)
}
}
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"compilerOptions": {
"lib": ["dom", "es6"],
"types": ["lodash"],
"types": ["vite/client"],
"skipLibCheck": true,
"target": "es6",
"moduleResolution": "node"
Expand Down
5 changes: 2 additions & 3 deletions vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,10 @@ module.exports = {
name: 'stimulus-rails-autosave'
},
rollupOptions: {
external: ['@hotwired/stimulus', 'lodash.debounce'],
external: ['@hotwired/stimulus'],
output: {
globals: {
'@hotwired/stimulus': 'Stimulus',
'lodash.debounce': 'debounce'
'@hotwired/stimulus': 'Stimulus'
}
}
}
Expand Down
Loading

0 comments on commit 8927490

Please sign in to comment.