About vue error, exports is not defined

Today, after writing the code, there was a sudden problem with packaging
browser error: Uncaught ReferenceError: exports is not defined
Compiler error:

warning in. / src/main.js
"export "default" (imported as" filters") was not found in". / filters"

I modified the code for a day today. I remember that I didn"t change the operation of filters, and main.js didn"t move. I was debugging while I was running. After packing, I suddenly didn"t report an error. I checked the path, file path and word spelling several times.

the file directory is as follows:

clipboard.png

filters/index.js Code

exports.statusName = (value, type) => {
    if (type === 0 && value === 0) {
        return ""
    }
    if (type === 0 && value === 1) {
        return ""
    }
    if (type === 1 && value === 0) {
        return ""
    }
    if (type === 1 && value === 1) {
        return ""
    }
    if (type === 2 && value === 0) {
        return ""
    }
    if (type === 2 && value === 1) {
        return ""
    }
}

main.js Code

import Vue from "vue";
import App from "./App.vue";
import router from "./router";
import store from "./store";
import iView from "iview";
import filters from "./filters";
import "iview/dist/styles/iview.css";
import "@/my-theme/index.less";
import "@/assets/css/iconfont.css";
import "@/assets/css/common.less";

Vue.config.productionTip = false;
Vue.use(iView);

Object.keys(filters).forEach(k => Vue.filter(k, filters[k]));

new Vue({
    router,
    store,
    render: h => h(App)
}).$mount("-sharpapp");

the mentality of finding is broken, and I would like to ask all of you to give us some advice on why you suddenly made a mistake. Thank you very much

.
Sep.27,2021

after looking up the information on the Internet, it turns out that I don't understand the two specifications of CommonJS and ES6

.

can be done in two ways. The first way to use CommonJS:
main.js, is to modify

.
import filters from './filters';
Change

to

var filters = require('./filters/index')

second, comply with the ES6 specification
filters/index.js needs to be modified, the code is as follows

let transitionstate = (value, type) => {
    if (type === 0 && value === 0) {
        return ''
    }
    if (type === 0 && value === 1) {
        return ''
    }
    if (type === 1 && value === 0) {
        return ''
    }
    if (type === 1 && value === 1) {
        return ''
    }
    if (type === 2 && value === 0) {
        return ''
    }
    if (type === 2 && value === 1) {
        return ''
    }
}
export {
    transitionstate
}

is referenced in main.js as follows:

import * as filters from './filters/index';

change the filters/index.js code

export default (value, type) => {
    if (type === 0 && value === 0) {
        return ''
    }
    if (type === 0 && value === 1) {
        return ''
    }
    if (type === 1 && value === 0) {
        return ''
    }
    if (type === 1 && value === 1) {
        return ''
    }
    if (type === 2 && value === 0) {
        return ''
    }
    if (type === 2 && value === 1) {
        return ''
    }
}
Menu