-
Notifications
You must be signed in to change notification settings - Fork 39
Expand file tree
/
Copy pathtsdown.config.mts
More file actions
62 lines (60 loc) · 1.85 KB
/
Copy pathtsdown.config.mts
File metadata and controls
62 lines (60 loc) · 1.85 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
import { defineConfig } from 'tsdown';
import {
createRemoveRuntimeArtifactsHook,
createTsdownUnbundleConfig,
createUseClientBoundaryPlugin,
} from '../../tsdown.preset.mts';
const neverBundle = [
/^server-only$/,
/^gt-next\/internal\/_get(Locale|Region)$/,
];
export default defineConfig([
{
...createTsdownUnbundleConfig({
format: 'cjs',
cjsDefault: false,
deps: {
neverBundle,
},
outExtensions: () => ({ js: '.js', dts: '.d.ts' }),
plugins: [
createUseClientBoundaryPlugin({
name: 'gt-next:use-client-boundaries',
outputExtension: '.js',
}),
],
}),
// src/index.types.ts only backs the exports map's "types" condition; its
// declarations ship, but its runtime modules are unreachable.
onSuccess: createRemoveRuntimeArtifactsHook(process.cwd(), 'dist', [
'index.types.js',
'index.types.js.map',
]),
},
{
...createTsdownUnbundleConfig({
format: 'esm',
clean: false,
deps: {
neverBundle,
},
outExtensions: () => ({ js: '.mjs', dts: '.d.ts' }),
// Server-only modules use require() for lazy loading. Don't emit rolldown's
// `createRequire`-from-`node:module` shim: it's statically reachable from
// client init code and breaks client bundlers (Turbopack "node:module"
// external; webpack UnhandledSchemeError). Next provides `require` for the
// guarded, server-only call sites in every bundling context that runs them.
outputOptions: { polyfillRequire: false },
plugins: [
createUseClientBoundaryPlugin({
name: 'gt-next:use-client-boundaries',
outputExtension: '.mjs',
}),
],
}),
onSuccess: createRemoveRuntimeArtifactsHook(process.cwd(), 'dist', [
'index.types.mjs',
'index.types.mjs.map',
]),
},
]);