-
Notifications
You must be signed in to change notification settings - Fork 19
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
feat: Refine CJS/ESM build configuration for browser SDK. #640
Changes from all commits
ae4de36
0349691
421b0b5
f96c211
903aa30
aadb06b
e3fc195
979219b
55672bb
8067c05
87ce8e0
cdf80b6
5ef907b
0fbe44c
4b3beb2
f7b2254
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,27 @@ | ||
// It is a dev dependency and the linter doesn't understand. | ||
// eslint-disable-next-line import/no-extraneous-dependencies | ||
import { defineConfig } from 'tsup'; | ||
|
||
export default defineConfig({ | ||
entry: { | ||
index: 'src/index.ts', | ||
compat: 'src/compat/index.ts', | ||
}, | ||
minify: true, | ||
format: ['esm', 'cjs'], | ||
splitting: false, | ||
sourcemap: false, | ||
clean: true, | ||
noExternal: ['@launchdarkly/js-sdk-common', '@launchdarkly/js-client-sdk-common'], | ||
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. So, the one thing that wasn't great about tsup is that it doesn't bundle dependencies unless they are dev dependencies. Which sounds fine, but then you need to figure out how to handle the typescript for those packages. It has a method to bundle the typescript into .d.ts files as well, but that very much didn't work. So this instructs it to not treat these as external. It does mean that you get these installed for a production build even though they are not then used. But that has been the precedent. If the bundling of the typing worked, then that would be a reasonable alternative. |
||
dts: true, | ||
metafile: true, | ||
esbuildOptions(opts) { | ||
// This would normally be `^_(?!meta|_)`, but go doesn't support negative look-ahead assertions, | ||
// so we need to craft something that works without it. | ||
// So start of line followed by a character that isn't followed by m or underscore, but we | ||
// want other things that do start with m, so we need to progressively handle more characters | ||
// of meta with exclusions. | ||
// eslint-disable-next-line no-param-reassign | ||
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 interface works by modifying the input options, which means re-assigning. |
||
opts.mangleProps = /^_([^m|_]|m[^e]|me[^t]|met[^a])/; | ||
}, | ||
}); |
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.
For the bundle-size task I will add some conditional configuration to a dev build and source maps.
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.
The esbuild support actually means it can generate a meta data file, which can be used for the analysis instead. So no debug builds for now.