-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore(javascript): use tsup bundler #3640
Changes from all commits
445289b
0571a41
610bca3
a9b0ae2
1c7c9b8
c24242b
8f81c94
98ef2ce
8de72b7
b9ba52a
b30393d
a551920
ec87f65
2a7122a
ed1edc3
750deb1
ff711aa
1ea8cd8
4a320a9
7614289
19a9a4d
44605ac
8c6ca79
33b0d9d
5e89f1d
9323543
1778083
3e9cbcb
d79ed18
177c6f0
96e338a
f1e404c
214ad33
42f5382
1140310
9534650
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import path from 'path'; | ||
|
||
import type { Options } from 'tsup'; | ||
|
||
type PKG = { | ||
dependencies?: Record<string, string>; | ||
name: string; | ||
}; | ||
|
||
export function getBaseConfig(cwd: string): Options { | ||
return { | ||
clean: true, | ||
sourcemap: true, | ||
splitting: false, | ||
tsconfig: path.resolve(cwd, 'tsconfig.json'), | ||
}; | ||
} | ||
|
||
export function getDependencies(pkg: PKG, env: 'node' | 'browser'): string[] { | ||
const deps = Object.keys(pkg.dependencies || {}) || []; | ||
|
||
if (pkg.name !== "algoliasearch") { | ||
return deps | ||
} | ||
|
||
if (env === 'node') { | ||
return deps.filter(dep => dep !== '@algolia/requester-browser-xhr') | ||
} | ||
|
||
return deps.filter(dep => dep !== '@algolia/requester-node-http') | ||
} | ||
|
||
export function getBaseNodeOptions(pkg: PKG, cwd: string): Options { | ||
return { | ||
...getBaseConfig(cwd), | ||
platform: 'node', | ||
target: 'node14', | ||
external: [...getDependencies(pkg, 'node'), 'node:crypto'], | ||
}; | ||
} | ||
|
||
export function getBaseBrowserOptions(pkg: PKG, cwd: string): Options { | ||
return { | ||
...getBaseConfig(cwd), | ||
platform: 'browser', | ||
format: ['esm'], | ||
target: ['chrome109', 'safari15.6', 'firefox115', 'edge126'], | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The enum for target are prefixes actually, if you don't give a precise version for browsers it asks for it at runtime |
||
external: [...getDependencies(pkg, 'browser'), 'dom'], | ||
}; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lovely