@ogs-gmbh/rolldown-plugin-package-json 1.0.0 → 1.1.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/CHANGELOG.md +26 -0
- package/dist/main/{exports.d.mts → exports.d.ts} +1 -1
- package/dist/main/exports.d.ts.map +1 -0
- package/dist/main/{exports.mjs → exports.js} +1 -1
- package/dist/main/exports.js.map +1 -0
- package/dist/main/{options.d.mts → options.d.ts} +1 -1
- package/dist/main/options.d.ts.map +1 -0
- package/dist/main/{options.mjs → options.js} +1 -1
- package/dist/main/options.js.map +1 -0
- package/dist/main/{plugin.d.mts → plugin.d.ts} +2 -2
- package/dist/main/plugin.d.ts.map +1 -0
- package/dist/main/{plugin.mjs → plugin.js} +10 -10
- package/dist/main/plugin.js.map +1 -0
- package/dist/main/public-api.d.ts +2 -0
- package/dist/main/public-api.js +2 -0
- package/dist/main/{types.d.mts → types.d.ts} +8 -17
- package/dist/main/types.d.ts.map +1 -0
- package/dist/main/types.js +0 -0
- package/dist/main/{utils.d.mts → utils.d.ts} +2 -2
- package/dist/main/utils.d.ts.map +1 -0
- package/dist/main/{utils.mjs → utils.js} +1 -1
- package/dist/main/utils.js.map +1 -0
- package/package.json +6 -10
- package/dist/main/exports.d.mts.map +0 -1
- package/dist/main/exports.mjs.map +0 -1
- package/dist/main/options.d.mts.map +0 -1
- package/dist/main/options.mjs.map +0 -1
- package/dist/main/plugin.d.mts.map +0 -1
- package/dist/main/plugin.mjs.map +0 -1
- package/dist/main/public-api.d.mts +0 -2
- package/dist/main/public-api.mjs +0 -3
- package/dist/main/types.d.mts.map +0 -1
- package/dist/main/types.mjs +0 -1
- package/dist/main/utils.d.mts.map +0 -1
- package/dist/main/utils.mjs.map +0 -1
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## [1.1.0](https://github.com/OGS-GmbH/rolldown-plugin-package-json/compare/v1.0.1...v1.1.0) (2026-04-01)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* add global override api ([8f93c93](https://github.com/OGS-GmbH/rolldown-plugin-package-json/commit/8f93c9336876674f7346615e86fc9de85ca4cf62))
|
|
9
|
+
|
|
10
|
+
## [1.0.1](https://github.com/OGS-GmbH/rolldown-plugin-package-json/compare/v1.0.0...v1.0.1) (2026-03-31)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Bug Fixes
|
|
14
|
+
|
|
15
|
+
* neutralize build ([71f0ca7](https://github.com/OGS-GmbH/rolldown-plugin-package-json/commit/71f0ca737eaec4135e81aa2bc2f44f0d7fd5ee6a))
|
|
16
|
+
|
|
17
|
+
## 1.0.0 (2026-03-31)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### ⚠ BREAKING CHANGES
|
|
21
|
+
|
|
22
|
+
* init [skip ci]
|
|
23
|
+
|
|
24
|
+
### Miscellaneous Chores
|
|
25
|
+
|
|
26
|
+
* init [skip ci] ([22be57b](https://github.com/OGS-GmbH/rolldown-plugin-package-json/commit/22be57b9a7c2ced877dcba1036e94ac1ef303969))
|
|
@@ -5,4 +5,4 @@ import { PackageJson } from "type-fest";
|
|
|
5
5
|
declare function getExportsFromBundle(this: PluginContext, bundle: OutputBundle): PackageJson.Exports;
|
|
6
6
|
//#endregion
|
|
7
7
|
export { getExportsFromBundle };
|
|
8
|
-
//# sourceMappingURL=exports.d.
|
|
8
|
+
//# sourceMappingURL=exports.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exports.d.ts","names":[],"sources":["../../src/exports.ts"],"mappings":";;;;iBAgBS,oBAAA,CAAqB,IAAA,EAAM,aAAA,EAAe,MAAA,EAAQ,YAAA,GAAe,WAAA,CAAY,OAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exports.js","names":[],"sources":["../../src/exports.ts"],"sourcesContent":["import path from \"node:path\";\nimport type { OutputBundle, PluginContext } from \"rolldown\";\nimport { PackageJson } from \"type-fest\";\n\nconst fileExtensionToField: Record<string, keyof PackageJson.ExportConditions> = {\n \".js\": \"default\",\n \".mjs\": \"import\",\n \".cjs\": \"require\",\n \".ts\": \"default\",\n \".mts\": \"import\",\n \".cts\": \"require\"\n};\n\nconst declarationMarker = \".d\";\nconst relativeMarker = \"./\";\n\nfunction getExportsFromBundle(this: PluginContext, bundle: OutputBundle): PackageJson.Exports {\n const files: PackageJson.Exports = {};\n\n for (const [name, content] of Object.entries(bundle)) {\n const relativeName = `${relativeMarker}${name}`;\n\n if (content.type === \"asset\") {\n files[relativeName] = relativeName;\n\n continue;\n }\n\n const parsedPath = path.parse(name);\n\n // If we found a declaration file, we need to handle it differently\n if (parsedPath.name.endsWith(declarationMarker)) {\n const relativeVirtualPath = `${relativeMarker}${parsedPath.name.slice(0, -2)}`;\n const currentFile = files[relativeVirtualPath];\n\n files[relativeVirtualPath] = {\n ...(typeof currentFile === \"object\" ? currentFile : {}),\n types: relativeName\n };\n\n continue;\n }\n\n const relativeVirtualPath = `${relativeMarker}${parsedPath.name}`;\n const currentFile = files[relativeVirtualPath];\n const field = fileExtensionToField[parsedPath.ext];\n\n if (field === undefined) {\n this.warn(`Bundle file '${name}' doesn't match any export rule and is ignored.`);\n continue;\n }\n\n files[relativeVirtualPath] = {\n ...(typeof currentFile === \"object\" ? currentFile : {}),\n [field]: relativeName\n };\n }\n\n return files;\n}\n\nexport { getExportsFromBundle };\n"],"mappings":";;AAIA,MAAM,uBAA2E;CAC/E,OAAO;CACP,QAAQ;CACR,QAAQ;CACR,OAAO;CACP,QAAQ;CACR,QAAQ;CACT;AAED,MAAM,oBAAoB;AAC1B,MAAM,iBAAiB;AAEvB,SAAS,qBAA0C,QAA2C;CAC5F,MAAM,QAA6B,EAAE;AAErC,MAAK,MAAM,CAAC,MAAM,YAAY,OAAO,QAAQ,OAAO,EAAE;EACpD,MAAM,eAAe,GAAG,iBAAiB;AAEzC,MAAI,QAAQ,SAAS,SAAS;AAC5B,SAAM,gBAAgB;AAEtB;;EAGF,MAAM,aAAa,KAAK,MAAM,KAAK;AAGnC,MAAI,WAAW,KAAK,SAAS,kBAAkB,EAAE;GAC/C,MAAM,sBAAsB,GAAG,iBAAiB,WAAW,KAAK,MAAM,GAAG,GAAG;GAC5E,MAAM,cAAc,MAAM;AAE1B,SAAM,uBAAuB;IAC3B,GAAI,OAAO,gBAAgB,WAAW,cAAc,EAAE;IACtD,OAAO;IACR;AAED;;EAGF,MAAM,sBAAsB,GAAG,iBAAiB,WAAW;EAC3D,MAAM,cAAc,MAAM;EAC1B,MAAM,QAAQ,qBAAqB,WAAW;AAE9C,MAAI,UAAU,KAAA,GAAW;AACvB,QAAK,KAAK,gBAAgB,KAAK,iDAAiD;AAChF;;AAGF,QAAM,uBAAuB;GAC3B,GAAI,OAAO,gBAAgB,WAAW,cAAc,EAAE;IACrD,QAAQ;GACV;;AAGH,QAAO"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"options.d.ts","names":[],"sources":["../../src/options.ts"],"mappings":";cAAM,sBAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"options.js","names":[],"sources":["../../src/options.ts"],"sourcesContent":["const defaultCleanProperties: string[] = [\"scripts\", \"packageManager\", \"publishConfig\"];\n\nexport { defaultCleanProperties };\n"],"mappings":";AAAA,MAAM,yBAAmC;CAAC;CAAW;CAAkB;CAAgB"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Options } from "./types";
|
|
1
|
+
import { Options } from "./types.js";
|
|
2
2
|
import { Plugin } from "rolldown";
|
|
3
3
|
|
|
4
4
|
//#region src/plugin.d.ts
|
|
@@ -15,4 +15,4 @@ import { Plugin } from "rolldown";
|
|
|
15
15
|
declare function packageJsonPlugin(options?: Options): Plugin;
|
|
16
16
|
//#endregion
|
|
17
17
|
export { packageJsonPlugin };
|
|
18
|
-
//# sourceMappingURL=plugin.d.
|
|
18
|
+
//# sourceMappingURL=plugin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.d.ts","names":[],"sources":["../../src/plugin.ts"],"mappings":";;;;;;AAOqC;;;;;;;;iBAe5B,iBAAA,CAAkB,OAAA,GAAU,OAAA,GAAU,MAAA"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
2
|
import fs from "node:fs";
|
|
3
3
|
import { merge } from "es-toolkit";
|
|
4
|
-
import { getExportsFromBundle } from "./exports";
|
|
5
|
-
import { defaultCleanProperties } from "./options";
|
|
6
|
-
import { isEnabled } from "./utils";
|
|
4
|
+
import { getExportsFromBundle } from "./exports.js";
|
|
5
|
+
import { defaultCleanProperties } from "./options.js";
|
|
6
|
+
import { isEnabled } from "./utils.js";
|
|
7
7
|
//#region src/plugin.ts
|
|
8
8
|
const fileName = "package.json";
|
|
9
9
|
/**
|
|
@@ -22,19 +22,22 @@ function packageJsonPlugin(options) {
|
|
|
22
22
|
encoding: "utf8",
|
|
23
23
|
flag: "r"
|
|
24
24
|
});
|
|
25
|
-
|
|
25
|
+
let meta = JSON.parse(metaContent);
|
|
26
26
|
if (isEnabled(options?.clean)) (typeof options?.clean === "boolean" ? defaultCleanProperties : options?.clean?.properties ? options.clean.properties : defaultCleanProperties).map((property) => {
|
|
27
27
|
delete meta[property];
|
|
28
28
|
});
|
|
29
|
-
if (isEnabled(options?.exports) && typeof options?.exports !== "boolean" && options?.exports?.override) meta.exports = options.exports.override;
|
|
30
29
|
return {
|
|
31
30
|
name: "package-json-plugin",
|
|
32
31
|
generateBundle: async function(_outputOptions, bundle) {
|
|
33
|
-
if (
|
|
32
|
+
if (options?.exports) {
|
|
34
33
|
const generatedExports = getExportsFromBundle.call(this, bundle);
|
|
35
34
|
if (meta.exports) meta.exports = merge(meta.exports, generatedExports);
|
|
36
35
|
else meta.exports = generatedExports;
|
|
37
36
|
}
|
|
37
|
+
if (options?.override) meta = {
|
|
38
|
+
...meta,
|
|
39
|
+
...options.override
|
|
40
|
+
};
|
|
38
41
|
const finalMetaContent = JSON.stringify(meta, null, 2);
|
|
39
42
|
this.emitFile({
|
|
40
43
|
type: "asset",
|
|
@@ -42,13 +45,10 @@ function packageJsonPlugin(options) {
|
|
|
42
45
|
originalFileName: metaPath,
|
|
43
46
|
source: finalMetaContent
|
|
44
47
|
});
|
|
45
|
-
},
|
|
46
|
-
buildEnd: function() {
|
|
47
|
-
this.info("'package.json' successfully created!");
|
|
48
48
|
}
|
|
49
49
|
};
|
|
50
50
|
}
|
|
51
51
|
//#endregion
|
|
52
52
|
export { packageJsonPlugin };
|
|
53
53
|
|
|
54
|
-
//# sourceMappingURL=plugin.
|
|
54
|
+
//# sourceMappingURL=plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.js","names":[],"sources":["../../src/plugin.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport path from \"node:path\";\nimport { merge } from \"es-toolkit\";\nimport type { NormalizedOutputOptions, OutputBundle, Plugin, PluginContext } from \"rolldown\";\nimport { PackageJson } from \"type-fest\";\nimport { getExportsFromBundle } from \"./exports.js\";\nimport { defaultCleanProperties } from \"./options.js\";\nimport { Options } from \"./types.js\";\nimport { isEnabled } from \"./utils.js\";\n\nconst fileName: string = \"package.json\";\n\n/**\n * A Rollup plugin that generates a `package.json` file based on your root `package.json` and the generated bundle.\n *\n * @param options - An optional object to configure {@link Options} for the plugin's behavior.\n * @returns A Rollup plugin that generates a `package.json` file.\n *\n * @since 1.0.0\n * @author Simon Kovtyk\n * @category Plugin\n */\nfunction packageJsonPlugin(options?: Options): Plugin {\n const metaPath = path.join(process.cwd(), fileName);\n const metaContent = fs.readFileSync(metaPath, { encoding: \"utf8\", flag: \"r\" });\n let meta = JSON.parse(metaContent) as PackageJson;\n\n if (isEnabled(options?.clean)) {\n const properties =\n typeof options?.clean === \"boolean\"\n ? defaultCleanProperties\n : options?.clean?.properties\n ? options.clean.properties\n : defaultCleanProperties;\n\n properties.map((property) => {\n delete meta[property];\n });\n }\n\n return {\n name: \"package-json-plugin\",\n generateBundle: async function (\n this: PluginContext,\n _outputOptions: NormalizedOutputOptions,\n bundle: OutputBundle\n ): Promise<void> {\n if (options?.exports) {\n const generatedExports = getExportsFromBundle.call(this, bundle);\n\n if (meta.exports) {\n // @ts-ignore\n meta.exports = merge(meta.exports, generatedExports);\n } else meta.exports = generatedExports;\n }\n\n if (options?.override) {\n meta = {\n ...meta,\n ...options.override\n };\n }\n\n const finalMetaContent = JSON.stringify(meta, null, 2);\n\n this.emitFile({\n type: \"asset\",\n fileName,\n originalFileName: metaPath,\n source: finalMetaContent\n });\n }\n };\n}\n\nexport { packageJsonPlugin };\n"],"mappings":";;;;;;;AAUA,MAAM,WAAmB;;;;;;;;;;;AAYzB,SAAS,kBAAkB,SAA2B;CACpD,MAAM,WAAW,KAAK,KAAK,QAAQ,KAAK,EAAE,SAAS;CACnD,MAAM,cAAc,GAAG,aAAa,UAAU;EAAE,UAAU;EAAQ,MAAM;EAAK,CAAC;CAC9E,IAAI,OAAO,KAAK,MAAM,YAAY;AAElC,KAAI,UAAU,SAAS,MAAM,CAQ3B,EANE,OAAO,SAAS,UAAU,YACtB,yBACA,SAAS,OAAO,aACd,QAAQ,MAAM,aACd,wBAEG,KAAK,aAAa;AAC3B,SAAO,KAAK;GACZ;AAGJ,QAAO;EACL,MAAM;EACN,gBAAgB,eAEd,gBACA,QACe;AACf,OAAI,SAAS,SAAS;IACpB,MAAM,mBAAmB,qBAAqB,KAAK,MAAM,OAAO;AAEhE,QAAI,KAAK,QAEP,MAAK,UAAU,MAAM,KAAK,SAAS,iBAAiB;QAC/C,MAAK,UAAU;;AAGxB,OAAI,SAAS,SACX,QAAO;IACL,GAAG;IACH,GAAG,QAAQ;IACZ;GAGH,MAAM,mBAAmB,KAAK,UAAU,MAAM,MAAM,EAAE;AAEtD,QAAK,SAAS;IACZ,MAAM;IACN;IACA,kBAAkB;IAClB,QAAQ;IACT,CAAC;;EAEL"}
|
|
@@ -29,36 +29,27 @@ type CleanOption = {
|
|
|
29
29
|
properties: string[];
|
|
30
30
|
};
|
|
31
31
|
/**
|
|
32
|
-
* Options for the
|
|
32
|
+
* Options for the plugin, which can be used to configure its behavior. Each option can be either a `boolean` to enable/disable the feature or an `Object` with additional configuration.
|
|
33
33
|
*
|
|
34
34
|
* @since 1.0.0
|
|
35
35
|
* @author Simon Kovtyk
|
|
36
36
|
* @category Types
|
|
37
37
|
*/
|
|
38
|
-
type
|
|
38
|
+
type Options = Partial<{
|
|
39
39
|
/**
|
|
40
|
-
* An object representing the
|
|
40
|
+
* An object representing the properties to be overridden in the generated `package.json` file. The properties specified in this object will take precedence over the default values and any values inherited from the root `package.json` file.
|
|
41
41
|
*
|
|
42
|
-
* @since 1.
|
|
42
|
+
* @since 1.1.0
|
|
43
43
|
* @author Simon Kovtyk
|
|
44
44
|
*/
|
|
45
|
-
override: PackageJson
|
|
46
|
-
};
|
|
47
|
-
/**
|
|
48
|
-
* Options for the plugin, which can be used to configure its behavior. Each option can be either a `boolean` to enable/disable the feature or an `Object` with additional configuration.
|
|
49
|
-
*
|
|
50
|
-
* @since 1.0.0
|
|
51
|
-
* @author Simon Kovtyk
|
|
52
|
-
* @category Types
|
|
53
|
-
*/
|
|
54
|
-
type Options = Partial<{
|
|
45
|
+
override: PackageJson;
|
|
55
46
|
/**
|
|
56
47
|
* Options for the `exports` feature of the plugin. See {@link ExportsOption} for more details.
|
|
57
48
|
*
|
|
58
49
|
* @since 1.0.0
|
|
59
50
|
* @author Simon Kovtyk
|
|
60
51
|
*/
|
|
61
|
-
exports: boolean
|
|
52
|
+
exports: boolean;
|
|
62
53
|
/**
|
|
63
54
|
* Options for the `clean` feature of the plugin. See {@link CleanOption} for more details.
|
|
64
55
|
*
|
|
@@ -68,5 +59,5 @@ type Options = Partial<{
|
|
|
68
59
|
clean: boolean | WithEnabled<CleanOption>;
|
|
69
60
|
}>;
|
|
70
61
|
//#endregion
|
|
71
|
-
export { type CleanOption, type
|
|
72
|
-
//# sourceMappingURL=types.d.
|
|
62
|
+
export { type CleanOption, type Options, type WithEnabled };
|
|
63
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","names":[],"sources":["../../src/types.ts"],"mappings":";;;;;AAAwC;;;;;KASnC,WAAA,MAAiB,CAAA;EAAM,OAAA;AAAA;;AAAO;;;;;AAiBvB;KARP,WAAA;;;;;;;;EAQH,UAAA;AAAA;;;;;;;;KAUG,OAAA,GAAU,OAAA;;;;;;;EAOb,QAAA,EAAU,WAAA;;;;;;;EAOV,OAAA;;;;;;;EAOA,KAAA,YAAiB,WAAA,CAAY,WAAA;AAAA"}
|
|
File without changes
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { WithEnabled } from "./types";
|
|
1
|
+
import { WithEnabled } from "./types.js";
|
|
2
2
|
|
|
3
3
|
//#region src/utils.d.ts
|
|
4
4
|
declare function isEnabled<T extends boolean | WithEnabled<unknown> | undefined>(option: T): boolean;
|
|
5
5
|
//#endregion
|
|
6
6
|
export { isEnabled };
|
|
7
|
-
//# sourceMappingURL=utils.d.
|
|
7
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","names":[],"sources":["../../src/utils.ts"],"mappings":";;;iBAES,SAAA,qBAA8B,WAAA,sBAAA,CAAkC,MAAA,EAAQ,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","names":[],"sources":["../../src/utils.ts"],"sourcesContent":["import { WithEnabled } from \"./types.js\";\n\nfunction isEnabled<T extends boolean | WithEnabled<unknown> | undefined>(option: T): boolean {\n if (option === undefined) return false;\n\n if (typeof option === \"boolean\") return option;\n\n return option.enabled;\n}\n\nexport { isEnabled };\n"],"mappings":";AAEA,SAAS,UAAgE,QAAoB;AAC3F,KAAI,WAAW,KAAA,EAAW,QAAO;AAEjC,KAAI,OAAO,WAAW,UAAW,QAAO;AAExC,QAAO,OAAO"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ogs-gmbh/rolldown-plugin-package-json",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "A powerful and flexible plugin for Rolldown that enhances package.json handling.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"build-automation",
|
|
@@ -37,35 +37,32 @@
|
|
|
37
37
|
],
|
|
38
38
|
"repository": "https://github.com/OGS-GmbH/rolldown-plugin-package-json",
|
|
39
39
|
"files": [
|
|
40
|
-
"./dist/main"
|
|
40
|
+
"./dist/main",
|
|
41
|
+
"CHANGELOG.md"
|
|
41
42
|
],
|
|
42
43
|
"type": "module",
|
|
43
44
|
"exports": {
|
|
44
45
|
".": {
|
|
45
46
|
"types": "./dist/main/public-api.d.ts",
|
|
46
|
-
"default": "./dist/main/public-api.
|
|
47
|
+
"default": "./dist/main/public-api.js"
|
|
47
48
|
}
|
|
48
49
|
},
|
|
49
50
|
"dependencies": {
|
|
50
|
-
"es-toolkit": "^1.45.1"
|
|
51
|
+
"es-toolkit": "^1.45.1",
|
|
52
|
+
"rolldown": "1.0.0-rc.12"
|
|
51
53
|
},
|
|
52
54
|
"devDependencies": {
|
|
53
55
|
"@commitlint/cli": "^20.5.0",
|
|
54
56
|
"@commitlint/config-conventional": "^20.5.0",
|
|
55
57
|
"@commitlint/prompt-cli": "^20.5.0",
|
|
56
|
-
"@eslint/json": "^0.14.0",
|
|
57
|
-
"@eslint/markdown": "^7.5.1",
|
|
58
|
-
"@ogs-gmbh/linter": "^2.0.5",
|
|
59
58
|
"@ogs-gmbh/oxlint-presets": "^1.0.4",
|
|
60
59
|
"@ogs-gmbh/vitepress-plugin-sidebar": "^1.0.3",
|
|
61
60
|
"@ogs-gmbh/vitepress-theme": "^1.1.0",
|
|
62
61
|
"@types/node": "^25.5.0",
|
|
63
|
-
"eslint": "^9.39.4",
|
|
64
62
|
"husky": "^9.1.7",
|
|
65
63
|
"lint-staged": "^16.4.0",
|
|
66
64
|
"oxfmt": "^0.42.0",
|
|
67
65
|
"oxlint": "^1.57.0",
|
|
68
|
-
"rolldown": "1.0.0-rc.12",
|
|
69
66
|
"sass-embedded": "^1.98.0",
|
|
70
67
|
"tsdown": "^0.21.7",
|
|
71
68
|
"type-fest": "^5.5.0",
|
|
@@ -81,7 +78,6 @@
|
|
|
81
78
|
"ci:docs:extract:typedoc": "typedoc",
|
|
82
79
|
"ci:docs:main:vitepress": "bash ./.vitepress/scripts/pre-vitepress.sh && vitepress build .vitepress",
|
|
83
80
|
"ci:pr:commitlint:main:commitlint": "commitlint",
|
|
84
|
-
"ci:pr:lint:main:eslint": "eslint .",
|
|
85
81
|
"ci:pr:lint:main:oxfmt": "oxfmt --check",
|
|
86
82
|
"ci:pr:lint:main:oxlint": "oxlint",
|
|
87
83
|
"commit": "commit",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"exports.d.mts","names":[],"sources":["../../src/exports.ts"],"mappings":";;;;iBAgBS,oBAAA,CAAqB,IAAA,EAAM,aAAA,EAAe,MAAA,EAAQ,YAAA,GAAe,WAAA,CAAY,OAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"exports.mjs","names":[],"sources":["../../src/exports.ts"],"sourcesContent":["import path from \"node:path\";\nimport type { OutputBundle, PluginContext } from \"rolldown\";\nimport { PackageJson } from \"type-fest\";\n\nconst fileExtensionToField: Record<string, keyof PackageJson.ExportConditions> = {\n \".js\": \"default\",\n \".mjs\": \"import\",\n \".cjs\": \"require\",\n \".ts\": \"default\",\n \".mts\": \"import\",\n \".cts\": \"require\"\n};\n\nconst declarationMarker = \".d\";\nconst relativeMarker = \"./\";\n\nfunction getExportsFromBundle(this: PluginContext, bundle: OutputBundle): PackageJson.Exports {\n const files: PackageJson.Exports = {};\n\n for (const [name, content] of Object.entries(bundle)) {\n const relativeName = `${relativeMarker}${name}`;\n\n if (content.type === \"asset\") {\n files[relativeName] = relativeName;\n\n continue;\n }\n\n const parsedPath = path.parse(name);\n\n // If we found a declaration file, we need to handle it differently\n if (parsedPath.name.endsWith(declarationMarker)) {\n const relativeVirtualPath = `${relativeMarker}${parsedPath.name.slice(0, -2)}`;\n const currentFile = files[relativeVirtualPath];\n\n files[relativeVirtualPath] = {\n ...(typeof currentFile === \"object\" ? currentFile : {}),\n types: relativeName\n };\n\n continue;\n }\n\n const relativeVirtualPath = `${relativeMarker}${parsedPath.name}`;\n const currentFile = files[relativeVirtualPath];\n const field = fileExtensionToField[parsedPath.ext];\n\n if (field === undefined) {\n this.warn(`Bundle file '${name}' doesn't match any export rule and is ignored.`);\n continue;\n }\n\n files[relativeVirtualPath] = {\n ...(typeof currentFile === \"object\" ? currentFile : {}),\n [field]: relativeName\n };\n }\n\n return files;\n}\n\nexport { getExportsFromBundle };\n"],"mappings":";;AAIA,MAAM,uBAA2E;CAC/E,OAAO;CACP,QAAQ;CACR,QAAQ;CACR,OAAO;CACP,QAAQ;CACR,QAAQ;CACT;AAED,MAAM,oBAAoB;AAC1B,MAAM,iBAAiB;AAEvB,SAAS,qBAA0C,QAA2C;CAC5F,MAAM,QAA6B,EAAE;AAErC,MAAK,MAAM,CAAC,MAAM,YAAY,OAAO,QAAQ,OAAO,EAAE;EACpD,MAAM,eAAe,GAAG,iBAAiB;AAEzC,MAAI,QAAQ,SAAS,SAAS;AAC5B,SAAM,gBAAgB;AAEtB;;EAGF,MAAM,aAAa,KAAK,MAAM,KAAK;AAGnC,MAAI,WAAW,KAAK,SAAS,kBAAkB,EAAE;GAC/C,MAAM,sBAAsB,GAAG,iBAAiB,WAAW,KAAK,MAAM,GAAG,GAAG;GAC5E,MAAM,cAAc,MAAM;AAE1B,SAAM,uBAAuB;IAC3B,GAAI,OAAO,gBAAgB,WAAW,cAAc,EAAE;IACtD,OAAO;IACR;AAED;;EAGF,MAAM,sBAAsB,GAAG,iBAAiB,WAAW;EAC3D,MAAM,cAAc,MAAM;EAC1B,MAAM,QAAQ,qBAAqB,WAAW;AAE9C,MAAI,UAAU,KAAA,GAAW;AACvB,QAAK,KAAK,gBAAgB,KAAK,iDAAiD;AAChF;;AAGF,QAAM,uBAAuB;GAC3B,GAAI,OAAO,gBAAgB,WAAW,cAAc,EAAE;IACrD,QAAQ;GACV;;AAGH,QAAO"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"options.d.mts","names":[],"sources":["../../src/options.ts"],"mappings":";cAAM,sBAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"options.mjs","names":[],"sources":["../../src/options.ts"],"sourcesContent":["const defaultCleanProperties: string[] = [\"scripts\", \"packageManager\", \"publishConfig\"];\n\nexport { defaultCleanProperties };\n"],"mappings":";AAAA,MAAM,yBAAmC;CAAC;CAAW;CAAkB;CAAgB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.mts","names":[],"sources":["../../src/plugin.ts"],"mappings":";;;;;;AAOkC;;;;;;;;iBAezB,iBAAA,CAAkB,OAAA,GAAU,OAAA,GAAU,MAAA"}
|
package/dist/main/plugin.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.mjs","names":[],"sources":["../../src/plugin.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport path from \"node:path\";\nimport { merge } from \"es-toolkit\";\nimport type { NormalizedOutputOptions, OutputBundle, Plugin, PluginContext } from \"rolldown\";\nimport { PackageJson } from \"type-fest\";\nimport { getExportsFromBundle } from \"./exports\";\nimport { defaultCleanProperties } from \"./options\";\nimport { Options } from \"./types\";\nimport { isEnabled } from \"./utils\";\n\nconst fileName: string = \"package.json\";\n\n/**\n * A Rollup plugin that generates a `package.json` file based on your root `package.json` and the generated bundle.\n *\n * @param options - An optional object to configure {@link Options} for the plugin's behavior.\n * @returns A Rollup plugin that generates a `package.json` file.\n *\n * @since 1.0.0\n * @author Simon Kovtyk\n * @category Plugin\n */\nfunction packageJsonPlugin(options?: Options): Plugin {\n const metaPath = path.join(process.cwd(), fileName);\n\n const metaContent = fs.readFileSync(metaPath, { encoding: \"utf8\", flag: \"r\" });\n\n const meta = JSON.parse(metaContent) as PackageJson;\n\n if (isEnabled(options?.clean)) {\n const properties =\n typeof options?.clean === \"boolean\"\n ? defaultCleanProperties\n : options?.clean?.properties\n ? options.clean.properties\n : defaultCleanProperties;\n\n properties.map((property) => {\n delete meta[property];\n });\n }\n\n if (\n isEnabled(options?.exports) &&\n typeof options?.exports !== \"boolean\" &&\n options?.exports?.override\n )\n meta.exports = options.exports.override;\n\n return {\n name: \"package-json-plugin\",\n generateBundle: async function (\n this: PluginContext,\n _outputOptions: NormalizedOutputOptions,\n bundle: OutputBundle\n ): Promise<void> {\n if (\n isEnabled(options?.exports) &&\n (typeof options?.exports === \"boolean\" || options?.exports?.override === undefined)\n ) {\n const generatedExports = getExportsFromBundle.call(this, bundle);\n\n if (meta.exports) {\n // @ts-ignore\n meta.exports = merge(meta.exports, generatedExports);\n } else meta.exports = generatedExports;\n }\n\n const finalMetaContent = JSON.stringify(meta, null, 2);\n\n this.emitFile({\n type: \"asset\",\n fileName,\n originalFileName: metaPath,\n source: finalMetaContent\n });\n },\n buildEnd: function (this: PluginContext) {\n this.info(\"'package.json' successfully created!\");\n }\n };\n}\n\nexport { packageJsonPlugin };\n"],"mappings":";;;;;;;AAUA,MAAM,WAAmB;;;;;;;;;;;AAYzB,SAAS,kBAAkB,SAA2B;CACpD,MAAM,WAAW,KAAK,KAAK,QAAQ,KAAK,EAAE,SAAS;CAEnD,MAAM,cAAc,GAAG,aAAa,UAAU;EAAE,UAAU;EAAQ,MAAM;EAAK,CAAC;CAE9E,MAAM,OAAO,KAAK,MAAM,YAAY;AAEpC,KAAI,UAAU,SAAS,MAAM,CAQ3B,EANE,OAAO,SAAS,UAAU,YACtB,yBACA,SAAS,OAAO,aACd,QAAQ,MAAM,aACd,wBAEG,KAAK,aAAa;AAC3B,SAAO,KAAK;GACZ;AAGJ,KACE,UAAU,SAAS,QAAQ,IAC3B,OAAO,SAAS,YAAY,aAC5B,SAAS,SAAS,SAElB,MAAK,UAAU,QAAQ,QAAQ;AAEjC,QAAO;EACL,MAAM;EACN,gBAAgB,eAEd,gBACA,QACe;AACf,OACE,UAAU,SAAS,QAAQ,KAC1B,OAAO,SAAS,YAAY,aAAa,SAAS,SAAS,aAAa,KAAA,IACzE;IACA,MAAM,mBAAmB,qBAAqB,KAAK,MAAM,OAAO;AAEhE,QAAI,KAAK,QAEP,MAAK,UAAU,MAAM,KAAK,SAAS,iBAAiB;QAC/C,MAAK,UAAU;;GAGxB,MAAM,mBAAmB,KAAK,UAAU,MAAM,MAAM,EAAE;AAEtD,QAAK,SAAS;IACZ,MAAM;IACN;IACA,kBAAkB;IAClB,QAAQ;IACT,CAAC;;EAEJ,UAAU,WAA+B;AACvC,QAAK,KAAK,uCAAuC;;EAEpD"}
|
package/dist/main/public-api.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.mts","names":[],"sources":["../../src/types.ts"],"mappings":";;;;;AAAwC;;;;;KASnC,WAAA,MAAiB,CAAA;EAAM,OAAA;AAAA;;AAAO;;;;;AAiBvB;KARP,WAAA;;;;;;;;EAQH,UAAA;AAAA;;;;;;;;KAUG,aAAA;EAiBU;;;;;;EAVb,QAAA,EAAU,WAAA,CAAY,OAAA;AAAA;;;;;;;;KAUnB,OAAA,GAAU,OAAA;;;;;;;EAOb,OAAA,YAAmB,WAAA,CAAY,aAAA;;;;;;;EAO/B,KAAA,YAAiB,WAAA,CAAY,WAAA;AAAA"}
|
package/dist/main/types.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.mts","names":[],"sources":["../../src/utils.ts"],"mappings":";;;iBAES,SAAA,qBAA8B,WAAA,sBAAA,CAAkC,MAAA,EAAQ,CAAA"}
|
package/dist/main/utils.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils.mjs","names":[],"sources":["../../src/utils.ts"],"sourcesContent":["import { WithEnabled } from \"./types\";\n\nfunction isEnabled<T extends boolean | WithEnabled<unknown> | undefined>(option: T): boolean {\n if (option === undefined) return false;\n\n if (typeof option === \"boolean\") return option;\n\n return option.enabled;\n}\n\nexport { isEnabled };\n"],"mappings":";AAEA,SAAS,UAAgE,QAAoB;AAC3F,KAAI,WAAW,KAAA,EAAW,QAAO;AAEjC,KAAI,OAAO,WAAW,UAAW,QAAO;AAExC,QAAO,OAAO"}
|