@williamthorsen/nmr 0.18.1 → 0.18.2
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/README.md +4 -9
- package/dist/esm/commands/build.js +9 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -3,18 +3,13 @@
|
|
|
3
3
|
Context-aware script runner for PNPM monorepos. Ships an `nmr` (node-monorepo run) binary that provides centralized, consistent script execution across workspace packages and the monorepo root.
|
|
4
4
|
|
|
5
5
|
<!-- section:release-notes -->
|
|
6
|
-
## Release notes — v0.18.
|
|
6
|
+
## Release notes — v0.18.2 (2026-07-18)
|
|
7
7
|
|
|
8
8
|
### 🐛 Bug fixes
|
|
9
9
|
|
|
10
|
-
-
|
|
10
|
+
- Fail the build on aliased imports that escape the package source (#475)
|
|
11
11
|
|
|
12
|
-
Fixes the
|
|
13
|
-
- `nmr clean` failed with a missing-command error in any project that had not separately installed `rimraf`, a tool nmr neither declared nor shipped.
|
|
14
|
-
- If run from a monorepo root, `nmr clean` cleaned one package and then aborted, leaving every other package untouched. Only repos that build nmr from source were affected.
|
|
15
|
-
- If run from a monorepo root, `nmr clean` ignored a package's own `clean` script.
|
|
16
|
-
- `nmr compile` skipped the build for a package whose output had been deleted, because the sources were unchanged. The package compiled to an empty output directory with no error and no warning, and could be published as an empty tarball.
|
|
17
|
-
- `nmr compile` reported missing output and recompiled on every run for a package whose sources emit nothing, such as a source tree of only declaration files.
|
|
12
|
+
Fixes an issue where an aliased import that resolved to a target outside the package's own source (one Node could not reach at runtime) passed the build but produced published output that crashed with a module-not-found error. `nmr-compile` now fails the build and reports the unresolvable import and where it pointed, so the problem surfaces before publish instead of in production. Aliased imports that resolve outside the source but remain genuinely external and runnable continue to build and ship unchanged.
|
|
18
13
|
<!-- /section:release-notes -->
|
|
19
14
|
|
|
20
15
|
## Installation
|
|
@@ -356,7 +351,7 @@ nmr-clean
|
|
|
356
351
|
|
|
357
352
|
### `nmr-compile`
|
|
358
353
|
|
|
359
|
-
Compile a single package's `src` tree to `dist/esm` with the TypeScript compiler API, emitting `.js` and `.d.ts` in one pass. Because the compiler parses each source file, every relative import form — static, re-export, dynamic `import()`, and bare side-effect — is rewritten from `.ts` to `.js` in both outputs, and `.ts` occurrences inside strings and comments are left intact. tsconfig `paths` aliases are resolved to runnable relative `.js` specifiers in both outputs, sourced from the package's tsconfig. The build is skipped when no input has changed and the previous output is still on disk (a content-and-path hash is cached under `node_modules/.cache/nmr-compile/`, outside the published output). Deleting the output by any means — `nmr clean`, `rm -rf dist`, `git clean` — therefore forces a rebuild rather than a skip. This is the default `compile` script — run it from a package directory.
|
|
354
|
+
Compile a single package's `src` tree to `dist/esm` with the TypeScript compiler API, emitting `.js` and `.d.ts` in one pass. Because the compiler parses each source file, every relative import form — static, re-export, dynamic `import()`, and bare side-effect — is rewritten from `.ts` to `.js` in both outputs, and `.ts` occurrences inside strings and comments are left intact. tsconfig `paths` aliases are resolved to runnable relative `.js` specifiers in both outputs, sourced from the package's tsconfig. An aliased import whose target resolves outside the package's `src/` and is not resolvable without the alias mapping fails the build with a diagnostic, rather than being emitted verbatim to produce output that fails at runtime. The build is skipped when no input has changed and the previous output is still on disk (a content-and-path hash is cached under `node_modules/.cache/nmr-compile/`, outside the published output). Deleting the output by any means — `nmr clean`, `rm -rf dist`, `git clean` — therefore forces a rebuild rather than a skip. This is the default `compile` script — run it from a package directory.
|
|
360
355
|
|
|
361
356
|
`typescript` is a peer dependency (`>=5.7.0`, required for `rewriteRelativeImportExtensions`); the consuming repo provides it. Relative imports in source must carry explicit `.ts` extensions for them to be rewritten.
|
|
362
357
|
|
|
@@ -149,7 +149,15 @@ function resolveSpecifierReplacement(specifier, sourceContainingFile, compilerOp
|
|
|
149
149
|
`Verify the tsconfig 'paths' mapping and that the target file exists.`);
|
|
150
150
|
}
|
|
151
151
|
if (!isWithin(sourceRoot, resolved.resolvedFileName)) {
|
|
152
|
-
|
|
152
|
+
const { paths: _paths, baseUrl: _baseUrl, rootDirs: _rootDirs, ...nodeResolutionOptions } = compilerOptions;
|
|
153
|
+
const bareResolved = ts.resolveModuleName(specifier, sourceContainingFile, nodeResolutionOptions, ts.sys).resolvedModule;
|
|
154
|
+
if (bareResolved) {
|
|
155
|
+
return undefined;
|
|
156
|
+
}
|
|
157
|
+
throw new Error(`nmr-compile: aliased import '${specifier}' from ${sourceContainingFile} resolves to ` +
|
|
158
|
+
`${resolved.resolvedFileName}, outside the package source root ${sourceRoot}, and does not resolve ` +
|
|
159
|
+
`the way Node will at runtime, which ignores tsconfig 'paths', 'baseUrl', and 'rootDirs'. The ` +
|
|
160
|
+
`emitted specifier would fail at runtime; re-anchor the alias inside the package.`);
|
|
153
161
|
}
|
|
154
162
|
const relative = toRelativeSpecifier(path.dirname(sourceContainingFile), resolved.resolvedFileName);
|
|
155
163
|
return swapTypeScriptExtension(relative);
|