Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 13 additions & 7 deletions packages/core/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -227,21 +227,27 @@ export const composeAutoExternalConfig = (options: {
return {};
}

// User externals configuration has higher priority than autoExternal
// eg: autoExternal: ['react'], user: output: { externals: { react: 'react-1' } }
// Only handle the case where the externals type is object, string / string[] does not need to be processed, other types are too complex.
const userExternalKeys =
userExternals && isObject(userExternals) ? Object.keys(userExternals) : [];

const externalOptions = {
dependencies: true,
optionalDependencies: true,
peerDependencies: true,
devDependencies: false,
...(autoExternal === true ? {} : autoExternal),
};

// User externals configuration has higher priority than autoExternal
// eg: autoExternal: ['react'], user: output: { externals: { react: 'react-1' } }
// Only handle the case where the externals type is object, string / string[] does not need to be processed, other types are too complex.
const userExternalKeys =
userExternals && isObject(userExternals) ? Object.keys(userExternals) : [];

const externals = (
['dependencies', 'peerDependencies', 'devDependencies'] as const
[
'dependencies',
'peerDependencies',
'devDependencies',
'optionalDependencies',
] as const
)
.reduce<string[]>((prev, type) => {
if (externalOptions[type]) {
Expand Down
3 changes: 2 additions & 1 deletion packages/core/src/types/utils.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
export type PkgJson = {
type?: 'module' | 'commonjs';
dependencies?: Record<string, string>;
peerDependencies?: Record<string, string>;
devDependencies?: Record<string, string>;
[key: string]: unknown;
optionalDependencies?: Record<string, string>;
};
2 changes: 2 additions & 0 deletions packages/plugin-dts/src/dts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export const calcBundledPackages = (options: {
dependencies?: Record<string, string>;
peerDependencies?: Record<string, string>;
devDependencies?: Record<string, string>;
optionalDependencies?: Record<string, string>;
};

try {
Expand All @@ -42,6 +43,7 @@ export const calcBundledPackages = (options: {
? {
dependencies: true,
peerDependencies: true,
optionalDependencies: true,
devDependencies: false,
...(autoExternal === true ? {} : autoExternal),
}
Expand Down
Loading