Skip to content

Commit

Permalink
minor refactorings and file renaming
Browse files Browse the repository at this point in the history
  • Loading branch information
marcuspoehls committed May 4, 2024
1 parent 8ae71de commit a57b4e4
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 11 deletions.
2 changes: 1 addition & 1 deletion packages/vite/src/backend/vite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Arr } from '@supercharge/arrays'
import { ViteConfig } from './vite-config.js'
import { ViteManifest } from './vite-manifest.js'
import { HtmlString } from '@supercharge/support'
import { HotReloadFileContent } from '../plugin/types.js'
import { HotReloadFileContent } from '../plugin/vite-plugin-types.js'

export type ViteTagAttributes = Record<string, any>

Expand Down
6 changes: 3 additions & 3 deletions packages/vite/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

import { supercharge } from './plugin/plugin.js'
import { supercharge } from './plugin/vite-plugin.js'

export default supercharge
export { supercharge }
Expand All @@ -11,5 +11,5 @@ export { ViteServiceProvider } from './vite-service-provider.js'
export { resolvePageComponent } from './inertia/inertia-helpers.js'
export { InertiaPageNotFoundError } from './inertia/inertia-page-not-found-error.js'

export { HotReloadFile } from './plugin/hotfile.js'
export { PluginConfigContract, DevServerUrl } from './plugin/types.js'
export { HotReloadFile } from './plugin/vite-hotfile.js'
export { PluginConfigContract, DevServerUrl } from './plugin/vite-plugin-types.js'
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

import Fs from 'node:fs'
import Path from 'node:path'
import { HotReloadFileContent } from './types.js'
import { HotReloadFileContent } from './vite-plugin-types.js'

export class HotReloadFile {
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,16 @@ export type DevServerUrl = `${'http' | 'https'}://${string}:${number}`
export interface PluginConfigContract {
/**
* The path or paths to the entrypoints to compile with Vite.
*
* @deprecated use the {@link entrypoints} property
*/
input: string | string[]

/**
* The path or paths to the entrypoints to compile with Vite.
*/
entrypoints: string | string[]

/**
* The "public" directory name.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
import Path from 'node:path'
import { AddressInfo } from 'node:net'
import { Str } from '@supercharge/strings'
import { HotReloadFile } from './hotfile.js'
import { DevServerUrl, PluginConfigContract } from './types.js'
import { HotReloadFile } from './vite-hotfile.js'
import { DevServerUrl, PluginConfigContract } from './vite-plugin-types.js'
import { ConfigEnv, Plugin, ResolvedConfig, UserConfig, ViteDevServer } from 'vite'

/**
Expand All @@ -20,19 +20,23 @@ export function supercharge (config: string | string[] | PluginConfigContract):
*/
function resolvePluginConfig (config: string | string[] | PluginConfigContract): Required<PluginConfigContract> {
if (!config) {
throw new Error('supercharge-vite-plugin: missing inputs or configuration')
throw new Error('supercharge-vite-plugin: missing configuration object')
}

if (typeof config === 'string') {
config = [config]
}

if (Array.isArray(config)) {
config = { input: config }
config = { entrypoints: config }
}

if (!config.input) {
throw new Error('supercharge-vite-plugin: missing "input" configuration')
if (!config.entrypoints && config.input) {
config.entrypoints = config.input
}

if (!config.entrypoints) {
throw new Error('supercharge-vite-plugin: missing "entrypoints" configuration')
}

if (typeof config.publicDirectory === 'string') {
Expand Down

0 comments on commit a57b4e4

Please sign in to comment.