Skip to content

Commit

Permalink
refactor: use object instead of many parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
Loïc Mangeonjean committed Nov 6, 2024
1 parent ac6c0ef commit cf73fa3
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 15 deletions.
20 changes: 14 additions & 6 deletions rollup/rollup-metadata-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,13 @@ interface Options {
) => { name: string; publicName?: string; priority?: number }
handle(
this: PluginContext,
group: GroupResult,
moduleGroupName: Map<string, string | undefined>,
otherDependencies: Set<string>,
options: OutputOptions,
bundle: OutputBundle
params: {
group: GroupResult
moduleGroupName: Map<string, string | undefined>
otherDependencies: Set<string>
options: OutputOptions
bundle: OutputBundle
}
): void | Promise<void>
}

Expand Down Expand Up @@ -187,7 +189,13 @@ export default ({

await Promise.all(
groupResults.map(async (group) => {
await handle.call(this, group, moduleGroupName, otherDependencies, options, bundle)
await handle.call(this, {
group,
moduleGroupName,
otherDependencies,
options,
bundle
})
})
)
}
Expand Down
2 changes: 1 addition & 1 deletion rollup/rollup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -864,7 +864,7 @@ export default (args: Record<string, string>): rollup.RollupOptions[] => {
priority: 1
}
},
async handle(group, moduleGroupName, otherDependencies, options, bundle) {
async handle({ group, moduleGroupName, otherDependencies, bundle }) {
const customResolutionPlugin = ({
customLoad
}: {
Expand Down
4 changes: 2 additions & 2 deletions rollup/rollup.default-extensions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ export default rollup.defineConfig([
}
}),
metadataPlugin({
handle({ directDependencies }, moduleGroupName, otherDependencies, options, bundle) {
handle({ group: { directDependencies }, bundle }) {
const entrypoint = Object.values(bundle).filter(
(v) => (v as rollup.OutputChunk).isEntry
)[0]!.fileName
Expand Down Expand Up @@ -191,7 +191,7 @@ ${extensions.map((name) => ` whenReady${pascalCase(name)}()`).join(',\n')}
}
},
metadataPlugin({
handle({ directDependencies }, moduleGroupName, otherDependencies, options, bundle) {
handle({ group: { directDependencies }, bundle }) {
const entrypoint = Object.values(bundle).filter(
(v) => (v as rollup.OutputChunk).isEntry
)[0]!.fileName
Expand Down
2 changes: 1 addition & 1 deletion rollup/rollup.rollup-plugins.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ const config: rollup.RollupOptions[] = [
preferConst: false
}),
metadataPlugin({
handle({ directDependencies }) {
handle({ group: { directDependencies } }) {
const packageJson: PackageJson = {
name: `@codingame/monaco-vscode-${path.basename(output)}`,
...Object.fromEntries(
Expand Down
8 changes: 3 additions & 5 deletions rollup/rollup.types.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,13 +173,11 @@ export default rollup.defineConfig(
priority: 1
}
},
async handle(
{ name: groupName, exclusiveModules, entrypoints },
async handle({
group: { name: groupName, exclusiveModules, entrypoints },
moduleGroupName,
otherDependencies,
options,
bundle
) {
}) {
if (groupName === 'main') {
return
}
Expand Down

0 comments on commit cf73fa3

Please sign in to comment.