-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtsup.config.ts
More file actions
58 lines (57 loc) · 1.82 KB
/
Copy pathtsup.config.ts
File metadata and controls
58 lines (57 loc) · 1.82 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
import { defineConfig } from 'tsup';
export default defineConfig([
// Node builds (ESM + CJS + declarations)
// Includes the introspect sub-path as a separate entry so consumers can
// `import { introspect } from 'mailc/introspect'` without paying for it
// in the main bundle. Browser/IIFE builds intentionally omit introspect —
// it is a dev-time tooling API, not runtime email-compilation code.
{
entry: ['src/index.ts', 'src/cli.ts', 'src/introspect.ts'],
format: ['esm', 'cjs'],
dts: true,
splitting: true,
clean: true,
sourcemap: true,
target: 'node20',
outDir: 'dist',
treeshake: true,
},
// Browser ESM — js-beautify is kept external so bundlers (Vite, webpack,
// Rollup) resolve it from the consumer's node_modules. The static import in
// formatter.ts produces a real `import { html } from 'js-beautify'` in the
// output — no CJS shim, works correctly in browser ESM context. Consumers
// who need prettification must have js-beautify in their dependencies.
{
entry: { browser: 'src/browser.ts' },
format: ['esm'],
dts: false,
globalName: 'mailc',
splitting: false,
clean: false,
sourcemap: true,
target: 'esnext',
outDir: 'dist',
treeshake: true,
minify: true,
platform: 'browser',
external: ['js-beautify'],
},
// Browser IIFE — CDN build with js-beautify bundled inline.
// compile() always returns prettified HTML.
// Use: <script src="https://unpkg.com/mailc/dist/browser.global.js"></script>
{
entry: { browser: 'src/browser.ts' },
format: ['iife'],
dts: false,
globalName: 'mailc',
splitting: false,
clean: false,
sourcemap: true,
target: 'esnext',
outDir: 'dist',
treeshake: true,
minify: true,
platform: 'browser',
noExternal: ['js-beautify'],
},
]);