@b9g/libuild 0.1.17 → 0.1.18

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/src/libuild.js CHANGED
@@ -844,22 +844,14 @@ async function cleanPackageJSON(pkg, mainEntry, options, cwd, distDir) {
844
844
  "types",
845
845
  "files",
846
846
  "sideEffects",
847
- "browserslist"
847
+ "browserslist",
848
+ "private"
848
849
  ];
849
850
  const pathFields = ["files", "types", "scripts"];
850
851
  for (const field of fieldsToKeep) {
851
852
  if (pkg[field] !== void 0) {
852
853
  if (field === "scripts") {
853
- const npmLifecycleScripts = ["postinstall", "preinstall", "install", "preuninstall", "postuninstall", "shrinkwrap"];
854
- const filteredScripts = {};
855
- for (const [scriptName, scriptValue] of Object.entries(pkg[field] || {})) {
856
- if (npmLifecycleScripts.includes(scriptName)) {
857
- filteredScripts[scriptName] = scriptValue;
858
- }
859
- }
860
- if (Object.keys(filteredScripts).length > 0) {
861
- cleaned[field] = transformSrcToDist(filteredScripts);
862
- }
854
+ continue;
863
855
  } else if (field === "bin") {
864
856
  cleaned[field] = transformBinPaths(pkg[field]);
865
857
  } else if (pathFields.includes(field)) {
@@ -925,9 +917,10 @@ async function build2(cwd, save = false) {
925
917
  if (pkg.bin) {
926
918
  await validateBinPaths(pkg.bin, cwd, save, "bin");
927
919
  }
928
- if (!pkg.private) {
929
- console.warn("\u26A0\uFE0F WARNING: Root package.json is not private - this could lead to accidental publishing of development package.json");
930
- console.warn(" Consider setting 'private: true' in your root package.json");
920
+ const hasPublishGuard = pkg.private || pkg.scripts?.prepublishOnly?.includes("exit 1");
921
+ if (!hasPublishGuard && !save) {
922
+ console.warn("\u26A0\uFE0F WARNING: Root package.json lacks publish protection - this could lead to accidental publishing");
923
+ console.warn(" Run 'libuild build --save' to add publish protection, or manually add a prepublishOnly script");
931
924
  }
932
925
  const gitignorePath = Path3.join(cwd, ".gitignore");
933
926
  if (await fileExists(gitignorePath)) {
@@ -1015,8 +1008,10 @@ async function build2(cwd, save = false) {
1015
1008
  throw error;
1016
1009
  }
1017
1010
  const externalDeps = [
1018
- "*.json"
1011
+ "*.json",
1019
1012
  // Let Node.js handle JSON imports natively
1013
+ "esbuild"
1014
+ // Explicit external to suppress require.resolve warning from esbuild's own code
1020
1015
  ];
1021
1016
  const entryPoints = [];
1022
1017
  const umdEntries = [];
@@ -1299,7 +1294,10 @@ async function build2(cwd, save = false) {
1299
1294
  if (save) {
1300
1295
  console.info(" Updating root package.json...");
1301
1296
  const rootPkg2 = { ...pkg };
1302
- rootPkg2.private = true;
1297
+ if (!rootPkg2.scripts) {
1298
+ rootPkg2.scripts = {};
1299
+ }
1300
+ rootPkg2.scripts.prepublishOnly = "echo 'ERROR: Cannot publish from root directory. Use libuild publish instead.' && exit 1";
1303
1301
  if (options.formats.cjs) {
1304
1302
  rootPkg2.main = `./dist/src/${mainEntry}.cjs`;
1305
1303
  }