Skip to content

Commit

Permalink
refactor!: rename VPPTPluginOptions to VitePublicTypescriptOptions
Browse files Browse the repository at this point in the history
  • Loading branch information
hemengke1997 committed May 30, 2024
1 parent 14aba64 commit a975868
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
"test:serve": "vitest run -c vitest.config.e2e.ts",
"test:build": "cross-env VITE_TEST_BUILD=1 vitest run -c vitest.config.e2e.ts",
"commitlint": "commitlint -e",
"lint": "eslint . --fix",
"lint": "eslint --fix",
"up": "taze -I -w",
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s -r 0",
"bump": "bumpp package.json -c --no-push -t --all -x \"pnpm run changelog\""
Expand Down
4 changes: 2 additions & 2 deletions src/node/helper/default-options.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import path from 'node:path'
import { type ResolvedConfig, normalizePath } from 'vite'
import { type VPPTPluginOptions } from '../interface'
import { type VitePublicTypescriptOptions } from '../interface'
import { type OptionsTypeWithDefault } from './utils'

function resolve(root?: string, ...args: string[]) {
Expand All @@ -9,7 +9,7 @@ function resolve(root?: string, ...args: string[]) {

export function resolveOptions(
resolvedViteConfig?: ResolvedConfig,
options?: VPPTPluginOptions,
options?: VitePublicTypescriptOptions,
): OptionsTypeWithDefault {
const publicDir = resolve(resolvedViteConfig?.root, resolvedViteConfig?.publicDir || 'public')

Expand Down
10 changes: 5 additions & 5 deletions src/node/helper/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { isCI, isWindows } from 'std-env'
import { type ResolvedConfig, createLogger, normalizePath } from 'vite'
import { name as pkgName } from '../../../package.json'
import { globalConfig } from '../global-config'
import { type VPPTPluginOptions } from '../interface'
import { type VitePublicTypescriptOptions } from '../interface'
import { manifestCache, saveManifestPathToDisk } from '../manifest-cache'
import { initCacheProcessor } from '../processor/processor'
import { disableManifestHmr } from './server'
Expand All @@ -16,7 +16,7 @@ const debug = createDebug('vite-plugin-public-typescript:util ===> ')

// type PartialBy<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>

export type OptionsTypeWithDefault = Required<VPPTPluginOptions>
export type OptionsTypeWithDefault = Required<VitePublicTypescriptOptions>

export { pkgName }

Expand Down Expand Up @@ -89,11 +89,11 @@ const HASH_LEN = 8

export const linebreak = isWindows ? '\r\n' : '\n'

export function getHashLen(hash: VPPTPluginOptions['hash']) {
export function getHashLen(hash: VitePublicTypescriptOptions['hash']) {
return typeof hash === 'number' ? hash : HASH_LEN
}

export function extractHashFromFileName(filename: string, hash: VPPTPluginOptions['hash']) {
export function extractHashFromFileName(filename: string, hash: VitePublicTypescriptOptions['hash']) {
const hashLen = getHashLen(hash)
const regex = new RegExp(`\\.([\\w\\d]{${hashLen}})\\.?`)
const match = filename.match(regex)
Expand All @@ -103,7 +103,7 @@ export function extractHashFromFileName(filename: string, hash: VPPTPluginOption
return ''
}

export function getContentHash(chunk: string | Uint8Array | undefined, hash?: VPPTPluginOptions['hash']) {
export function getContentHash(chunk: string | Uint8Array | undefined, hash?: VitePublicTypescriptOptions['hash']) {
if (!chunk) {
return ''
}
Expand Down
4 changes: 2 additions & 2 deletions src/node/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ import {
setupGlobalConfig,
setupManifestCache,
} from './helper/utils'
import { type VPPTPluginOptions } from './interface'
import { type VitePublicTypescriptOptions } from './interface'
import { getManifest, manifestCache } from './manifest-cache'
import { pluginServer } from './plugins/server'
import { pluginVirtual } from './plugins/virtual'

const debug = createDebug('vite-plugin-public-typescript:index ===> ')

export default function publicTypescript(options: VPPTPluginOptions = {}) {
export default function publicTypescript(options: VitePublicTypescriptOptions = {}) {
debug('user options:', options)

let viteConfig: ResolvedConfig
Expand Down
2 changes: 1 addition & 1 deletion src/node/interface.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { type BuildOptions } from 'esbuild'
import { type ESBuildPluginBabelOptions } from './build/babel'

export interface VPPTPluginOptions {
export interface VitePublicTypescriptOptions {
/**
* @description dir of input typescript files
* @default 'public-typescript'
Expand Down
2 changes: 1 addition & 1 deletion src/node/processor/FileCacheProcessor.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import path from 'node:path'
import createDebug from 'debug'
import fs from 'fs-extra'
import path from 'node:path'
import colors from 'picocolors'
import { normalizePath } from 'vite'
import { globalConfig } from '../global-config'
Expand Down
2 changes: 1 addition & 1 deletion src/node/processor/ManifestCacheProcessor.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import path from 'node:path'
import createDebug from 'debug'
import path from 'node:path'
import { normalizePath } from 'vite'
import { type GlobalConfig } from '../global-config/GlobalConfigBuilder'
import { type CacheValueEx } from '../manifest-cache'
Expand Down

0 comments on commit a975868

Please sign in to comment.