-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathvite.config.ts
More file actions
84 lines (79 loc) · 3.17 KB
/
Copy pathvite.config.ts
File metadata and controls
84 lines (79 loc) · 3.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
/**
* ObjectUI
* Copyright (c) 2024-present ObjectStack Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import dts from 'vite-plugin-dts';
import { resolve } from 'path';
import { createDtsExplicitExtensions } from '../../scripts/vite-dts-explicit-extensions.ts';
import { createDtsFailOnTypeErrors } from '../../scripts/vite-dts-fail-on-type-errors.ts';
// objectui#3240 — with the per-package `vitest.config.*` files gone, Vitest
// launched from THIS directory falls back to this file and uses it as its test
// config. Guard that entry point (route 4 in
// scripts/vitest-invocation-guard.mjs, which carries the mechanism and the
// measurement). Gated on `VITEST` because the same file is the BUILD config:
// Vitest sets that variable when it loads a config, `vite build` does not, so
// a test run is refused and a build never is.
import {
assertCanonicalVitestInvocation,
repoRootFrom,
} from '../../scripts/vitest-invocation-guard.mjs';
if (process.env.VITEST) {
assertCanonicalVitestInvocation({ repoRoot: repoRootFrom(import.meta.url) });
}
export default defineConfig({
plugins: [
react(),
dts({
insertTypesEntry: true,
// Clear the inherited tsconfig `paths` so the dts type program resolves
// `@object-ui/*` to each dependency's published `dist/*.d.ts` (external)
// instead of following the workspace `src` aliases into files outside
// this package's `rootDir` — which would emit TS6059 rootDir errors.
compilerOptions: { rootDir: resolve(__dirname, 'src'), paths: {} },
aliasesExclude: [/^@object-ui\//],
include: ['src'],
exclude: ['**/*.test.ts', '**/*.test.tsx', 'node_modules'],
// Relative specifiers in the EMITTED typings get their explicit extension
// here — objectui#5365 / #5439. A NAMED re-export through an extensionless
// hop still declares the name under `nodenext` and silently types it `any`.
...createDtsExplicitExtensions({ packageDir: __dirname }),
// A type error the declaration program already found and printed used to
// leave `vite build` exiting 0 — objectui#5370 / #5483. This makes it fatal.
...createDtsFailOnTypeErrors({ packageDir: __dirname }),
}),
],
resolve: {
alias: {
'@': resolve(__dirname, './src'),
'@object-ui/core': resolve(__dirname, '../core/src/index.ts'),
},
},
build: {
lib: {
entry: resolve(__dirname, 'src/index.tsx'),
name: 'ObjectUIPluginMap',
fileName: 'index',
},
rollupOptions: {
external: (id) => !/^[./]/.test(id) && !id.startsWith(__dirname),
output: {
inlineDynamicImports: true,
globals: {
react: 'React',
'react-dom': 'ReactDOM',
'@object-ui/components': 'ObjectUIComponents',
'@object-ui/core': 'ObjectUICore',
'@object-ui/react': 'ObjectUIReact',
'@object-ui/types': 'ObjectUITypes',
'@object-ui/types/zod': 'ObjectUITypesZod',
'lucide-react': 'LucideReact',
},
},
},
},
});