rolldown-license-plugin 2.1.0 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +15 -1
- package/dist/index.d.ts +12 -8
- package/dist/index.js +10 -3
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -50,7 +50,21 @@ When set, word-wrap `licenseText` to this column width.
|
|
|
50
50
|
|
|
51
51
|
Type: `(license: LicenseInfo) => boolean`
|
|
52
52
|
|
|
53
|
-
Validate each dependency's license. Return `false` to throw
|
|
53
|
+
Validate each dependency's license. Return `false` to reject it. By default, rejected dependencies are warned via `console.warn`. Use `failOnViolation` and `failOnUnlicensed` to throw build errors instead.
|
|
54
|
+
|
|
55
|
+
#### `opts.failOnViolation`
|
|
56
|
+
|
|
57
|
+
Type: `boolean`\
|
|
58
|
+
Default: `false`
|
|
59
|
+
|
|
60
|
+
Throw a build error when a dependency has an incompatible license.
|
|
61
|
+
|
|
62
|
+
#### `opts.failOnUnlicensed`
|
|
63
|
+
|
|
64
|
+
Type: `boolean`\
|
|
65
|
+
Default: `false`
|
|
66
|
+
|
|
67
|
+
Throw a build error when a dependency does not specify any license.
|
|
54
68
|
|
|
55
69
|
### `LicenseInfo`
|
|
56
70
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
//#region node_modules/.pnpm/rolldown@1.0.0-rc.
|
|
1
|
+
//#region node_modules/.pnpm/rolldown@1.0.0-rc.14/node_modules/rolldown/dist/shared/logging-C6h4g8dA.d.mts
|
|
2
2
|
//#region src/log/logging.d.ts
|
|
3
3
|
/** @inline */
|
|
4
4
|
type LogLevel = "info" | "debug" | "warn";
|
|
@@ -48,7 +48,7 @@ interface RolldownError extends RolldownLog {
|
|
|
48
48
|
}
|
|
49
49
|
type LogOrStringHandler = (level: LogLevelWithError, log: RolldownLogWithString) => void; //#endregion
|
|
50
50
|
//#endregion
|
|
51
|
-
//#region node_modules/.pnpm/@oxc-project+types@0.
|
|
51
|
+
//#region node_modules/.pnpm/@oxc-project+types@0.124.0/node_modules/@oxc-project/types/types.d.ts
|
|
52
52
|
// Auto-generated code, DO NOT EDIT DIRECTLY!
|
|
53
53
|
// To edit this generated file you have to edit `tasks/ast_tools/src/generators/typescript.rs`.
|
|
54
54
|
interface Program extends Span {
|
|
@@ -1347,7 +1347,7 @@ type UnaryOperator = "+" | "-" | "!" | "~" | "typeof" | "void" | "delete";
|
|
|
1347
1347
|
type UpdateOperator = "++" | "--";
|
|
1348
1348
|
type Node = Program | IdentifierName | IdentifierReference | BindingIdentifier | LabelIdentifier | ThisExpression | ArrayExpression | ObjectExpression | ObjectProperty | TemplateLiteral | TaggedTemplateExpression | TemplateElement | ComputedMemberExpression | StaticMemberExpression | PrivateFieldExpression | CallExpression | NewExpression | MetaProperty | SpreadElement | UpdateExpression | UnaryExpression | BinaryExpression | PrivateInExpression | LogicalExpression | ConditionalExpression | AssignmentExpression | ArrayAssignmentTarget | ObjectAssignmentTarget | AssignmentTargetRest | AssignmentTargetWithDefault | AssignmentTargetPropertyIdentifier | AssignmentTargetPropertyProperty | SequenceExpression | Super | AwaitExpression | ChainExpression | ParenthesizedExpression | Directive | Hashbang | BlockStatement | VariableDeclaration | VariableDeclarator | EmptyStatement | ExpressionStatement | IfStatement | DoWhileStatement | WhileStatement | ForStatement | ForInStatement | ForOfStatement | ContinueStatement | BreakStatement | ReturnStatement | WithStatement | SwitchStatement | SwitchCase | LabeledStatement | ThrowStatement | TryStatement | CatchClause | DebuggerStatement | AssignmentPattern | ObjectPattern | BindingProperty | ArrayPattern | BindingRestElement | Function | FunctionBody | ArrowFunctionExpression | YieldExpression | Class | ClassBody | MethodDefinition | PropertyDefinition | PrivateIdentifier | StaticBlock | AccessorProperty | ImportExpression | ImportDeclaration | ImportSpecifier | ImportDefaultSpecifier | ImportNamespaceSpecifier | ImportAttribute | ExportNamedDeclaration | ExportDefaultDeclaration | ExportAllDeclaration | ExportSpecifier | V8IntrinsicExpression | BooleanLiteral | NullLiteral | NumericLiteral | StringLiteral | BigIntLiteral | RegExpLiteral | JSXElement | JSXOpeningElement | JSXClosingElement | JSXFragment | JSXOpeningFragment | JSXClosingFragment | JSXNamespacedName | JSXMemberExpression | JSXExpressionContainer | JSXEmptyExpression | JSXAttribute | JSXSpreadAttribute | JSXIdentifier | JSXSpreadChild | JSXText | TSThisParameter | TSEnumDeclaration | TSEnumBody | TSEnumMember | TSTypeAnnotation | TSLiteralType | TSConditionalType | TSUnionType | TSIntersectionType | TSParenthesizedType | TSTypeOperator | TSArrayType | TSIndexedAccessType | TSTupleType | TSNamedTupleMember | TSOptionalType | TSRestType | TSAnyKeyword | TSStringKeyword | TSBooleanKeyword | TSNumberKeyword | TSNeverKeyword | TSIntrinsicKeyword | TSUnknownKeyword | TSNullKeyword | TSUndefinedKeyword | TSVoidKeyword | TSSymbolKeyword | TSThisType | TSObjectKeyword | TSBigIntKeyword | TSTypeReference | TSQualifiedName | TSTypeParameterInstantiation | TSTypeParameter | TSTypeParameterDeclaration | TSTypeAliasDeclaration | TSClassImplements | TSInterfaceDeclaration | TSInterfaceBody | TSPropertySignature | TSIndexSignature | TSCallSignatureDeclaration | TSMethodSignature | TSConstructSignatureDeclaration | TSIndexSignatureName | TSInterfaceHeritage | TSTypePredicate | TSModuleDeclaration | TSGlobalDeclaration | TSModuleBlock | TSTypeLiteral | TSInferType | TSTypeQuery | TSImportType | TSImportTypeQualifiedName | TSFunctionType | TSConstructorType | TSMappedType | TSTemplateLiteralType | TSAsExpression | TSSatisfiesExpression | TSTypeAssertion | TSImportEqualsDeclaration | TSExternalModuleReference | TSNonNullExpression | Decorator | TSExportAssignment | TSNamespaceExportDeclaration | TSInstantiationExpression | JSDocNullableType | JSDocNonNullableType | JSDocUnknownType | ParamPattern;
|
|
1349
1349
|
//#endregion
|
|
1350
|
-
//#region node_modules/.pnpm/rolldown@1.0.0-rc.
|
|
1350
|
+
//#region node_modules/.pnpm/rolldown@1.0.0-rc.14/node_modules/rolldown/dist/shared/binding-DUEnSb0A.d.mts
|
|
1351
1351
|
interface CodegenOptions {
|
|
1352
1352
|
/**
|
|
1353
1353
|
* Remove whitespace.
|
|
@@ -2236,7 +2236,7 @@ interface ViteImportGlobMeta {
|
|
|
2236
2236
|
isSubImportsPattern?: boolean;
|
|
2237
2237
|
} //#endregion
|
|
2238
2238
|
//#endregion
|
|
2239
|
-
//#region node_modules/.pnpm/@rolldown+pluginutils@1.0.0-rc.
|
|
2239
|
+
//#region node_modules/.pnpm/@rolldown+pluginutils@1.0.0-rc.14/node_modules/@rolldown/pluginutils/dist/filter/composable-filters.d.ts
|
|
2240
2240
|
type StringOrRegExp$1 = string | RegExp;
|
|
2241
2241
|
type PluginModuleType = 'js' | 'jsx' | 'ts' | 'tsx' | 'json' | 'text' | 'base64' | 'dataurl' | 'binary' | 'empty' | (string & {});
|
|
2242
2242
|
type FilterExpression = And | Or | Not | Id | ImporterId | ModuleType$1 | Code | Query;
|
|
@@ -2298,7 +2298,7 @@ declare class Exclude$1 {
|
|
|
2298
2298
|
constructor(expr: FilterExpression);
|
|
2299
2299
|
}
|
|
2300
2300
|
//#endregion
|
|
2301
|
-
//#region node_modules/.pnpm/rolldown@1.0.0-rc.
|
|
2301
|
+
//#region node_modules/.pnpm/rolldown@1.0.0-rc.14/node_modules/rolldown/dist/shared/define-config-DhJZwTRw.d.mts
|
|
2302
2302
|
//#region src/types/misc.d.ts
|
|
2303
2303
|
/** @inline */
|
|
2304
2304
|
type SourcemapPathTransformOption = (relativeSourcePath: string, sourcemapPath: string) => string;
|
|
@@ -5741,8 +5741,10 @@ type LicenseInfo = {
|
|
|
5741
5741
|
type RolldownLicensePluginOpts = {
|
|
5742
5742
|
/** Called during `generateBundle` with the collected license data, sorted by name */done: (licenses: LicenseInfo[], context: PluginContext) => void | Promise<void>; /** Regex to match license filenames. Default: `/^((UN)?LICEN(S|C)E|COPYING).*$/i` */
|
|
5743
5743
|
match?: RegExp; /** When set, word-wrap `licenseText` to this column width */
|
|
5744
|
-
wrapText?: number; /** Validate each dependency's license. Return `false` to
|
|
5745
|
-
allow?: (license: LicenseInfo) => boolean;
|
|
5744
|
+
wrapText?: number; /** Validate each dependency's license. Return `false` to reject it */
|
|
5745
|
+
allow?: (license: LicenseInfo) => boolean; /** Throw a build error when a dependency has an incompatible license. Default: `false` (warn only) */
|
|
5746
|
+
failOnViolation?: boolean; /** Throw a build error when a dependency does not specify any license. Default: `false` (warn only) */
|
|
5747
|
+
failOnUnlicensed?: boolean;
|
|
5746
5748
|
};
|
|
5747
5749
|
/** Word-wrap plain text to a specified column width */
|
|
5748
5750
|
declare function wrap(text: string, width: number): string;
|
|
@@ -5751,7 +5753,9 @@ declare const licensePlugin: ({
|
|
|
5751
5753
|
done,
|
|
5752
5754
|
match,
|
|
5753
5755
|
wrapText,
|
|
5754
|
-
allow
|
|
5756
|
+
allow,
|
|
5757
|
+
failOnViolation,
|
|
5758
|
+
failOnUnlicensed
|
|
5755
5759
|
}: RolldownLicensePluginOpts) => Plugin;
|
|
5756
5760
|
//#endregion
|
|
5757
5761
|
export { LicenseInfo, RolldownLicensePluginOpts, licensePlugin, wrap };
|
package/dist/index.js
CHANGED
|
@@ -40,7 +40,7 @@ function parseLicense(pkgJson) {
|
|
|
40
40
|
return "";
|
|
41
41
|
}
|
|
42
42
|
/** Rolldown plugin that extracts license information from bundled dependencies */
|
|
43
|
-
const licensePlugin = ({ done, match = defaultMatch, wrapText, allow }) => ({
|
|
43
|
+
const licensePlugin = ({ done, match = defaultMatch, wrapText, allow, failOnViolation = false, failOnUnlicensed = false }) => ({
|
|
44
44
|
name: "rolldown-license-plugin",
|
|
45
45
|
async generateBundle(_opts, bundle) {
|
|
46
46
|
const pkgJsonCache = /* @__PURE__ */ new Map();
|
|
@@ -107,8 +107,15 @@ const licensePlugin = ({ done, match = defaultMatch, wrapText, allow }) => ({
|
|
|
107
107
|
}));
|
|
108
108
|
licenses.sort((a, b) => a.name.localeCompare(b.name));
|
|
109
109
|
if (allow) {
|
|
110
|
-
const
|
|
111
|
-
|
|
110
|
+
const errors = [];
|
|
111
|
+
for (const entry of licenses) {
|
|
112
|
+
if (allow(entry)) continue;
|
|
113
|
+
const fail = entry.license ? failOnViolation : failOnUnlicensed;
|
|
114
|
+
const msg = entry.license ? `Dependency "${entry.name}" has an incompatible license: ${entry.license}` : `Dependency "${entry.name}" does not specify any license.`;
|
|
115
|
+
if (fail) errors.push(msg);
|
|
116
|
+
else console.warn(msg);
|
|
117
|
+
}
|
|
118
|
+
if (errors.length) throw new Error(errors.join("\n"));
|
|
112
119
|
}
|
|
113
120
|
await done(licenses, this);
|
|
114
121
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rolldown-license-plugin",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.2.0",
|
|
4
4
|
"description": "Rolldown plugin to extract dependency licenses",
|
|
5
5
|
"author": "silverwind <me@silverwind.io>",
|
|
6
6
|
"repository": "silverwind/rolldown-license-plugin",
|
|
@@ -17,11 +17,11 @@
|
|
|
17
17
|
],
|
|
18
18
|
"devDependencies": {
|
|
19
19
|
"@types/node": "25.5.2",
|
|
20
|
-
"@typescript/native-preview": "7.0.0-dev.
|
|
21
|
-
"eslint": "10.
|
|
22
|
-
"eslint-config-silverwind": "
|
|
20
|
+
"@typescript/native-preview": "7.0.0-dev.20260408.1",
|
|
21
|
+
"eslint": "10.2.0",
|
|
22
|
+
"eslint-config-silverwind": "131.0.1",
|
|
23
23
|
"jest-extended": "7.0.0",
|
|
24
|
-
"rolldown": "1.0.0-rc.
|
|
24
|
+
"rolldown": "1.0.0-rc.14",
|
|
25
25
|
"tsdown": "0.21.7",
|
|
26
26
|
"tsdown-config-silverwind": "2.0.5",
|
|
27
27
|
"typescript": "5.9.3",
|