mirror of
https://github.com/ourongxing/newsnow.git
synced 2025-01-18 18:59:15 +08:00
chore: switch to unimport
This commit is contained in:
parent
55709e1420
commit
743778e757
1
.gitignore
vendored
1
.gitignore
vendored
@ -11,3 +11,4 @@ dist/
|
||||
dev-dist
|
||||
*.tsbuildinfo
|
||||
wrangler.toml
|
||||
imports.app.d.ts
|
95
auto-imports.app.d.ts
vendored
95
auto-imports.app.d.ts
vendored
@ -1,95 +0,0 @@
|
||||
/* eslint-disable */
|
||||
/* prettier-ignore */
|
||||
// @ts-nocheck
|
||||
// noinspection JSUnusedGlobalSymbols
|
||||
// Generated by unplugin-auto-import
|
||||
// biome-ignore lint: disable
|
||||
export {}
|
||||
declare global {
|
||||
const $: typeof import('clsx')['default']
|
||||
const Author: typeof import('./shared/consts')['Author']
|
||||
const Homepage: typeof import('./shared/consts')['Homepage']
|
||||
const Interval: typeof import('./shared/consts')['Interval']
|
||||
const TTL: typeof import('./shared/consts')['TTL']
|
||||
const Timer: typeof import('./src/utils/index')['Timer']
|
||||
const Version: typeof import('./shared/consts')['Version']
|
||||
const atom: typeof import('jotai')['atom']
|
||||
const atomFamily: typeof import('jotai/utils')['atomFamily']
|
||||
const atomWithDefault: typeof import('jotai/utils')['atomWithDefault']
|
||||
const atomWithHash: typeof import('jotai/utils')['atomWithHash']
|
||||
const atomWithObservable: typeof import('jotai/utils')['atomWithObservable']
|
||||
const atomWithReducer: typeof import('jotai/utils')['atomWithReducer']
|
||||
const atomWithReset: typeof import('jotai/utils')['atomWithReset']
|
||||
const atomWithStorage: typeof import('jotai/utils')['atomWithStorage']
|
||||
const columns: typeof import('./shared/metadata')['columns']
|
||||
const createJSONStorage: typeof import('jotai/utils')['createJSONStorage']
|
||||
const createRef: typeof import('react')['createRef']
|
||||
const currentColumnIDAtom: typeof import('./src/atoms/index')['currentColumnIDAtom']
|
||||
const currentSourcesAtom: typeof import('./src/atoms/index')['currentSourcesAtom']
|
||||
const delay: typeof import('./shared/utils')['delay']
|
||||
const downloadMetadata: typeof import('./src/hooks/useSync')['downloadMetadata']
|
||||
const fixedColumnIds: typeof import('./shared/metadata')['fixedColumnIds']
|
||||
const focusSourcesAtom: typeof import('./src/atoms/index')['focusSourcesAtom']
|
||||
const forwardRef: typeof import('react')['forwardRef']
|
||||
const freezeAtom: typeof import('jotai/utils')['freezeAtom']
|
||||
const freezeAtomCreator: typeof import('jotai/utils')['freezeAtomCreator']
|
||||
const goToTopAtom: typeof import('./src/atoms/index')['goToTopAtom']
|
||||
const hiddenColumns: typeof import('./shared/metadata')['hiddenColumns']
|
||||
const lazy: typeof import('react')['lazy']
|
||||
const loadable: typeof import('jotai/utils')['loadable']
|
||||
const memo: typeof import('react')['memo']
|
||||
const metadata: typeof import('./shared/metadata')['metadata']
|
||||
const myFetch: typeof import('./src/utils/index')['myFetch']
|
||||
const originSources: typeof import('./shared/sources')['originSources']
|
||||
const preprocessMetadata: typeof import('./src/atoms/primitiveMetadataAtom')['preprocessMetadata']
|
||||
const primitiveMetadataAtom: typeof import('./src/atoms/primitiveMetadataAtom')['primitiveMetadataAtom']
|
||||
const projectDir: typeof import('./shared/dir')['projectDir']
|
||||
const randomItem: typeof import('./shared/utils')['randomItem']
|
||||
const randomUUID: typeof import('./shared/utils')['randomUUID']
|
||||
const refetchSourcesAtom: typeof import('./src/atoms/index')['refetchSourcesAtom']
|
||||
const relativeTime: typeof import('./shared/utils')['relativeTime']
|
||||
const safeParseString: typeof import('./src/utils/index')['safeParseString']
|
||||
const selectAtom: typeof import('jotai/utils')['selectAtom']
|
||||
const sources: typeof import('./shared/sources')['sources']
|
||||
const splitAtom: typeof import('jotai/utils')['splitAtom']
|
||||
const startTransition: typeof import('react')['startTransition']
|
||||
const toastAtom: typeof import('./src/hooks/useToast')['toastAtom']
|
||||
const typeSafeObjectEntries: typeof import('./shared/type.util')['typeSafeObjectEntries']
|
||||
const typeSafeObjectFromEntries: typeof import('./shared/type.util')['typeSafeObjectFromEntries']
|
||||
const typeSafeObjectValues: typeof import('./shared/type.util')['typeSafeObjectValues']
|
||||
const uploadMetadata: typeof import('./src/hooks/useSync')['uploadMetadata']
|
||||
const useAtom: typeof import('jotai')['useAtom']
|
||||
const useAtomCallback: typeof import('jotai/utils')['useAtomCallback']
|
||||
const useAtomValue: typeof import('jotai')['useAtomValue']
|
||||
const useCallback: typeof import('react')['useCallback']
|
||||
const useContext: typeof import('react')['useContext']
|
||||
const useDark: typeof import('./src/hooks/useDark')['useDark']
|
||||
const useDebugValue: typeof import('react')['useDebugValue']
|
||||
const useDeferredValue: typeof import('react')['useDeferredValue']
|
||||
const useEffect: typeof import('react')['useEffect']
|
||||
const useFocus: typeof import('./src/hooks/useFocus')['useFocus']
|
||||
const useFocusWith: typeof import('./src/hooks/useFocus')['useFocusWith']
|
||||
const useHydrateAtoms: typeof import('jotai/utils')['useHydrateAtoms']
|
||||
const useId: typeof import('react')['useId']
|
||||
const useImperativeHandle: typeof import('react')['useImperativeHandle']
|
||||
const useInsertionEffect: typeof import('react')['useInsertionEffect']
|
||||
const useLayoutEffect: typeof import('react')['useLayoutEffect']
|
||||
const useLogin: typeof import('./src/hooks/useLogin')['useLogin']
|
||||
const useMemo: typeof import('react')['useMemo']
|
||||
const useOnReload: typeof import('./src/hooks/useOnReload')['useOnReload']
|
||||
const usePWA: typeof import('./src/hooks/usePWA')['usePWA']
|
||||
const useReducer: typeof import('react')['useReducer']
|
||||
const useReducerAtom: typeof import('jotai/utils')['useReducerAtom']
|
||||
const useRef: typeof import('react')['useRef']
|
||||
const useRelativeTime: typeof import('./src/hooks/useRelativeTime')['useRelativeTime']
|
||||
const useResetAtom: typeof import('jotai/utils')['useResetAtom']
|
||||
const useSearchBar: typeof import('./src/hooks/useSearch')['useSearchBar']
|
||||
const useSetAtom: typeof import('jotai')['useSetAtom']
|
||||
const useState: typeof import('react')['useState']
|
||||
const useSync: typeof import('./src/hooks/useSync')['useSync']
|
||||
const useSyncExternalStore: typeof import('react')['useSyncExternalStore']
|
||||
const useToast: typeof import('./src/hooks/useToast')['useToast']
|
||||
const useTransition: typeof import('react')['useTransition']
|
||||
const verifyPrimitiveMetadata: typeof import('./shared/verify')['verifyPrimitiveMetadata']
|
||||
const waitForAll: typeof import('jotai/utils')['waitForAll']
|
||||
}
|
@ -2,7 +2,8 @@ import { ourongxing, react } from "@ourongxing/eslint-config"
|
||||
|
||||
export default ourongxing({
|
||||
type: "app",
|
||||
ignores: ["**/routeTree.gen.ts"],
|
||||
// 貌似不能 ./ 开头,
|
||||
ignores: ["src/routeTree.gen.ts", "imports.app.d.ts"],
|
||||
}).append(react({
|
||||
files: ["src/**"],
|
||||
}))
|
||||
|
@ -88,8 +88,8 @@
|
||||
"tsx": "^4.19.1",
|
||||
"typescript": "^5.6.3",
|
||||
"typescript-eslint": "^8.8.1",
|
||||
"unimport": "^3.13.1",
|
||||
"unocss": "^0.63.4",
|
||||
"unplugin-auto-import": "^0.18.3",
|
||||
"vite": "^5.4.8",
|
||||
"vite-plugin-pwa": "^0.20.5",
|
||||
"vite-plugin-with-nitro": "0.0.3",
|
||||
|
32
pnpm-lock.yaml
generated
32
pnpm-lock.yaml
generated
@ -201,12 +201,12 @@ importers:
|
||||
typescript-eslint:
|
||||
specifier: ^8.8.1
|
||||
version: 8.11.0(eslint@9.13.0(jiti@2.3.3))(typescript@5.6.3)
|
||||
unimport:
|
||||
specifier: ^3.13.1
|
||||
version: 3.13.1(rollup@4.24.0)
|
||||
unocss:
|
||||
specifier: ^0.63.4
|
||||
version: 0.63.6(postcss@8.4.47)(rollup@4.24.0)(typescript@5.6.3)(vite@5.4.10(@types/node@22.7.9)(terser@5.36.0))
|
||||
unplugin-auto-import:
|
||||
specifier: ^0.18.3
|
||||
version: 0.18.3(rollup@4.24.0)
|
||||
vite:
|
||||
specifier: ^5.4.8
|
||||
version: 5.4.10(@types/node@22.7.9)(terser@5.36.0)
|
||||
@ -5811,18 +5811,6 @@ packages:
|
||||
vite:
|
||||
optional: true
|
||||
|
||||
unplugin-auto-import@0.18.3:
|
||||
resolution: {integrity: sha512-q3FUtGQjYA2e+kb1WumyiQMjHM27MrTQ05QfVwtLRVhyYe+KF6TblBYaEX9L6Z0EibsqaXAiW+RFfkcQpfaXzg==}
|
||||
engines: {node: '>=14'}
|
||||
peerDependencies:
|
||||
'@nuxt/kit': ^3.2.2
|
||||
'@vueuse/core': '*'
|
||||
peerDependenciesMeta:
|
||||
'@nuxt/kit':
|
||||
optional: true
|
||||
'@vueuse/core':
|
||||
optional: true
|
||||
|
||||
unplugin@1.14.1:
|
||||
resolution: {integrity: sha512-lBlHbfSFPToDYp9pjXlUEFVxYLaue9f9T1HC+4OHlmj+HnMDdz9oZY+erXfoCe/5V/7gKUSY2jpXPb9S7f0f/w==}
|
||||
engines: {node: '>=14.0.0'}
|
||||
@ -12354,20 +12342,6 @@ snapshots:
|
||||
- supports-color
|
||||
- typescript
|
||||
|
||||
unplugin-auto-import@0.18.3(rollup@4.24.0):
|
||||
dependencies:
|
||||
'@antfu/utils': 0.7.10
|
||||
'@rollup/pluginutils': 5.1.3(rollup@4.24.0)
|
||||
fast-glob: 3.3.2
|
||||
local-pkg: 0.5.0
|
||||
magic-string: 0.30.12
|
||||
minimatch: 9.0.5
|
||||
unimport: 3.13.1(rollup@4.24.0)
|
||||
unplugin: 1.14.1
|
||||
transitivePeerDependencies:
|
||||
- rollup
|
||||
- webpack-sources
|
||||
|
||||
unplugin@1.14.1:
|
||||
dependencies:
|
||||
acorn: 8.13.0
|
||||
|
@ -3,6 +3,7 @@ import { useQuery } from "@tanstack/react-query"
|
||||
import { AnimatePresence, motion, useInView } from "framer-motion"
|
||||
import type { SyntheticListenerMap } from "@dnd-kit/core/dist/hooks/utilities"
|
||||
import { useWindowSize } from "react-use"
|
||||
import { forwardRef, useImperativeHandle } from "react"
|
||||
import { OverlayScrollbar } from "../common/overlay-scrollbar"
|
||||
import { refetchSourcesAtom } from "~/atoms"
|
||||
import { safeParseString } from "~/utils"
|
||||
|
@ -80,7 +80,7 @@ export function Menu() {
|
||||
href="https://github.com/ourongxing/newsnow"
|
||||
>
|
||||
<img
|
||||
alt="GitHub forks badge"
|
||||
alt="GitHub stars badge"
|
||||
src="https://img.shields.io/github/stars/ourongxing/newsnow?logo=github"
|
||||
/>
|
||||
</a>
|
||||
|
@ -1,5 +1,4 @@
|
||||
import type { MaybePromise } from "@shared/type.util"
|
||||
|
||||
import { $fetch } from "ofetch"
|
||||
|
||||
export function safeParseString(str: any) {
|
||||
|
@ -9,5 +9,5 @@
|
||||
"@shared/*": ["shared/*"]
|
||||
}
|
||||
},
|
||||
"include": ["src", "shared", "./auto-imports.app.d.ts"]
|
||||
"include": ["src", "shared", "imports.app.d.ts"]
|
||||
}
|
||||
|
@ -5,7 +5,7 @@ import react from "@vitejs/plugin-react-swc"
|
||||
import { TanStackRouterVite } from "@tanstack/router-plugin/vite"
|
||||
import unocss from "unocss/vite"
|
||||
import dotenv from "dotenv"
|
||||
import autoImport from "unplugin-auto-import/vite"
|
||||
import unimport from "unimport/unplugin"
|
||||
import nitro from "./nitro.config"
|
||||
import { projectDir } from "./shared/dir"
|
||||
import pwa from "./pwa.config"
|
||||
@ -30,17 +30,20 @@ export default defineConfig({
|
||||
},
|
||||
plugins: [
|
||||
TanStackRouterVite({
|
||||
// error with unplugin-auto-import and vite-plugin-pwa
|
||||
// error with auto import and vite-plugin-pwa
|
||||
// autoCodeSplitting: true,
|
||||
}),
|
||||
autoImport({
|
||||
unimport.vite({
|
||||
dirs: ["src/hooks", "shared", "src/utils", "src/atoms"],
|
||||
imports: ["react", "jotai", "jotai/utils", {
|
||||
clsx: [
|
||||
["default", "$"],
|
||||
],
|
||||
presets: ["react", {
|
||||
from: "jotai",
|
||||
imports: ["atom", "useAtom", "useAtomValue", "useSetAtom"],
|
||||
}],
|
||||
dts: "auto-imports.app.d.ts",
|
||||
imports: [
|
||||
{ from: "clsx", name: "default", as: "$" },
|
||||
{ from: "jotai/utils", name: "atomWithStorage" },
|
||||
],
|
||||
dts: "imports.app.d.ts",
|
||||
}),
|
||||
unocss(),
|
||||
react(),
|
||||
|
@ -1,13 +1,8 @@
|
||||
import { join } from "node:path"
|
||||
import { defineConfig } from "vitest/config"
|
||||
import autoImport from "unplugin-auto-import/vite"
|
||||
import { resolveModuleExportNames } from "mlly"
|
||||
import unimport from "unimport/unplugin"
|
||||
import { projectDir } from "./shared/dir"
|
||||
|
||||
const h3Exports = await resolveModuleExportNames("h3", {
|
||||
url: import.meta.url,
|
||||
})
|
||||
|
||||
export default defineConfig({
|
||||
test: {
|
||||
globals: true,
|
||||
@ -22,13 +17,16 @@ export default defineConfig({
|
||||
},
|
||||
plugins: [
|
||||
// https://github.com/unjs/nitro/blob/v2/src/core/config/resolvers/imports.ts
|
||||
autoImport({
|
||||
imports: [{
|
||||
from: "h3",
|
||||
imports: h3Exports.filter(n => !/^[A-Z]/.test(n) && n !== "use"),
|
||||
}],
|
||||
unimport.vite({
|
||||
imports: [],
|
||||
presets: [
|
||||
{
|
||||
package: "h3",
|
||||
ignore: [/^[A-Z]/, r => r === "use"],
|
||||
},
|
||||
],
|
||||
dirs: ["server/utils", "shared"],
|
||||
dts: false,
|
||||
// dts: false,
|
||||
}),
|
||||
],
|
||||
})
|
||||
|
Loading…
x
Reference in New Issue
Block a user