mirror of
https://github.com/tuono-labs/tuono
synced 2026-07-25 12:52:47 -07:00
chore(eslint): remove build folder exclusion (#202)
This commit is contained in:
committed by
GitHub
parent
90da869277
commit
08b75b1a79
@@ -7,7 +7,6 @@ export default tseslint.config(
|
||||
{
|
||||
ignores: [
|
||||
// #region shared
|
||||
'**/build',
|
||||
'**/dist',
|
||||
'**/.tuono',
|
||||
'**/vite.config.ts.timestamp**',
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
import { build, createServer, InlineConfig, mergeConfig } from 'vite'
|
||||
import type { InlineConfig } from 'vite'
|
||||
import { build, createServer, mergeConfig } from 'vite'
|
||||
import react from '@vitejs/plugin-react-swc'
|
||||
import ViteFsRouter from 'tuono-fs-router-vite-plugin'
|
||||
import { LazyLoadingPlugin } from 'tuono-lazy-fn-vite-plugin'
|
||||
import mdx from '@mdx-js/rollup'
|
||||
|
||||
import { loadConfig, blockingAsync } from './utils'
|
||||
|
||||
const VITE_PORT = 3001
|
||||
@@ -18,14 +20,14 @@ const BASE_CONFIG: InlineConfig = {
|
||||
},
|
||||
plugins: [
|
||||
{ enforce: 'pre', ...mdx({ providerImportSource: '@mdx-js/react' }) },
|
||||
// @ts-ignore: TS configuration issue.
|
||||
// @ts-expect-error: TS configuration issue.
|
||||
react({ include: /\.(jsx|js|mdx|md|tsx|ts)$/ }),
|
||||
ViteFsRouter(),
|
||||
LazyLoadingPlugin(),
|
||||
],
|
||||
}
|
||||
|
||||
const developmentSSRBundle = () => {
|
||||
const developmentSSRBundle = (): void => {
|
||||
blockingAsync(async () => {
|
||||
const config = await loadConfig()
|
||||
await build(
|
||||
@@ -40,8 +42,9 @@ const developmentSSRBundle = () => {
|
||||
emptyOutDir: true,
|
||||
rollupOptions: {
|
||||
input: './.tuono/server-main.tsx',
|
||||
// Silent all logs
|
||||
onLog() {},
|
||||
onLog() {
|
||||
// Silence all logs
|
||||
},
|
||||
output: {
|
||||
entryFileNames: 'dev-server.js',
|
||||
format: 'iife',
|
||||
@@ -57,7 +60,7 @@ const developmentSSRBundle = () => {
|
||||
})
|
||||
}
|
||||
|
||||
const developmentCSRWatch = () => {
|
||||
const developmentCSRWatch = (): void => {
|
||||
blockingAsync(async () => {
|
||||
const config = await loadConfig()
|
||||
const server = await createServer(
|
||||
@@ -85,7 +88,7 @@ const developmentCSRWatch = () => {
|
||||
})
|
||||
}
|
||||
|
||||
const buildProd = () => {
|
||||
const buildProd = (): void => {
|
||||
blockingAsync(async () => {
|
||||
const config = await loadConfig()
|
||||
|
||||
@@ -132,7 +135,7 @@ const buildProd = () => {
|
||||
})
|
||||
}
|
||||
|
||||
const buildConfig = () => {
|
||||
const buildConfig = (): void => {
|
||||
blockingAsync(async () => {
|
||||
await build({
|
||||
root: '.tuono',
|
||||
|
||||
@@ -14,7 +14,7 @@ describe('loadConfig', () => {
|
||||
it('should error if the config does not exist', async () => {
|
||||
const consoleErrorSpy = vi
|
||||
.spyOn(console, 'error')
|
||||
.mockImplementation(() => {})
|
||||
.mockImplementation(() => undefined)
|
||||
await loadConfig()
|
||||
|
||||
expect(consoleErrorSpy).toHaveBeenCalledTimes(2)
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import path from 'path'
|
||||
|
||||
import { pathToFileURL } from 'url'
|
||||
|
||||
import type { AliasOptions } from 'vite'
|
||||
|
||||
import type { TuonoConfig } from '../config'
|
||||
@@ -9,7 +11,6 @@ import {
|
||||
CONFIG_FOLDER_NAME,
|
||||
CONFIG_FILE_NAME,
|
||||
} from './constants'
|
||||
import { pathToFileURL } from 'url'
|
||||
|
||||
/**
|
||||
* Normalize vite alias option:
|
||||
@@ -44,16 +45,18 @@ const normalizeViteAlias = (alias?: AliasOptions): AliasOptions | undefined => {
|
||||
if (!alias) return
|
||||
|
||||
if (Array.isArray(alias)) {
|
||||
return alias.map(({ replacement, ...userAliasDefinition }) => ({
|
||||
...userAliasDefinition,
|
||||
replacement: normalizeAliasPath(replacement),
|
||||
}))
|
||||
return (alias as Extract<AliasOptions, readonly unknown[]>).map(
|
||||
({ replacement, ...userAliasDefinition }) => ({
|
||||
...userAliasDefinition,
|
||||
replacement: normalizeAliasPath(replacement),
|
||||
}),
|
||||
)
|
||||
}
|
||||
|
||||
if (typeof alias === 'object') {
|
||||
let normalizedAlias: AliasOptions = {}
|
||||
for (let [key, value] of Object.entries(alias)) {
|
||||
normalizedAlias[key] = normalizeAliasPath(value)
|
||||
const normalizedAlias: AliasOptions = {}
|
||||
for (const [key, value] of Object.entries(alias)) {
|
||||
normalizedAlias[key] = normalizeAliasPath(value as string)
|
||||
}
|
||||
return normalizedAlias
|
||||
}
|
||||
@@ -71,14 +74,14 @@ const normalizeViteAlias = (alias?: AliasOptions): AliasOptions | undefined => {
|
||||
export const normalizeConfig = (config: TuonoConfig): TuonoConfig => {
|
||||
return {
|
||||
vite: {
|
||||
alias: normalizeViteAlias(config?.vite?.alias),
|
||||
alias: normalizeViteAlias(config.vite?.alias),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
export const loadConfig = async (): Promise<TuonoConfig> => {
|
||||
try {
|
||||
const configFile = await import(
|
||||
const configFile = (await import(
|
||||
pathToFileURL(
|
||||
path.join(
|
||||
process.cwd(),
|
||||
@@ -87,7 +90,7 @@ export const loadConfig = async (): Promise<TuonoConfig> => {
|
||||
CONFIG_FILE_NAME,
|
||||
),
|
||||
).href
|
||||
)
|
||||
)) as { default: TuonoConfig }
|
||||
|
||||
return normalizeConfig(configFile.default)
|
||||
} catch (err) {
|
||||
@@ -97,8 +100,8 @@ export const loadConfig = async (): Promise<TuonoConfig> => {
|
||||
}
|
||||
}
|
||||
|
||||
export const blockingAsync = (callback: () => Promise<void>) => {
|
||||
;(async () => {
|
||||
export const blockingAsync = (callback: () => Promise<void>): void => {
|
||||
void (async (): Promise<void> => {
|
||||
await callback()
|
||||
})()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user