Skip to content
This repository was archived by the owner on Apr 9, 2025. It is now read-only.

Commit 6f5ac5a

Browse files
author
Daniel Requejo
committed
📦 Reduce import cost:
- Amend tsconfig - Amend package.json - Change to named exports
1 parent e551992 commit 6f5ac5a

13 files changed

+42
-36
lines changed

Diff for: package.json

+14-10
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,20 @@
11
{
2-
"author": "Dennis R. Bosmans",
32
"name": "vue-form-handler",
3+
"version": "0.0.4",
4+
"type": "module",
5+
"license": "MIT",
6+
"author": "Dennis R. Bosmans",
7+
"sideEffects": false,
48
"description": "Vue 3 form handler, with validation, error handling, and more.",
9+
"homepage": "https://www.vue-form-handler.com/",
510
"repository": {
611
"type": "git",
712
"url": "https://github.com/dbssman/vue-form-handler"
813
},
9-
"homepage": "https://www.vue-form-handler.com/",
10-
"license": "MIT",
14+
"bugs": {
15+
"url": "https://github.com/dbssman/vue-form-handler/issues"
16+
},
1117
"private": false,
12-
"version": "0.0.4",
13-
"type": "module",
1418
"keywords": [
1519
"vue",
1620
"vue handler",
@@ -21,13 +25,13 @@
2125
"files": [
2226
"dist"
2327
],
24-
"main": "./dist/vue-form-handler.umd.cjs",
25-
"module": "./dist/vue-form-handler.js",
28+
"main": "./dist/index.js",
29+
"module": "./dist/index.js",
2630
"types": "./dist/index.d.ts",
2731
"exports": {
2832
".": {
29-
"import": "./dist/vue-form-handler.js",
30-
"require": "./dist/vue-form-handler.umd.cjs",
33+
"import": "./dist/index.js",
34+
"require": "./dist/index.umd.cjs",
3135
"types": "./dist/index.d.ts"
3236
}
3337
},
@@ -42,6 +46,7 @@
4246
"docs:preview": "vitepress preview docs"
4347
},
4448
"devDependencies": {
49+
"vue": "^3.2.41",
4550
"@types/lodash-es": "^4.17.6",
4651
"@types/node": "^18.11.9",
4752
"@vitejs/plugin-vue": "^3.2.0",
@@ -55,7 +60,6 @@
5560
"vite-plugin-dts": "^1.7.1",
5661
"vitepress": "^1.0.0-alpha.33",
5762
"vitest": "^0.26.1",
58-
"vue": "^3.2.41",
5963
"vue-tsc": "^1.0.9"
6064
}
6165
}

Diff for: src/FormHandler.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import useFormHandler from './useFormHandler';
1+
import { useFormHandler } from './useFormHandler';
22
import { FormHandlerParams, FormHandlerReturn } from './types/formHandler';
33
import { defineComponent, PropType } from 'vue';
44

5-
export default defineComponent({
5+
export const FormHandler = defineComponent({
66
name: 'FormHandler',
77
props: {
88
initialValues: Object as PropType<FormHandlerParams['initialValues']>,

Diff for: src/core/constants.ts renamed to src/constants.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { BaseControlEmits } from "../types"
1+
import { BaseControlEmits } from "./types"
22

33
export const DEFAULT_FIELD_VALUE = null;
44

Diff for: src/index.ts

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
export { default as FormHandler } from './FormHandler'
2-
export { default as useFormHandler } from './useFormHandler'
3-
4-
export * from './core/constants'
5-
export type { Interceptor, FormValidation } from './types'
1+
export * from './FormHandler'
2+
export * from './useFormHandler'
3+
export * from './types'
4+
export * from './constants'

Diff for: src/logic/getDefaultFieldValue.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { isCheckboxInput } from "../utils"
2-
import { DEFAULT_FIELD_VALUE } from "../core/constants"
2+
import { DEFAULT_FIELD_VALUE } from "../constants"
33

44
export default (el: any) => {
55
if (!el) {

Diff for: src/logic/getNativeFieldValue.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { DEFAULT_FIELD_VALUE } from '../core/constants';
1+
import { DEFAULT_FIELD_VALUE } from '../constants';
22
import { isCheckboxInput, isMultipleSelect, isRadioInput } from "../utils"
33

44
export default (el: any) => {

Diff for: src/test/component.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import FormHandler from '../FormHandler'
1+
import { FormHandler } from '../FormHandler'
22
import { mount } from '@vue/test-utils'
33
import { expect, it, describe } from "vitest"
44

Diff for: src/test/handler.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import useFormHandler, { initialState } from '../useFormHandler';
1+
import { initialState, useFormHandler } from '../useFormHandler';
22
import { expect, it, describe } from "vitest"
33

44
describe('Form handler testing', () => {

Diff for: src/test/register.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { describe, it, expect } from 'vitest'
2-
import useFormHandler from '../useFormHandler'
2+
import { useFormHandler } from '../useFormHandler'
33

44
describe('Register function testing', () => {
55
it('Registering a field', () => {

Diff for: src/types/formHandler.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -169,4 +169,4 @@ export interface FormHandlerReturn {
169169
}
170170

171171
/** Form handler solution as a composable function */
172-
export type FormHandler = (_?: FormHandlerParams) => FormHandlerReturn
172+
export type UseFormHandler = (_?: FormHandlerParams) => FormHandlerReturn

Diff for: src/useFormHandler.ts

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { NativeValidations } from './types/validations';
2-
import { DEFAULT_FIELD_VALUE } from './core/constants';
2+
import { DEFAULT_FIELD_VALUE } from './constants';
33
import {
44
ModifiedValues,
55
TriggerValidation,
6-
FormHandler,
6+
UseFormHandler,
77
ResetField,
88
ResetForm,
99
InitControl,
@@ -36,7 +36,7 @@ export const initialState = () => ({
3636
isValid: true,
3737
})
3838

39-
const useFormHandler: FormHandler = ({
39+
export const useFormHandler: UseFormHandler = ({
4040
initialValues = {},
4141
interceptor,
4242
validate,
@@ -290,5 +290,3 @@ const useFormHandler: FormHandler = ({
290290
values: readonly(values)
291291
}
292292
}
293-
294-
export default useFormHandler

Diff for: tsconfig.json

+7
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
"module": "ESNext",
66
"moduleResolution": "Node",
77
"strict": true,
8+
"strictNullChecks": true,
9+
"strictFunctionTypes": true,
810
"jsx": "preserve",
911
"resolveJsonModule": true,
1012
"isolatedModules": true,
@@ -14,8 +16,13 @@
1416
"DOM"
1517
],
1618
"skipLibCheck": true,
19+
"skipDefaultLibCheck": true,
1720
"noEmit": true,
1821
"declaration": true,
22+
"declarationMap": true,
23+
"noUnusedLocals": true,
24+
"sourceMap": true,
25+
"noImplicitAny": true,
1926
"types": [
2027
"vitest/importMeta"
2128
]

Diff for: vite.config.ts

+5-7
Original file line numberDiff line numberDiff line change
@@ -16,25 +16,23 @@ export default defineConfig({
1616
reporters: 'verbose',
1717
},
1818
build: {
19+
sourcemap: true,
20+
minify: false,
1921
lib: {
2022
entry: resolve(__dirname, 'src/index.ts'),
21-
name: 'VueFormHandler',
22-
fileName: 'vue-form-handler',
23+
name: 'vue-form-handler',
24+
fileName: 'index',
2325
},
2426
rollupOptions: {
25-
external: ['vue'],
2627
output: {
27-
globals: {
28-
vue: 'Vue'
29-
}
28+
sourcemapExcludeSources: true,
3029
}
3130
}
3231
},
3332
plugins: [
3433
vue(),
3534
dts({
3635
insertTypesEntry: true,
37-
exclude: ['**/logic', '**/utils'],
3836
}),
3937
]
4038
})

0 commit comments

Comments
 (0)