nf3 0.3.12 → 0.3.13

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.
@@ -199,7 +199,10 @@ async function traceNodeModules(input, opts) {
199
199
  if (opts.chmod) await fsp.chmod(dst, opts.chmod === true ? 420 : opts.chmod);
200
200
  }
201
201
  const pkgJSON = pkg.versions[version].pkgJSON;
202
- applyProductionCondition(pkgJSON.exports);
202
+ if (pkgJSON.exports) {
203
+ pkgJSON.exports = JSON.parse(JSON.stringify(pkgJSON.exports));
204
+ applyProductionCondition(pkgJSON.exports);
205
+ }
203
206
  const pkgJSONPath = join(outDir, pkgPath, "package.json");
204
207
  await fsp.mkdir(dirname(pkgJSONPath), { recursive: true });
205
208
  await fsp.writeFile(pkgJSONPath, JSON.stringify(pkgJSON, null, 2), "utf8");
@@ -243,8 +246,9 @@ async function traceNodeModules(input, opts) {
243
246
  }));
244
247
  for (const [pkgName, pkgVersions] of Object.entries(multiVersionPkgs)) {
245
248
  const versionEntries = Object.entries(pkgVersions).sort(([v1, p1], [v2, p2]) => {
246
- if (p1.length === 0) return -1;
247
- if (p2.length === 0) return 1;
249
+ const d1 = p1.length === 0 ? Infinity : p1.length;
250
+ const d2 = p2.length === 0 ? Infinity : p2.length;
251
+ if (d1 !== d2) return d2 - d1;
248
252
  return compareVersions(v1, v2);
249
253
  });
250
254
  for (const [version, parentPkgs] of versionEntries) {
@@ -275,7 +279,10 @@ function applyProductionCondition(exports) {
275
279
  if (!exports || typeof exports === "string" || Array.isArray(exports)) return;
276
280
  if ("production" in exports) if (typeof exports.production === "string") exports.default = exports.production;
277
281
  else Object.assign(exports, exports.production);
278
- for (const key in exports) applyProductionCondition(exports[key]);
282
+ for (const key in exports) {
283
+ if (key === "production") continue;
284
+ applyProductionCondition(exports[key]);
285
+ }
279
286
  }
280
287
  function resolveFullTraceEntry(entries, pkgName) {
281
288
  if (!entries) return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nf3",
3
- "version": "0.3.12",
3
+ "version": "0.3.13",
4
4
  "description": "",
5
5
  "license": "MIT",
6
6
  "repository": "unjs/nf3",