Import store modules with ES6 imports instead of dynamically (#3064)

This commit is contained in:
absidue 2023-01-15 02:03:16 +01:00 committed by GitHub
parent d8e6c3e422
commit a953142377
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 17 additions and 9 deletions

View File

@ -1,14 +1,22 @@
/**
* The file enables `@/store/index.js` to import all vuex modules
* in a one-shot manner. There should not be any reason to edit this file.
* in a one-shot manner.
*/
const files = require.context('.', false, /\.js$/)
const modules = {}
import history from './history'
import invidious from './invidious'
import playlists from './playlists'
import profiles from './profiles'
import settings from './settings'
import subscriptions from './subscriptions'
import utils from './utils'
files.keys().forEach(key => {
if (key === './index.js') return
modules[key.replaceAll(/(\.\/|\.js)/g, '')] = files(key).default
})
export default modules
export default {
history,
invidious,
playlists,
profiles,
settings,
subscriptions,
utils
}