Skip to content

Commit 03c6f1a

Browse files
authored
Fix vite build issue with import from accounting-js (#124)
accounting-js does not export default and vite build fails while trying to optimise its dependencies. Using named exports solves the issue and allows vite to optimise vue-numeric wihtout errors.
1 parent ff30b07 commit 03c6f1a

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/vue-numeric.vue

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
</template>
1919

2020
<script>
21-
import accounting from 'accounting-js'
21+
import { unformat, formatMoney, toFixed } from 'accounting-js'
2222
2323
export default {
2424
name: 'VueNumeric',
@@ -325,7 +325,7 @@ export default {
325325
if(typeof this.valueNumber === 'string' && this.valueNumber === '') {
326326
return ''
327327
} else {
328-
this.amount = accounting.formatMoney(this.valueNumber, {
328+
this.amount = formatMoney(this.valueNumber, {
329329
symbol: '',
330330
format: '%v',
331331
thousand: '',
@@ -361,7 +361,7 @@ export default {
361361
* @param {Number} value
362362
*/
363363
update (value) {
364-
const fixedValue = accounting.toFixed(value, this.precision)
364+
const fixedValue = toFixed(value, this.precision)
365365
const output = this.outputType.toLowerCase() === 'string' ? fixedValue : Number(fixedValue)
366366
this.$emit('input', output)
367367
},
@@ -373,7 +373,7 @@ export default {
373373
*/
374374
format (value) {
375375
if(typeof value === 'string' && value === '') return ''
376-
return accounting.formatMoney(value, {
376+
return formatMoney(value, {
377377
symbol: this.currency,
378378
format: this.symbolPosition,
379379
precision: Number(this.precision),
@@ -390,7 +390,7 @@ export default {
390390
unformat (value) {
391391
const toUnformat = typeof value === 'string' && value === '' ? this.emptyValue : value
392392
if(typeof toUnformat === 'string' && toUnformat === '') return ''
393-
return accounting.unformat(toUnformat, this.decimalSeparatorSymbol)
393+
return unformat(toUnformat, this.decimalSeparatorSymbol)
394394
},
395395
396396
/**

0 commit comments

Comments
 (0)