cloudflare/cloudflare-typescript

Public

mirrored fromhttps://github.com/cloudflare/cloudflare-typescriptAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
generated-2c44b1b60a

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

scripts/make-dist-package-json.cjs

21lines · modecode

1const pkgJson = require(process.env['PKG_JSON_PATH'] || '../package.json');
2
3function processExportMap(m) {
4 for (const key in m) {
5 const value = m[key];
6 if (typeof value === 'string') m[key] = value.replace(/^\.\/dist\//, './');
7 else processExportMap(value);
8 }
9}
10processExportMap(pkgJson.exports);
11
12for (const key of ['types', 'main', 'module']) {
13 if (typeof pkgJson[key] === 'string') pkgJson[key] = pkgJson[key].replace(/^(\.\/)?dist\//, './');
14}
15
16delete pkgJson.devDependencies;
17delete pkgJson.scripts.prepack;
18delete pkgJson.scripts.prepublishOnly;
19delete pkgJson.scripts.prepare;
20
21console.log(JSON.stringify(pkgJson, null, 2));
22