Skip to content

Commit

Permalink
fix(lib): Libraries do not need to be minified by default as this is …
Browse files Browse the repository at this point in the history
…done on app level

Co-authored-by: Ferdinand Thiessen <opensource@fthiessen.de>
Co-authored-by: Grigorii K. Shartsev <me@shgk.me>
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
  • Loading branch information
susnux and ShGKme committed Apr 22, 2024
1 parent e9be750 commit f147668
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion lib/libConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ import { ImportCSSPlugin } from './plugins/ImportCSS.js'
type OutputOptions = BuildOptions['rollupOptions']['output']

export interface LibraryOptions extends BaseOptions {
/**
* Whether to minify the output
* @default false For libraries the code is not minified by default for better DX. Usually it is not needed: a library will be minified as a part of an app bundling.
*/
minify?: boolean

/**
* Options for the rollup node externals plugin
*
Expand Down Expand Up @@ -52,7 +58,13 @@ export interface LibraryOptions extends BaseOptions {
*/
export const createLibConfig = (entries: { [entryAlias: string]: string }, options: LibraryOptions = {}): UserConfigFn => {
// Add default values for options
options = { config: {}, nodeExternalsOptions: {}, libraryFormats: ['es'], ...options }
options = {
config: {},
minify: false,
nodeExternalsOptions: {},
libraryFormats: ['es'],
...options,
}

const node = nodeExternals({
builtins: true, // Mark all node core modules, like `path` as external
Expand Down

0 comments on commit f147668

Please sign in to comment.