manual-chunked

This commit is contained in:
Untone 2024-09-03 18:37:57 +03:00
parent 6bfaa3fb51
commit 7fa17cee3c
5 changed files with 30 additions and 17 deletions

View File

@ -34,11 +34,6 @@ export default defineConfig({
https: true https: true
}, },
devOverlay: true, devOverlay: true,
build: {
chunkSizeWarningLimit: 1024,
target: 'esnext',
sourcemap: true
},
vite: { vite: {
envPrefix: 'PUBLIC_', envPrefix: 'PUBLIC_',
plugins: [!isVercel && mkcert(), nodePolyfills(polyfillOptions), sassDts()], plugins: [!isVercel && mkcert(), nodePolyfills(polyfillOptions), sassDts()],
@ -49,6 +44,23 @@ export default defineConfig({
includePaths: ['./public', './src/styles'] includePaths: ['./public', './src/styles']
} }
} as CSSOptions['preprocessorOptions'] } as CSSOptions['preprocessorOptions']
},
build: {
chunkSizeWarningLimit: 800,
target: 'esnext',
sourcemap: true,
rollupOptions: {
// plugins: [visualizer()]
output: {
manualChunks: {
'icons': ['./src/components/_shared/Icon/Icon.tsx'],
'session': ['./src/context/session.tsx'],
'editor': ['./src/context/editor.tsx'],
'localize': ['./src/context/localize.tsx'],
'connect': ['./src/context/connect.tsx']
}
}
}
} }
} }
} as SolidStartInlineConfig) } as SolidStartInlineConfig)

View File

@ -182,19 +182,25 @@ export const AuthorView = (props: AuthorViewProps) => {
}) })
const result = await authorCommentsFetcher() const result = await authorCommentsFetcher()
result && addReactions(result) result && addReactions(result)
result && setCommented((prev) => [...new Set([...(prev || []), ...result])])
restoreScrollPosition() restoreScrollPosition()
return result as LoadMoreItems return result as LoadMoreItems
} }
createEffect(() => setCurrentTab(params.tab)) createEffect(() => setCurrentTab(params.tab))
createEffect( createEffect(
on( on(
[author, commented], [author, commentsByAuthor],
([a, ccc]) => a && setLoadMoreCommentsHidden(ccc?.length === a.stat?.comments), ([a, ccc]) => {
if (a && ccc && ccc[a.id]) {
setCommented(ccc[a.id])
setLoadMoreCommentsHidden(ccc[a.id]?.length === a.stat?.comments)
}
},
{} {}
) )
) )
createEffect( createEffect(
on( on(
[author, feedByAuthor], [author, feedByAuthor],

View File

@ -49,10 +49,7 @@ export const LoadMoreWrapper = (props: LoadMoreProps) => {
restoreScrollPosition() restoreScrollPosition()
} }
onMount(() => { onMount(loadItems)
loadItems()
console.debug(`load on mount ${items()}`)
})
return ( return (
<> <>

View File

@ -4,8 +4,6 @@ import ICU from 'i18next-icu'
import TimeAgo from 'javascript-time-ago' import TimeAgo from 'javascript-time-ago'
import enTime from 'javascript-time-ago/locale/en' import enTime from 'javascript-time-ago/locale/en'
import ruTime from 'javascript-time-ago/locale/ru' import ruTime from 'javascript-time-ago/locale/ru'
import en from '~/intl/locales/en/translation.json'
import ru from '~/intl/locales/ru/translation.json'
TimeAgo.addLocale(enTime) TimeAgo.addLocale(enTime)
TimeAgo.addLocale(ruTime) TimeAgo.addLocale(ruTime)
@ -13,7 +11,8 @@ TimeAgo.addLocale(ruTime)
export const i18nextInit = async (lng = 'ru') => { export const i18nextInit = async (lng = 'ru') => {
if (!i18next.isInitialized) { if (!i18next.isInitialized) {
console.debug('[i18next] initializing...') console.debug('[i18next] initializing...')
const en = await import('~/intl/locales/en/translation.json')
const ru = await import('~/intl/locales/ru/translation.json')
await i18next await i18next
.use(HttpApi) .use(HttpApi)
.use(ICU) .use(ICU)

View File

@ -1,7 +1,6 @@
import { RouteSectionProps, createAsync, useSearchParams } from '@solidjs/router' import { RouteSectionProps, createAsync, useSearchParams } from '@solidjs/router'
import { Client } from '@urql/core' import { Client } from '@urql/core'
import { createEffect, createMemo } from 'solid-js' import { createEffect, createMemo } from 'solid-js'
import { AUTHORS_PER_PAGE } from '~/components/Views/AllAuthors/AllAuthors'
import { Feed } from '~/components/Views/Feed' import { Feed } from '~/components/Views/Feed'
import { FeedProps } from '~/components/Views/Feed/Feed' import { FeedProps } from '~/components/Views/Feed/Feed'
import { LoadMoreItems, LoadMoreWrapper } from '~/components/_shared/LoadMoreWrapper' import { LoadMoreItems, LoadMoreWrapper } from '~/components/_shared/LoadMoreWrapper'
@ -125,7 +124,7 @@ export default (props: RouteSectionProps<{ shouts: Shout[]; topics: Topic[] }>)
key="feed" key="feed"
desc="Independent media project about culture, science, art and society with horizontal editing" desc="Independent media project about culture, science, art and society with horizontal editing"
> >
<LoadMoreWrapper loadFunction={loadMoreFeed} pageSize={AUTHORS_PER_PAGE}> <LoadMoreWrapper loadFunction={loadMoreFeed} pageSize={SHOUTS_PER_PAGE}>
<ReactionsProvider> <ReactionsProvider>
<Feed shouts={feed() || (shouts() as Shout[])} order={order() as FeedProps['order']} /> <Feed shouts={feed() || (shouts() as Shout[])} order={order() as FeedProps['order']} />
</ReactionsProvider> </ReactionsProvider>