-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Refine CJS/ESM build configuration for browser SDK. (#640)
The goals here are to: - Make the build simpler. - Make the build "modern". Currently we have worked around some build issues in other packages. Mainly with node module resolution. Despite the settings in the package.json node wants certain file extensions for certain types including .cts for the CJS type definitions. So far tsup seems to be the simplest way to get all things with expected names without a multi-step process. Or without having to make a hack package.json that just has the modules type. Please review #637 first.
- Loading branch information
1 parent
44a2237
commit ec4377c
Showing
5 changed files
with
57 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'], | ||
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 | ||
opts.mangleProps = /^_([^m|_]|m[^e]|me[^t]|met[^a])/; | ||
}, | ||
}); |