Skip to content

Commit

Permalink
Packaging tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
Wes Biggs committed Nov 10, 2023
1 parent 5489c3d commit 6275e32
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 5 deletions.
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@
"name": "@dsnp/did-resolver",
"version": "0.0.0",
"description": "A DSNP DID resolver",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"type": "module",
"scripts": {
"build": "tsc",
"build": "npm run clean && tsc",
"postbuild": "npm run package",
"clean": "rm -Rf dist",
"prepackage": "cp CONTRIBUTING.md README.md LICENSE ./dist",
"package": "node --no-warnings scripts/package.js",
"test": "jest",
"format": "tsc --noEmit --pretty && eslint --fix \"**/*.ts\"",
"lint": "tsc --noEmit --pretty && eslint \"**/*.ts\""
Expand Down
27 changes: 27 additions & 0 deletions scripts/package.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/**
* Build the package.json for the actual publishing
*/
// eslint-disable-next-line
import fs from "fs";
import path from "path";
import * as url from 'url';
const __filename = url.fileURLToPath(import.meta.url);
const __dirname = url.fileURLToPath(new URL('.', import.meta.url));

// eslint-disable-next-line
import rootPackage from "../package.json" assert { type: "json" };

// Don't keep scripts
delete rootPackage["scripts"];

// Don't keep dev dependencies
delete rootPackage["devDependencies"];

// Setup the main and types correctly
rootPackage["module"] = "./index.js";
rootPackage["types"] = "index.d.ts";

// Write it out
fs.writeFileSync(`${path.join(__dirname, "../dist", "package.json")}`, JSON.stringify(rootPackage, null, 2), (err) => {
if (err) throw new Error(err);
});
5 changes: 3 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"declaration": true,
"esModuleInterop": true,
"strict": true,
"skipLibCheck": true
"skipLibCheck": true,
"sourceMap": false
},
"exclude": ["node_modules/**", "./test/**", "**/*.test.ts", "./dist/**"]
"exclude": ["node_modules/**", "jest.config.*", "**/*.test.ts", "./dist/**"]
}

0 comments on commit 6275e32

Please sign in to comment.