forked from stack-auth/stack-auth
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtsup.config.ts
More file actions
47 lines (43 loc) · 1.31 KB
/
tsup.config.ts
File metadata and controls
47 lines (43 loc) · 1.31 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
import { defineConfig, Options } from 'tsup';
import packageJson from './package.json';
const customNoExternal = new Set([
"oauth4webapi",
]);
const config: Options = {
entryPoints: ['src/**/*.(ts|tsx|js|jsx)'],
sourcemap: true,
clean: false,
noExternal: [...customNoExternal],
dts: true,
outDir: 'dist',
format: ['esm', 'cjs'],
legacyOutput: true,
env: {
STACK_COMPILE_TIME_CLIENT_PACKAGE_VERSION: `js ${packageJson.name}@${packageJson.version}`,
},
esbuildPlugins: [
{
name: 'stackframe tsup plugin (private)',
setup(build) {
build.onEnd(result => {
const sourceFiles = result.outputFiles?.filter(file => !file.path.endsWith('.map')) ?? [];
for (const file of sourceFiles) {
const matchUseClient = /[\s\n\r]*(^|\n|\r|;)\s*['"]use\s+client['"]\s*(\n|\r|;)/im;
if (matchUseClient.test(file.text)) {
file.contents = new TextEncoder().encode(`"use client";\n${file.text}`);
}
}
});
build.onResolve({ filter: /^.*$/m }, async (args) => {
if (args.kind === "entry-point" || customNoExternal.has(args.path)) {
return undefined;
}
return {
external: true,
};
});
},
},
],
};
export default defineConfig(config);