Skip to content

Commit

Permalink
feat: allow specifying dependencies to inline in inlineDependencies (
Browse files Browse the repository at this point in the history
  • Loading branch information
danielroe authored Jan 7, 2025
1 parent 76d4bf6 commit 31c7901
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
10 changes: 9 additions & 1 deletion src/builders/rollup/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,22 @@ export function getRollupOptions(ctx: BuildContext): RollupOptions {
return true;
}
if (
ctx.options.rollup.inlineDependencies ||
ctx.options.rollup.inlineDependencies === true ||
id[0] === "." ||
isAbsolute(id) ||
/src[/\\]/.test(id) ||
id.startsWith(ctx.pkg.name!)
) {
return false;
}
if (Array.isArray(ctx.options.rollup.inlineDependencies)) {
const isExplicitlyInlined =
arrayIncludes(ctx.options.rollup.inlineDependencies, pkg) ||
arrayIncludes(ctx.options.rollup.inlineDependencies, id);
if (isExplicitlyInlined) {
return false;
}
}
if (!isExplicitExternal) {
warn(ctx, `Inlined implicit external ${id}`);
}
Expand Down
7 changes: 5 additions & 2 deletions src/builders/rollup/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,12 @@ export interface RollupBuildOptions {
preserveDynamicImports?: boolean;

/**
* Inline dependencies nor explicitly set in "dependencies" or "peerDependencies" or as marked externals to the bundle.
* Whether to inline dependencies not explicitly set in "dependencies" or "peerDependencies" or as marked externals to the bundle.
*
* If set to true, all such dependencies will be inlined.
* If an array of string or regular expressions is passed, these will be used to determine whether to inline such a dependency.
*/
inlineDependencies?: boolean;
inlineDependencies?: boolean | Array<string | RegExp>;

/**
* Rollup [Output Options](https://rollupjs.org/configuration-options)
Expand Down

0 comments on commit 31c7901

Please sign in to comment.