@b9g/libuild 0.1.16 → 0.1.17
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/CHANGELOG.md +8 -0
- package/package.json +1 -1
- package/src/libuild.cjs +16 -6
- package/src/libuild.js +16 -6
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
|
|
5
|
+
## [0.1.17] - 2025-01-25
|
|
6
|
+
|
|
7
|
+
### Added
|
|
8
|
+
- **Ambient .d.ts file copying** - Hand-written ambient TypeScript declaration files (e.g., global.d.ts with `declare module` statements) are now automatically copied from src/ to dist/src/ during build. These files are automatically discovered by TypeScript when the package is consumed, providing global type declarations for module augmentation.
|
|
9
|
+
|
|
10
|
+
### Fixed
|
|
11
|
+
- **Non-deterministic export field ordering** - Fixed issue where package.json exports fields (types/import/require) would reorder non-deterministically across rebuilds with --save flag, causing unnecessary git diffs. All builds now consistently use types-first ordering.
|
|
12
|
+
|
|
5
13
|
## [0.1.16] - 2025-01-14
|
|
6
14
|
|
|
7
15
|
### Added
|
package/package.json
CHANGED
package/src/libuild.cjs
CHANGED
|
@@ -215411,20 +215411,17 @@ async function generateExports(entries, mainEntry, options, existingExports = {}
|
|
|
215411
215411
|
async function createExportEntry(entry) {
|
|
215412
215412
|
if (entry.startsWith("bin/")) {
|
|
215413
215413
|
const binEntry = entry.replace("bin/", "");
|
|
215414
|
-
const exportEntry = {
|
|
215415
|
-
import: `./bin/${binEntry}.js`
|
|
215416
|
-
};
|
|
215414
|
+
const exportEntry = {};
|
|
215417
215415
|
if (distDir) {
|
|
215418
215416
|
const dtsPath = Path3.join(distDir, "bin", `${binEntry}.d.ts`);
|
|
215419
215417
|
if (await fileExists(dtsPath)) {
|
|
215420
215418
|
exportEntry.types = `./bin/${binEntry}.d.ts`;
|
|
215421
215419
|
}
|
|
215422
215420
|
}
|
|
215421
|
+
exportEntry.import = `./bin/${binEntry}.js`;
|
|
215423
215422
|
return exportEntry;
|
|
215424
215423
|
} else {
|
|
215425
|
-
const exportEntry = {
|
|
215426
|
-
import: `./src/${entry}.js`
|
|
215427
|
-
};
|
|
215424
|
+
const exportEntry = {};
|
|
215428
215425
|
if (distDir) {
|
|
215429
215426
|
const dtsPath = Path3.join(distDir, "src", `${entry}.d.ts`);
|
|
215430
215427
|
const exists = await fileExists(dtsPath);
|
|
@@ -215432,6 +215429,7 @@ async function generateExports(entries, mainEntry, options, existingExports = {}
|
|
|
215432
215429
|
exportEntry.types = `./src/${entry}.d.ts`;
|
|
215433
215430
|
}
|
|
215434
215431
|
}
|
|
215432
|
+
exportEntry.import = `./src/${entry}.js`;
|
|
215435
215433
|
if (options.formats.cjs) {
|
|
215436
215434
|
exportEntry.require = `./src/${entry}.cjs`;
|
|
215437
215435
|
}
|
|
@@ -216240,6 +216238,18 @@ async function build2(cwd, save = false) {
|
|
|
216240
216238
|
await FS3.copyFile(srcPath, Path3.join(distDir, file));
|
|
216241
216239
|
}
|
|
216242
216240
|
}
|
|
216241
|
+
if (await fileExists(srcDir)) {
|
|
216242
|
+
const srcFiles = await FS3.readdir(srcDir);
|
|
216243
|
+
const ambientDtsFiles = srcFiles.filter((f) => f.endsWith(".d.ts"));
|
|
216244
|
+
if (ambientDtsFiles.length > 0) {
|
|
216245
|
+
console.info(` Copying ${ambientDtsFiles.length} ambient .d.ts file(s)...`);
|
|
216246
|
+
for (const dtsFile of ambientDtsFiles) {
|
|
216247
|
+
const srcPath = Path3.join(srcDir, dtsFile);
|
|
216248
|
+
const destPath = Path3.join(distSrcDir, dtsFile);
|
|
216249
|
+
await FS3.copyFile(srcPath, destPath);
|
|
216250
|
+
}
|
|
216251
|
+
}
|
|
216252
|
+
}
|
|
216243
216253
|
const commonFiles = ["README.md", "LICENSE", "CHANGELOG.md", "COPYING", "AUTHORS"];
|
|
216244
216254
|
if (pkg.files && Array.isArray(pkg.files)) {
|
|
216245
216255
|
for (const commonFile of commonFiles) {
|
package/src/libuild.js
CHANGED
|
@@ -398,20 +398,17 @@ async function generateExports(entries, mainEntry, options, existingExports = {}
|
|
|
398
398
|
async function createExportEntry(entry) {
|
|
399
399
|
if (entry.startsWith("bin/")) {
|
|
400
400
|
const binEntry = entry.replace("bin/", "");
|
|
401
|
-
const exportEntry = {
|
|
402
|
-
import: `./bin/${binEntry}.js`
|
|
403
|
-
};
|
|
401
|
+
const exportEntry = {};
|
|
404
402
|
if (distDir) {
|
|
405
403
|
const dtsPath = Path3.join(distDir, "bin", `${binEntry}.d.ts`);
|
|
406
404
|
if (await fileExists(dtsPath)) {
|
|
407
405
|
exportEntry.types = `./bin/${binEntry}.d.ts`;
|
|
408
406
|
}
|
|
409
407
|
}
|
|
408
|
+
exportEntry.import = `./bin/${binEntry}.js`;
|
|
410
409
|
return exportEntry;
|
|
411
410
|
} else {
|
|
412
|
-
const exportEntry = {
|
|
413
|
-
import: `./src/${entry}.js`
|
|
414
|
-
};
|
|
411
|
+
const exportEntry = {};
|
|
415
412
|
if (distDir) {
|
|
416
413
|
const dtsPath = Path3.join(distDir, "src", `${entry}.d.ts`);
|
|
417
414
|
const exists = await fileExists(dtsPath);
|
|
@@ -419,6 +416,7 @@ async function generateExports(entries, mainEntry, options, existingExports = {}
|
|
|
419
416
|
exportEntry.types = `./src/${entry}.d.ts`;
|
|
420
417
|
}
|
|
421
418
|
}
|
|
419
|
+
exportEntry.import = `./src/${entry}.js`;
|
|
422
420
|
if (options.formats.cjs) {
|
|
423
421
|
exportEntry.require = `./src/${entry}.cjs`;
|
|
424
422
|
}
|
|
@@ -1227,6 +1225,18 @@ async function build2(cwd, save = false) {
|
|
|
1227
1225
|
await FS3.copyFile(srcPath, Path3.join(distDir, file));
|
|
1228
1226
|
}
|
|
1229
1227
|
}
|
|
1228
|
+
if (await fileExists(srcDir)) {
|
|
1229
|
+
const srcFiles = await FS3.readdir(srcDir);
|
|
1230
|
+
const ambientDtsFiles = srcFiles.filter((f) => f.endsWith(".d.ts"));
|
|
1231
|
+
if (ambientDtsFiles.length > 0) {
|
|
1232
|
+
console.info(` Copying ${ambientDtsFiles.length} ambient .d.ts file(s)...`);
|
|
1233
|
+
for (const dtsFile of ambientDtsFiles) {
|
|
1234
|
+
const srcPath = Path3.join(srcDir, dtsFile);
|
|
1235
|
+
const destPath = Path3.join(distSrcDir, dtsFile);
|
|
1236
|
+
await FS3.copyFile(srcPath, destPath);
|
|
1237
|
+
}
|
|
1238
|
+
}
|
|
1239
|
+
}
|
|
1230
1240
|
const commonFiles = ["README.md", "LICENSE", "CHANGELOG.md", "COPYING", "AUTHORS"];
|
|
1231
1241
|
if (pkg.files && Array.isArray(pkg.files)) {
|
|
1232
1242
|
for (const commonFile of commonFiles) {
|