@b9g/libuild 0.1.21 → 0.1.22

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 CHANGED
@@ -2,6 +2,11 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file.
4
4
 
5
+ ## [0.1.22] - 2025-12-22
6
+
7
+ ### Fixed
8
+ - **Bin imports from src polluting source tree** - Fixed .d.ts files being emitted to source directories when bin entries import from `../src/`. This caused lint failures and polluted the src/ folder. Fixes [#2](https://github.com/bikeshaving/libuild/issues/2).
9
+
5
10
  ## [0.1.21] - 2025-12-22
6
11
 
7
12
  ### Fixed
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@b9g/libuild",
3
- "version": "0.1.21",
3
+ "version": "0.1.22",
4
4
  "description": "Zero-config library builds",
5
5
  "keywords": [
6
6
  "build",
package/src/libuild.cjs CHANGED
@@ -212725,15 +212725,15 @@ function dtsPlugin(options) {
212725
212725
  } catch (error) {
212726
212726
  return;
212727
212727
  }
212728
- const tsFiles = entryFiles.filter((file) => file.endsWith(".ts") && !file.endsWith(".d.ts"));
212729
- if (tsFiles.length === 0) {
212730
- return;
212731
- }
212732
212728
  await FS2.mkdir(options.outDir, { recursive: true });
212733
212729
  const fs = await import("fs");
212734
212730
  const resolvedRootDir = fs.realpathSync(options.rootDir);
212735
212731
  const resolvedOutDir = fs.realpathSync(options.outDir);
212736
- const resolvedTsFiles = tsFiles.map((f) => fs.realpathSync(f));
212732
+ const tsFiles = entryFiles.filter((file) => file.endsWith(".ts") && !file.endsWith(".d.ts")).map((f) => fs.realpathSync(f)).filter((f) => f.startsWith(resolvedRootDir + Path2.sep));
212733
+ if (tsFiles.length === 0) {
212734
+ return;
212735
+ }
212736
+ const resolvedTsFiles = tsFiles;
212737
212737
  try {
212738
212738
  const compilerOptions = {
212739
212739
  declaration: true,
@@ -212747,7 +212747,13 @@ function dtsPlugin(options) {
212747
212747
  moduleResolution: TS.ModuleResolutionKind.Bundler
212748
212748
  };
212749
212749
  const program = TS.createProgram(resolvedTsFiles, compilerOptions);
212750
- const emitResult = program.emit();
212750
+ const writeFile4 = (fileName, data, writeByteOrderMark, onError, sourceFiles) => {
212751
+ if (!fileName.startsWith(resolvedOutDir + Path2.sep)) {
212752
+ return;
212753
+ }
212754
+ TS.sys.writeFile(fileName, data, writeByteOrderMark);
212755
+ };
212756
+ const emitResult = program.emit(void 0, writeFile4);
212751
212757
  if (emitResult.diagnostics.length > 0) {
212752
212758
  const diagnostics = TS.formatDiagnosticsWithColorAndContext(emitResult.diagnostics, {
212753
212759
  getCanonicalFileName: (path) => path,
package/src/libuild.js CHANGED
@@ -110,15 +110,15 @@ function dtsPlugin(options) {
110
110
  } catch (error) {
111
111
  return;
112
112
  }
113
- const tsFiles = entryFiles.filter((file) => file.endsWith(".ts") && !file.endsWith(".d.ts"));
114
- if (tsFiles.length === 0) {
115
- return;
116
- }
117
113
  await FS2.mkdir(options.outDir, { recursive: true });
118
114
  const fs = await import("fs");
119
115
  const resolvedRootDir = fs.realpathSync(options.rootDir);
120
116
  const resolvedOutDir = fs.realpathSync(options.outDir);
121
- const resolvedTsFiles = tsFiles.map((f) => fs.realpathSync(f));
117
+ const tsFiles = entryFiles.filter((file) => file.endsWith(".ts") && !file.endsWith(".d.ts")).map((f) => fs.realpathSync(f)).filter((f) => f.startsWith(resolvedRootDir + Path2.sep));
118
+ if (tsFiles.length === 0) {
119
+ return;
120
+ }
121
+ const resolvedTsFiles = tsFiles;
122
122
  try {
123
123
  const compilerOptions = {
124
124
  declaration: true,
@@ -132,7 +132,13 @@ function dtsPlugin(options) {
132
132
  moduleResolution: TS.ModuleResolutionKind.Bundler
133
133
  };
134
134
  const program = TS.createProgram(resolvedTsFiles, compilerOptions);
135
- const emitResult = program.emit();
135
+ const writeFile4 = (fileName, data, writeByteOrderMark, onError, sourceFiles) => {
136
+ if (!fileName.startsWith(resolvedOutDir + Path2.sep)) {
137
+ return;
138
+ }
139
+ TS.sys.writeFile(fileName, data, writeByteOrderMark);
140
+ };
141
+ const emitResult = program.emit(void 0, writeFile4);
136
142
  if (emitResult.diagnostics.length > 0) {
137
143
  const diagnostics = TS.formatDiagnosticsWithColorAndContext(emitResult.diagnostics, {
138
144
  getCanonicalFileName: (path) => path,