Skip to content

Commit

Permalink
refactor(mc-scripts): renaming vars
Browse files Browse the repository at this point in the history
  • Loading branch information
CarlosCortizasCT committed Oct 10, 2024
1 parent 8df0afc commit f8f062c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .changeset/grumpy-fireants-protect.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Also, if you are using `vite`, we've also added a couple of plugins you can use
- [vite-bundle-analyzer](https://github.com/KusStar/vite-bundle-visualizer)
- [rollup-plugin-visualizer](https://github.com/btd/rollup-plugin-visualizer) (tree visualization)

You can use them by setting this environment variables"
You can use them by setting this environment variables:

```bash
# vite-bundle-analyzer
Expand Down
31 changes: 17 additions & 14 deletions packages/mc-scripts/src/config/optimizations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,24 @@ const removeNonExistantDependencies = (
manualChunks: Record<string, string[]>,
appDependencies: string[]
) => {
return Object.entries(manualChunks).reduce((acc, [chunkName, vendors]) => {
const existingVendors = vendors.filter((vendor) =>
appDependencies.includes(vendor)
);
if (existingVendors.length > 0) {
acc[chunkName] = existingVendors;
} else {
console.log(
chalk.yellow(
`\nFiltering out chunk "${chunkName}" because its configured dependencies does not exist in the application: ${vendors}\n`
)
return Object.entries(manualChunks).reduce(
(chunkGroups, [chunkName, vendors]) => {
const existingVendors = vendors.filter((vendor) =>
appDependencies.includes(vendor)
);
}
return acc;
}, {} as Record<string, string[]>);
if (existingVendors.length > 0) {
chunkGroups[chunkName] = existingVendors;
} else {
console.log(
chalk.yellow(
`\nFiltering out chunk "${chunkName}" because its configured dependencies does not exist in the application: ${vendors}\n`
)
);
}
return chunkGroups;
},
{} as Record<string, string[]>
);
};

// Reference: https://rollupjs.org/configuration-options/#output-manualchunks
Expand Down

0 comments on commit f8f062c

Please sign in to comment.