@ogs-gmbh/rolldown-plugin-package-json 1.0.0 → 1.0.1
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 +19 -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} +4 -7
- 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} +1 -1
- 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 +4 -3
- 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,19 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## [1.0.1](https://github.com/OGS-GmbH/rolldown-plugin-package-json/compare/v1.0.0...v1.0.1) (2026-03-31)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Bug Fixes
|
|
7
|
+
|
|
8
|
+
* neutralize build ([71f0ca7](https://github.com/OGS-GmbH/rolldown-plugin-package-json/commit/71f0ca737eaec4135e81aa2bc2f44f0d7fd5ee6a))
|
|
9
|
+
|
|
10
|
+
## 1.0.0 (2026-03-31)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### ⚠ BREAKING CHANGES
|
|
14
|
+
|
|
15
|
+
* init [skip ci]
|
|
16
|
+
|
|
17
|
+
### Miscellaneous Chores
|
|
18
|
+
|
|
19
|
+
* 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
|
/**
|
|
@@ -42,13 +42,10 @@ function packageJsonPlugin(options) {
|
|
|
42
42
|
originalFileName: metaPath,
|
|
43
43
|
source: finalMetaContent
|
|
44
44
|
});
|
|
45
|
-
},
|
|
46
|
-
buildEnd: function() {
|
|
47
|
-
this.info("'package.json' successfully created!");
|
|
48
45
|
}
|
|
49
46
|
};
|
|
50
47
|
}
|
|
51
48
|
//#endregion
|
|
52
49
|
export { packageJsonPlugin };
|
|
53
50
|
|
|
54
|
-
//# sourceMappingURL=plugin.
|
|
51
|
+
//# 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\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 };\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;;EAEL"}
|
|
@@ -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,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"}
|
|
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.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "A powerful and flexible plugin for Rolldown that enhances package.json handling.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"build-automation",
|
|
@@ -37,13 +37,14 @@
|
|
|
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": {
|
|
@@ -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"}
|