0

I do not see any duplicated export. Do you?

// slice.ts

import {
    createAsyncThunk,
    createSelector,
    createSlice,
    current,
    PayloadAction,
} from '@reduxjs/toolkit'
import axios from 'axios'
import { DataBundlesInitial } from './Types/Tikex'
import { useAppSelector } from './useAppSelector'
import type { RootState } from './store'

interface SliceState {
    dataBundlesInitial: DataBundlesInitial | null
}

const initialState = {} as SliceState

const namespace = 'slice'

export const loginGithub = createAsyncThunk(
    `${namespace}/loginGithub`,
    async (props: any, { dispatch, getState }) => {
        const { data } = await axios({
            method: 'get',
            url: 'me',
            headers: { crossDomain: true },
        })
        return data
    }
)

const slice = createSlice({
    name: 'slice',
    initialState,
    reducers: {
        loginGithub(state, action: PayloadAction<DataBundlesInitial | null>) {
            state.dataBundlesInitial = action.payload
        },
    },
    extraReducers: (builder) => {
        builder.addCase(loginGithub.fulfilled, (state, { payload }) => {
            state.dataBundlesInitial = payload
        })
    },
})

export const {} = slice.actions
export default slice.reducer

export const selectSlice = createSelector(
    [(state: RootState) => state.slice],
    (slice) => slice
)
export const selectDataBundleInitial = createSelector(
    [selectSlice],
    (slice) => slice?.dataBundlesInitial
)

export const useDataBundleInitial = () =>
    useAppSelector(selectDataBundleInitial)

I tried to remove the one reducer from reducers. Did not help.

full error:

Failed to compile.

./src/utils/slice.ts
Module parse failed: Duplicate export '_actions' (78:37)
File was processed with these loaders:
 * ./node_modules/next/dist/build/webpack/loaders/next-swc-loader.js
You may need an additional loader to handle the result of these loaders.
|     }
| });
> export var _actions = slice.actions, _actions = _actions !== null ? _actions : _throw(new TypeError("Cannot destructure undefined"));
| export default slice.reducer;
| export var selectSlice = createSelector([

Import trace for requested module:
./src/utils/store.ts
./src/pages/_app.tsx


> Build failed because of webpack errors
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
János
  • 32,867
  • 38
  • 193
  • 353

1 Answers1

0

"empty" slive.action export is not allowed, I removed this line:

export const {} = slice.actions
János
  • 32,867
  • 38
  • 193
  • 353