Repository navigation
Expand file tree
/
Copy pathtsdown.config.ts
More file actions
60 lines (54 loc) · 2.27 KB
/
Copy pathtsdown.config.ts
File metadata and controls
60 lines (54 loc) · 2.27 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
import { readFileSync } from 'node:fs';
import { defineConfig } from 'tsdown';
import { reactCompilerPlugin } from './scripts/compiler/transform.mjs';
const pkg = JSON.parse(readFileSync('./package.json', 'utf-8'));
const tastyPkg = JSON.parse(
readFileSync('./node_modules/@tenphi/tasty/package.json', 'utf-8'),
);
const banner = {
js: `/** @license ${pkg.license} | ${pkg.name} v${pkg.version} | ${pkg.author} */`,
};
const define = {
__UIKIT_VERSION__: JSON.stringify(pkg.version),
__TASTY_VERSION__: JSON.stringify(tastyPkg.version),
// Identity mapping, on purpose. `platform: 'browser'` makes rolldown inline
// `process.env.NODE_ENV` as the literal NODE_ENV of *this* build, so every
// consumer inherited whatever the release machine happened to export -
// `isDevEnv()` shipped as `"development" !== "test" && ... !== "production"`,
// i.e. `true` in production. Defining the expression as itself wins over that
// injection and leaves the read in the output, where the consumer's own
// bundler (webpack/Vite/Next all define it) or Node resolves it for the
// environment that is actually running. Keep the canonical
// `process.env.NODE_ENV` spelling at the read sites: that is the only form
// those bundlers match.
'process.env.NODE_ENV': 'process.env.NODE_ENV',
};
export default defineConfig({
plugins:
process.env.UIKIT_REACT_COMPILER === 'off' ? [] : [reactCompilerPlugin()],
entry: {
index: 'src/index.ts',
// Second entry so `@cube-dev/ui-kit/eslint-plugin` stays version-locked to
// the components its defaults registry describes. It imports only the
// registry and its types, so linting never pulls React into the lint
// process.
'eslint-plugin/index': 'src/eslint-plugin/index.ts',
// Third entry: DOM-pure helpers for tooling that inspects rendered output
// (`@cube-dev/ui-kit/probe`). Version-locked for the same reason as above —
// the class-name pattern it normalises is tasty's, and the CSS it reads is
// this package's.
'probe/index': 'src/probe/index.ts',
},
format: 'esm',
outDir: 'dist',
unbundle: true,
dts: true,
platform: 'browser',
target: 'es2022',
sourcemap: true,
clean: true,
deps: { onlyBundle: false },
banner,
define,
copy: ['README.md', 'CHANGELOG.md'],
});