npm pack # or npm publish
tar -Oxf blah-1.0.0.tgz package/package.json
# {
# "name": "blah",
# "version": "1.0.0",
# "type": "module",
# "exports": {
# ".": {
# "types": "./dist/index.d.ts",
# "import": "./dist/index.mjs"
# }
# },
# "scripts": {
# "backup": "node backup.js",
# "prepack": "npm run backup && node prepack.js",
# "postpack": "node postpack.js"
# }
# }
-
-
Save manzt/621fe167e0c7f3764b94e7135951653d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as fs from "node:fs"; | |
fs.writeFileSync("./package.json.backup", fs.readFileSync("./package.json")); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "blah", | |
"version": "1.0.0", | |
"type": "module", | |
"exports": { | |
".": { | |
"types": "index.d.ts", | |
"import": "index.js" | |
} | |
}, | |
"scripts": { | |
"backup": "node backup.js", | |
"prepack": "npm run backup && node prepack.js", | |
"postpack": "node postpack.js" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as fs from "node:fs"; | |
const backup = fs.readFileSync("./package.json.backup"); | |
fs.writeFileSync("./package.json", backup); | |
fs.unlinkSync("./package.json.backup"); // delete backup file |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as fs from "node:fs"; | |
const contents = JSON.parse(fs.readFileSync("./package.json", { encoding: "utf8" })); | |
contents.exports["."] = { | |
"types": "./dist/index.d.ts", | |
"import": "./dist/index.mjs" | |
} | |
fs.writeFileSync("./package.json", JSON.stringify(contents, null, 2)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment