@_linked/server 2.24.9 → 2.24.11
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 +12 -0
- package/lib/esm/shapes/LinkedServer.js +21 -10
- package/lib/esm/shapes/LinkedServer.js.map +1 -1
- package/lib/esm/utils/linkedDependencies.d.ts +35 -0
- package/lib/esm/utils/linkedDependencies.js +109 -13
- package/lib/esm/utils/linkedDependencies.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @\_linked/server
|
|
2
2
|
|
|
3
|
+
## 2.24.11
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#175](https://github.com/linked-fw/server/pull/175) [`37318c4`](https://github.com/linked-fw/server/commit/37318c468ea9d18a33aa44dd441899e8fb0fbf8b) Thanks [@flyon](https://github.com/flyon)! - In dev, a source workspace's backend is found from `src/` (`src/backend.tsx`, `src/backend.ts`, or its `exports` target mapped from `lib/esm` back to `src`), the way linked's Vite resolver loads it. An unbuilt workspace, whose `exports` name only `lib/esm`, no longer has its `src/backend.ts` silently skipped. Published packages and production are unchanged.
|
|
8
|
+
|
|
9
|
+
## 2.24.10
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [#173](https://github.com/linked-fw/server/pull/173) [`3181adf`](https://github.com/linked-fw/server/commit/3181adfdd7609f32c6866e3733580b8059c2ce9e) Thanks [@flyon](https://github.com/flyon)! - At boot the server no longer tries to import a workspace linked package that has no JavaScript entry (no `main`, `module` or root `exports`), such as the pure-CSS `@_linked/css`. Before, a pure-CSS package checked out as a workspace member logged `Error loading '…': Failed to resolve entry for package` on every start. The new `hasModuleEntry(packageJson)` in `utils/linkedDependencies` makes that decision.
|
|
14
|
+
|
|
3
15
|
## 2.24.9
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
|
@@ -41,7 +41,7 @@ import { getShapeClass, getSuperShapesClasses, } from '@_linked/core/utils/Shape
|
|
|
41
41
|
import path from 'path';
|
|
42
42
|
import { pathToFileURL } from 'node:url';
|
|
43
43
|
import { isFatalError } from '../utils/fatalError.js';
|
|
44
|
-
import { discoverLinkedDependencies, isBundledBySsr, NODE_IMPORT_CONDITIONS, readInstalledPackage, resolveBackendEntry, ssrNoExternalOf, } from '../utils/linkedDependencies.js';
|
|
44
|
+
import { discoverLinkedDependencies, hasModuleEntry, isBundledBySsr, NODE_IMPORT_CONDITIONS, readInstalledPackage, resolveBackendEntry, resolveDevBackendEntry, ssrNoExternalOf, } from '../utils/linkedDependencies.js';
|
|
45
45
|
/**
|
|
46
46
|
* `instanceof ShapeProvider`, tolerating a second copy of server-utils.
|
|
47
47
|
*
|
|
@@ -1165,10 +1165,20 @@ let LinkedServer = class LinkedServer extends Shape {
|
|
|
1165
1165
|
res.type(extension || 'bin').send(resized);
|
|
1166
1166
|
}
|
|
1167
1167
|
async indexLincdPackage(pkg, warnIfNotFound = false) {
|
|
1168
|
-
var _a;
|
|
1168
|
+
var _a, _b;
|
|
1169
1169
|
if (pkg === this.package.name) {
|
|
1170
1170
|
return;
|
|
1171
1171
|
}
|
|
1172
|
+
// A pure-CSS linked package has nothing to import whole.
|
|
1173
|
+
const dir = (_a = this.linkedPackageDirs) === null || _a === void 0 ? void 0 : _a.get(pkg);
|
|
1174
|
+
if (dir) {
|
|
1175
|
+
try {
|
|
1176
|
+
const json = JSON.parse(fsNative.readFileSync(path.join(dir, 'package.json'), 'utf-8'));
|
|
1177
|
+
if (!hasModuleEntry(json))
|
|
1178
|
+
return;
|
|
1179
|
+
}
|
|
1180
|
+
catch (_c) { }
|
|
1181
|
+
}
|
|
1172
1182
|
try {
|
|
1173
1183
|
// console.log(`🔍 Loading package: ${pkg}`);
|
|
1174
1184
|
// console.log(
|
|
@@ -1182,7 +1192,7 @@ let LinkedServer = class LinkedServer extends Shape {
|
|
|
1182
1192
|
// SECOND core copy (benign post-§P1, but a needless second instance).
|
|
1183
1193
|
// Node import stays as the fallback when Vite isn't active (production /
|
|
1184
1194
|
// Node-only CLI commands). Mirrors indexPackageBackendProviders.
|
|
1185
|
-
const vite = (
|
|
1195
|
+
const vite = (_b = this.config.server) === null || _b === void 0 ? void 0 : _b.vite;
|
|
1186
1196
|
if (vite && typeof vite.ssrLoadModule === 'function') {
|
|
1187
1197
|
await vite.ssrLoadModule(pkg);
|
|
1188
1198
|
}
|
|
@@ -1278,14 +1288,15 @@ let LinkedServer = class LinkedServer extends Shape {
|
|
|
1278
1288
|
}
|
|
1279
1289
|
if (dir && json) {
|
|
1280
1290
|
if (viteOwnsPackage) {
|
|
1281
|
-
//
|
|
1282
|
-
//
|
|
1283
|
-
//
|
|
1291
|
+
// A source package (one with src/) is a workspace to linked's Vite
|
|
1292
|
+
// config, whose resolver maps `<pkg>/backend` to src BEFORE
|
|
1293
|
+
// `exports` (resolveDevBackendEntry mirrors it). Checking only
|
|
1294
|
+
// `exports` missed an unbuilt workspace, whose `exports` name only
|
|
1295
|
+
// lib/esm: its src/backend.ts was never loaded. Otherwise Vite
|
|
1296
|
+
// resolves a bundled package with the `development` condition. It
|
|
1297
|
+
// is still loaded by its bare name, so it is the same module id the
|
|
1284
1298
|
// rest of the SSR graph imports.
|
|
1285
|
-
entry =
|
|
1286
|
-
'development',
|
|
1287
|
-
...NODE_IMPORT_CONDITIONS,
|
|
1288
|
-
]);
|
|
1299
|
+
entry = resolveDevBackendEntry(dir, json);
|
|
1289
1300
|
if (entry)
|
|
1290
1301
|
load = () => vite.ssrLoadModule(`${pkg}/backend`);
|
|
1291
1302
|
}
|