Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support modify vendor name #597

Merged
merged 7 commits into from
Sep 25, 2023
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
6 changes: 6 additions & 0 deletions packages/pkg/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## 1.5.13

### Patch Changes

- 1de94aa: feat: support modify vendor name

## 1.5.12

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/pkg/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ice/pkg",
"version": "1.5.12",
"version": "1.5.13",
"description": "A fast builder for React components, Node modules and web libraries.",
"type": "module",
"main": "./lib/index.js",
Expand Down
7 changes: 4 additions & 3 deletions packages/pkg/src/helpers/getRollupOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,12 +165,13 @@ function getRollupOutputs({
esVersion,
command,
}: GetRollupOutputsOptions): OutputOptions[] {
const { outputDir } = bundleTaskConfig;
const { outputDir, vendorName = 'vendor' } = bundleTaskConfig;

const outputFormats = (bundleTaskConfig.formats || []).filter((format) => format !== 'es2017') as Array<'umd' | 'esm' | 'cjs'>;

const name = bundleTaskConfig.name ?? pkg.name;
const minify = bundleTaskConfig.jsMinify(mode, command);

return outputFormats.map((format) => ({
name,
format,
Expand All @@ -183,7 +184,7 @@ function getRollupOutputs({
chunkFileNames: getFilename('[name]', format, esVersion, mode, 'js'),
manualChunks: format !== 'umd' ? (id, { getModuleInfo }) => {
if (/node_modules/.test(id)) {
return 'vendor';
return vendorName;
}

const entryPoints = [];
Expand All @@ -204,7 +205,7 @@ function getRollupOutputs({
}
// For multiple entries, we put it into a "shared code" bundle
if (entryPoints.length > 1) {
return 'vendor';
return vendorName;
}
} : undefined,
plugins: [
Expand Down
2 changes: 2 additions & 0 deletions packages/pkg/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,8 @@ export interface BundleTaskConfig extends
jsMinify?: (mode: string, command: string) => JSMinify;

cssMinify?: (mode: string, command: string) => CSSMinify;

vendorName?: string;
}

export interface TransformTaskConfig extends _TaskConfig, TransformUserConfig {
Expand Down
Loading