Skip to content

Commit fa88ba0

Browse files
committed
update
1 parent bb482d3 commit fa88ba0

18 files changed

+2462
-12899
lines changed

.eslintignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
!docs/.vitepress
2+
dist
3+
examples

.eslintrc.js

Lines changed: 5 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -4,44 +4,14 @@ module.exports = {
44
node: true
55
},
66
extends: [
7-
'plugin:vue/essential',
87
'eslint:recommended',
9-
'airbnb-base',
8+
'plugin:vue/recommended',
9+
'@vue/typescript/recommended'
1010
],
11-
globals: {
12-
Atomics: 'readonly',
13-
SharedArrayBuffer: 'readonly',
14-
},
1511
parserOptions: {
16-
ecmaVersion: 2020
12+
parser: '@typescript-eslint/parser'
1713
},
18-
ignorePatterns: ['**/tests/unit/*.spec.js'],
1914
rules: {
20-
'semi': 'off',
21-
'comma-dangle': ["error", "never"],
22-
'prefer-arrow-callback': 0,
23-
'consistent-return': 0,
24-
'prefer-destructuring': 0,
25-
'no-param-reassign': 0,
26-
'max-len': 0,
27-
'no-var': 0
28-
},
29-
overrides: [
30-
{
31-
files: ['**/tests/unit/*.spec.js'],
32-
env: {
33-
jest: true
34-
}
35-
},
36-
{
37-
files: ['**/*.vue'],
38-
extends: [
39-
'plugin:vue/essential',
40-
'eslint:recommended',
41-
],
42-
plugins: [
43-
'vue'
44-
]
45-
}
46-
]
15+
// Customize your rules here
16+
}
4717
};

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,5 @@ pnpm-debug.log*
1313
.temp
1414
.cache
1515
vue-v3
16+
*.bak
17+
examples

babel.config.js

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

jest.config.js

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

package.json

Lines changed: 35 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -4,61 +4,46 @@
44
"private": false,
55
"description": "Easy formatted numbers, currency and percentage with input/directive mask for Vue.js",
66
"author": "Dipak Sarkar <hello@dipaksarkar.in> (https://dipaksarkar.in/)",
7-
"main": "dist/index.cjs.js",
8-
"module": "dist/index.esm.js",
9-
"unpkg": "dist/index.min.js",
10-
"style": "dist/styles.css",
11-
"licence": "MIT",
7+
"license": "MIT",
8+
"module": "./dist/index.mjs",
9+
"main": "./dist/index.cjs",
10+
"types": "./dist/index.d.ts",
1211
"files": [
13-
"dist/*",
14-
"src/**/*.vue"
12+
"dist"
1513
],
14+
"exports": {
15+
".": {
16+
"import": "./dist/index.mjs",
17+
"require": "./dist/index.cjs",
18+
"types": "./dist/index.d.ts"
19+
}
20+
},
21+
"sideeffects": false,
1622
"scripts": {
17-
"build": "rollup --c rollup.config.js",
23+
"build": "tsc --emitDeclarationOnly --skipLibCheck --declaration --outDir .temp/types && rollup --c rollup.config.js",
1824
"docs:build": "vuepress build docs",
1925
"docs:dev": "vuepress dev docs",
2026
"test": "jest tests/*",
2127
"lint": "eslint 'src/**/*.{js,vue}'",
2228
"push": "clear && git config core.ignorecase false && branch=\"$(git symbolic-ref -q HEAD)\" || \"dev\" && branch=${branch##refs/heads/} && branch=${branch:-HEAD} && echo Pushing to Branch \"$branch\" && echo Please type your commit message && read msg && clear && git add . && git commit -m \"$msg\" && git push origin \"$branch\""
2329
},
2430
"devDependencies": {
25-
"@babel/core": "^7.9.0",
26-
"@babel/preset-env": "^7.9.5",
27-
"@vue/cli-plugin-unit-jest": "^4.5.13",
28-
"@vue/cli-service": "^4.5.13",
29-
"@vue/test-utils": "^1.2.2",
30-
"@vuedoc/md": "^1.6.0",
31-
"@vuepress/plugin-back-to-top": "^1.8.2",
32-
"@vuepress/plugin-google-analytics": "^1.8.2",
33-
"@vuepress/plugin-medium-zoom": "^1.8.2",
34-
"@vuepress/plugin-register-components": "^1.4.1",
35-
"babel-core": "^6.26.3",
36-
"babel-jest": "^25.3.0",
37-
"babel-preset-env": "^1.7.0",
38-
"babel-preset-vue": "^2.0.2",
39-
"eslint": "^6.8.0",
40-
"eslint-config-airbnb-base": "^14.1.0",
41-
"eslint-plugin-import": "^2.20.2",
42-
"eslint-plugin-vue": "^6.2.2",
43-
"jest": "^25.3.0",
44-
"node-fetch": "^2.6.0",
45-
"npm-run-all": "^4.1.5",
46-
"postcss": "6.0",
47-
"quasar": "^1.11.3",
31+
"@rollup/plugin-commonjs": "^24.0.1",
32+
"@rollup/plugin-node-resolve": "^15.0.1",
33+
"@vue/eslint-config-typescript": "^11.0.2",
34+
"@vue/test-utils": "^2.2.10",
35+
"eslint": "^8.34.0",
36+
"eslint-plugin-vue": "^9.9.0",
37+
"jest": "^29.4.2",
38+
"lint-staged": "^13.1.1",
4839
"rollup": "^2.6.1",
49-
"rollup-plugin-buble": "^0.19.8",
5040
"rollup-plugin-commonjs": "^10.1.0",
51-
"rollup-plugin-css-only": "^2.0.0",
52-
"rollup-plugin-filesize": "^9.1.1",
41+
"rollup-plugin-dts": "^5.1.1",
42+
"rollup-plugin-filesize": "^9.1.2",
5343
"rollup-plugin-node-resolve": "^5.2.0",
54-
"rollup-plugin-replace": "^2.2.0",
55-
"rollup-plugin-terser": "^5.3.0",
56-
"rollup-plugin-vue": "^5.1.6",
57-
"vue": "^2.6.11",
58-
"vue-jest": "^3.0.5",
59-
"vue-template-compiler": "^2.6.11",
60-
"vuepress": "^1.8.2",
61-
"vuepress-plugin-demo-code": "^0.5.0"
44+
"rollup-plugin-typescript2": "^0.34.1",
45+
"typescript": "^4.9.5",
46+
"vue": "2.6.0"
6247
},
6348
"bugs": {
6449
"url": "https://github.com/coders-tm/vue-number-format/issues"
@@ -76,12 +61,19 @@
7661
"currency input",
7762
"money input"
7863
],
79-
"license": "MIT",
8064
"repository": {
8165
"type": "git",
8266
"url": "https://github.com/coders-tm/vue-number-format.git"
8367
},
8468
"publishConfig": {
8569
"@coders-tm:registry": "https://npm.pkg.github.com"
70+
},
71+
"simple-git-hooks": {
72+
"pre-commit": "npx lint-staged"
73+
},
74+
"lint-staged": {
75+
"{**/*,*}.{js,ts,vue}": [
76+
"eslint --fix"
77+
]
8678
}
8779
}

rollup.config.js

Lines changed: 34 additions & 104 deletions
Original file line numberDiff line numberDiff line change
@@ -1,122 +1,52 @@
1-
import vue from 'rollup-plugin-vue'
2-
import buble from 'rollup-plugin-buble'
1+
import typescript from 'rollup-plugin-typescript2'
32
import commonjs from 'rollup-plugin-commonjs'
4-
import replace from 'rollup-plugin-replace'
5-
import { terser } from 'rollup-plugin-terser'
63
import resolve from 'rollup-plugin-node-resolve'
4+
import dts from 'rollup-plugin-dts'
75
import filesize from 'rollup-plugin-filesize'
8-
import css from 'rollup-plugin-css-only'
96
import pkg from './package.json'
107

118
const banner = `/**
129
* Vue Number Format ${pkg.version}
13-
* (c) 2018-${new Date().getFullYear()} ${pkg.author}
10+
* (c) 2021-${new Date().getFullYear()} ${pkg.author}
1411
* @license ${pkg.license}
1512
*/`
1613

17-
const baseConfig = {
18-
input: 'src/index.js',
19-
plugins: {
20-
preVue: [
21-
replace({
22-
'process.env.NODE_ENV': JSON.stringify('production')
23-
}),
24-
commonjs()
25-
],
26-
vue: {
27-
css: true,
28-
template: {
29-
isProduction: true
30-
}
31-
},
32-
postVue: [
33-
buble({
34-
transforms: {
35-
dangerousForOf: true
36-
}
37-
}),
38-
filesize()
39-
]
40-
}
41-
};
42-
4314
export default [
4415
{
45-
...baseConfig,
46-
output: {
47-
file: pkg.module,
48-
format: 'esm',
49-
exports: 'named',
50-
sourcemap: true,
51-
banner
52-
},
16+
input: 'src/index.ts',
17+
output: [
18+
{
19+
compact: true,
20+
file: pkg.main,
21+
format: 'cjs',
22+
exports: 'named',
23+
name: 'VueNumberFormat',
24+
banner
25+
},
26+
{
27+
file: pkg.module,
28+
format: 'esm',
29+
exports: 'named',
30+
banner
31+
}
32+
],
5333
plugins: [
54-
...baseConfig.plugins.preVue,
55-
css({
56-
output: pkg.style
57-
}),
58-
vue({
59-
...baseConfig.plugins.vue,
60-
css: false
61-
}),
62-
...baseConfig.plugins.postVue,
63-
terser({
64-
output: {
65-
ecma: 6
34+
typescript({
35+
tsconfigOverride: {
36+
compilerOptions: {
37+
declaration: false
38+
}
6639
}
6740
}),
68-
resolve()
69-
]
70-
},
71-
{
72-
...baseConfig,
73-
output: {
74-
compact: true,
75-
file: pkg.main,
76-
format: 'cjs',
77-
name: 'VueNumberFormat',
78-
exports: 'named',
79-
sourcemap: true,
80-
banner
81-
},
82-
plugins: [
83-
...baseConfig.plugins.preVue,
84-
css({
85-
output: pkg.style
86-
}),
87-
vue({
88-
...baseConfig.plugins.vue,
89-
template: {
90-
...baseConfig.plugins.vue.template,
91-
optimizeSSR: true
92-
},
93-
css: false
94-
}),
95-
...baseConfig.plugins.postVue,
96-
resolve()
97-
]
41+
resolve(),
42+
commonjs(),
43+
filesize()
44+
],
45+
external: ['vue']
9846
},
9947
{
100-
...baseConfig,
101-
output: {
102-
compact: true,
103-
file: pkg.unpkg,
104-
format: 'iife',
105-
name: 'VueNumberFormat',
106-
exports: 'named',
107-
sourcemap: true,
108-
banner
109-
},
110-
plugins: [
111-
...baseConfig.plugins.preVue,
112-
vue(baseConfig.plugins.vue),
113-
...baseConfig.plugins.postVue,
114-
terser({
115-
output: {
116-
ecma: 5
117-
}
118-
}),
119-
resolve()
120-
]
48+
input: './.temp/types/index.d.ts',
49+
output: [{ file: 'dist/index.d.ts', format: 'es' }],
50+
plugins: [dts()]
12151
}
122-
];
52+
]

src/component.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
2+
import Vue from 'vue';
3+
4+
export default Vue.extend({
5+
data() {
6+
return {
7+
message: 'Hello, World!'
8+
};
9+
},
10+
template: `<template>
11+
<div>{{ message }}</div>
12+
</template>`
13+
});

0 commit comments

Comments
 (0)