@_linked/cli 1.12.0 → 1.13.0

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
@@ -1,5 +1,26 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.13.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#79](https://github.com/linked-cm/cli/pull/79) [`fd27a8d`](https://github.com/linked-cm/cli/commit/fd27a8d827b591c2d6db6bd2a7db1aa1de94b71d) Thanks [@flyon](https://github.com/flyon)! - Add `linked start --api-only` for a Linked backend without a web frontend.
8
+
9
+ - No `vite.config.*` is required: without one, Vite runs with the `createViteConfig()` defaults inline, so TypeScript, decorators and extensionless imports in source-only shape packages still work.
10
+ - No `src/App.tsx` or `src/routes.tsx` is loaded. The CLI sets `server.apiOnly` on the LinkedServer config instead of the page rendering hooks, so `/call/...` and `/api/...` routes are served and page requests get a 404 (needs a `@_linked/server` release that honours `server.apiOnly`).
11
+ - The mode is explicit and never inferred from missing files. `server.apiOnly: true` in `linked.config.js` turns it on too.
12
+ - `LinkedServerConfig` gains the `apiOnly` field.
13
+
14
+ Add `"linked": {"extensionlessImports": true}` to a package's `package.json` for packages whose source uses extensionless relative imports (for example, shapes shared with React Native, where Metro does not map `.js` specifiers to `.ts` source).
15
+
16
+ - `linked build` skips the "Checking imports" step for that package and logs that it did.
17
+ - After compiling ESM, it appends `.js` (or `/index.js` for a directory) to extensionless `./` and `../` specifiers of static imports, exports and `import()` calls in `lib/esm/**/*.js`, so the output loads under Node. Specifiers it cannot resolve are left unchanged with a warning. `.d.ts` files are not rewritten.
18
+ - Packages without the field build exactly as before.
19
+
20
+ Fix linked-package discovery in `linked start` for apps inside an npm/yarn workspaces monorepo: dependencies are now resolved the way Node resolves them, walking up parent `node_modules` directories to the workspace root. A linked package hoisted to the root `node_modules` is found, so the app no longer falls into standalone mode (which dropped the `development` export condition).
21
+
22
+ In workspace mode, `linked start` now bundles only the discovered source workspaces through Vite SSR (`ssr.noExternal`). Published framework packages installed in `node_modules` (such as `@_linked/core`) stay external and load through Node. Before, every `@_linked/*` package was force-bundled, so Vite ran its own `@_linked/core` while a store loaded by core's `loadStores` through a native `import()` (for example `@_linked/fuseki/shapes/FusekiStore`) pulled in a second, Node-loaded core. That split the shape registry ("Cannot resolve an rdf:type for shape"). An installed package that depends (directly or transitively, through `dependencies` or `peerDependencies`) on a discovered workspace is bundled too. For example, when `@_linked/core` is itself a source workspace, a published `@_linked/fuseki` goes through Vite and uses the same core. Only the dependency closure of the app and its workspaces is scanned.
23
+
3
24
  ## 1.12.0
4
25
 
5
26
  ### Minor Changes
@@ -89,6 +89,11 @@ export declare const upgradePackages: () => Promise<void>;
89
89
  export declare const createPackage: (name: any, uriBase?: any, basePath?: string) => Promise<void>;
90
90
  export declare const register: (registryURL: any) => Promise<void>;
91
91
  export declare const buildPackage: (target: any, target2: any, packagePath?: string, logResults?: boolean) => Promise<any>;
92
+ type BuildStep = {
93
+ name: string;
94
+ apply: () => Promise<unknown>;
95
+ };
96
+ export declare const planBuildSteps: (pkgJson: any, packagePath: string) => BuildStep[];
92
97
  export declare const compilePackage: (packagePath?: string) => Promise<void>;
93
98
  export declare const compilePackageESM: (packagePath?: string) => Promise<boolean>;
94
99
  export declare const compilePackageCJS: (packagePath?: string) => Promise<boolean | {
@@ -1 +1 @@
1
- {"version":3,"file":"cli-methods.d.ts","sourceRoot":"","sources":["../../src/cli-methods.ts"],"names":[],"mappings":"AA2BA,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,iBAAiB,CAAC;AAgBpD;;;;;;GAMG;AAKH,OAAO,EACL,uBAAuB,EACvB,wBAAwB,EACxB,gBAAgB,EACjB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAC,uBAAuB,EAAE,wBAAwB,EAAE,gBAAgB,EAAC,CAAC;AAoB7E,MAAM,MAAM,WAAW,GAAG,KAAK,GAAG,cAAc,CAAC;AAEjD,KAAK,WAAW,GAAG;IACjB,O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,EACL,oBAAe,oBA6DhB,CAAC;AAEF,eAAO,IAAI,YAAY,GACrB,SAAI,EACJ,WAAM,EACN,YAAO,EACP,wBAAuB,OAAe,EACtC,OAAM,OAAe,kBAqHtB,CAAC;AAeF,eAAO,IAAI,4BAA4B,GACrC,aAAQ,EACR,YAAO,EACP,iBAAY,EACZ,gBAAW,qBA4CZ,CAAC;AAOF,eAAO,IAAI,cAAc,GAAa,aAAQ,EAAE,YAAO,SAMtD,CAAC;AACF,eAAO,IAAI,YAAY,GAAmB,iBAAwB,kBA8FjE,CAAC;AAEF,eAAO,IAAI,wBAAwB,GAAa,gBAAW,EAAE,YAAO,SA6BnE,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,cAAc,GAAU,gBAAW,qBA8B/C,CAAC"}
@@ -17,6 +17,7 @@ import { createInterface } from 'readline';
17
17
  import { debugInfo, execp, execPromise, getFileImports, getFiles, getLastCommitTime, getPackageJSON, isImportOutsideOfPackage, isImportWithMissingExtension, isInvalidLINCDImport, needsRebuilding, } from './utils.js';
18
18
  import { renameShippedDotfiles } from './utils/shippedDotfiles.js';
19
19
  import { planPackageSetup } from './utils/packageSetup.js';
20
+ import { rewriteExtensionlessImports } from './utils/esmSpecifiers.js';
20
21
  import { spawn as spawnChild } from 'child_process';
21
22
  import { findNearestPackageJson } from 'find-nearest-package-json';
22
23
  import { statSync } from 'fs';
@@ -2180,6 +2181,7 @@ export const register = function (registryURL) {
2180
2181
  }
2181
2182
  };
2182
2183
  export const buildPackage = (target_1, target2_1, ...args_1) => __awaiter(void 0, [target_1, target2_1, ...args_1], void 0, function* (target, target2, packagePath = process.cwd(), logResults = true) {
2184
+ var _a;
2183
2185
  // Ensure packagePath is absolute and points to a directory containing package.json; if not, go up until we find one
2184
2186
  // First, resolve to absolute path
2185
2187
  let currentPath = path.isAbsolute(packagePath)
@@ -2260,23 +2262,89 @@ export const buildPackage = (target_1, target2_1, ...args_1) => __awaiter(void 0
2260
2262
  });
2261
2263
  });
2262
2264
  };
2263
- buildStep({
2264
- name: 'Checking imports',
2265
- apply: () => checkImports(packagePath + '/src'),
2265
+ if (((_a = pkgJson.linked) === null || _a === void 0 ? void 0 : _a.extensionlessImports) === true) {
2266
+ const skipped = "Skipping the import check: package.json sets 'linked.extensionlessImports'";
2267
+ logResults ? spinner.info(skipped) : console.log(skipped);
2268
+ }
2269
+ planBuildSteps(pkgJson, packagePath).forEach(buildStep);
2270
+ let success = yield buildProcess.catch((err) => {
2271
+ let msg = typeof err === 'string' || err instanceof Error
2272
+ ? err.toString()
2273
+ : err.error && !err.error.toString().includes('Command failed:')
2274
+ ? err.error
2275
+ : err.stdout + '\n' + err.stderr;
2276
+ if (logResults) {
2277
+ spinner.stopAndPersist({
2278
+ symbol: chalk.red('✖'),
2279
+ // text: 'Build failed',
2280
+ });
2281
+ }
2282
+ else {
2283
+ console.error(chalk.red(packagePath.split('/').pop(), ' - Build failed:'));
2284
+ console.error(err);
2285
+ return msg;
2286
+ }
2287
+ console.log(msg);
2266
2288
  });
2267
- buildStep({
2289
+ //will be undefined if there was an error
2290
+ if (typeof success !== 'undefined' && success !== false) {
2291
+ if (logResults) {
2292
+ spinner.stopAndPersist({
2293
+ symbol: chalk.greenBright('✔'),
2294
+ text: success === true
2295
+ ? 'Build successful'
2296
+ : 'Build successful with warnings',
2297
+ });
2298
+ }
2299
+ }
2300
+ else {
2301
+ if (logResults) {
2302
+ spinner.stopAndPersist({
2303
+ symbol: chalk.red('✖'),
2304
+ text: 'Build failed',
2305
+ });
2306
+ }
2307
+ }
2308
+ return success;
2309
+ });
2310
+ // The ordered `linked build` steps for a linkedPackage. A package whose source
2311
+ // uses extensionless relative imports (`"linked": {"extensionlessImports": true}`)
2312
+ // skips the import check and gets `.js` added to its emitted ESM specifiers.
2313
+ export const planBuildSteps = (pkgJson, packagePath) => {
2314
+ var _a;
2315
+ const extensionlessImports = ((_a = pkgJson.linked) === null || _a === void 0 ? void 0 : _a.extensionlessImports) === true;
2316
+ const steps = [];
2317
+ if (!extensionlessImports) {
2318
+ steps.push({
2319
+ name: 'Checking imports',
2320
+ apply: () => checkImports(packagePath + '/src'),
2321
+ });
2322
+ }
2323
+ steps.push({
2268
2324
  name: 'Compiling ESM',
2269
2325
  apply: () => __awaiter(void 0, void 0, void 0, function* () {
2270
2326
  return compilePackageESM(packagePath);
2271
2327
  }),
2272
2328
  });
2273
- buildStep({
2329
+ if (extensionlessImports) {
2330
+ steps.push({
2331
+ name: 'Rewriting ESM import specifiers',
2332
+ apply: () => __awaiter(void 0, void 0, void 0, function* () {
2333
+ const libEsm = path.join(packagePath, 'lib', 'esm');
2334
+ if (fs.existsSync(libEsm)) {
2335
+ yield rewriteExtensionlessImports(libEsm);
2336
+ }
2337
+ return true;
2338
+ }),
2339
+ });
2340
+ }
2341
+ steps.push({
2274
2342
  name: 'Compiling CJS',
2275
2343
  apply: () => __awaiter(void 0, void 0, void 0, function* () {
2276
2344
  return compilePackageCJS(packagePath);
2277
2345
  }),
2278
2346
  });
2279
- buildStep({
2347
+ steps.push({
2280
2348
  name: 'Copying files to lib folder',
2281
2349
  apply: () => __awaiter(void 0, void 0, void 0, function* () {
2282
2350
  const files = yield glob(packagePath + '/src/**/*.{json,d.ts,css,scss}');
@@ -2299,7 +2367,7 @@ export const buildPackage = (target_1, target2_1, ...args_1) => __awaiter(void 0
2299
2367
  });
2300
2368
  }),
2301
2369
  });
2302
- buildStep({
2370
+ steps.push({
2303
2371
  name: 'Dual package support',
2304
2372
  apply: () => {
2305
2373
  // Skip if no tsconfig files (e.g. pure-CSS packages).
@@ -2314,56 +2382,18 @@ export const buildPackage = (target_1, target2_1, ...args_1) => __awaiter(void 0
2314
2382
  });
2315
2383
  },
2316
2384
  });
2317
- buildStep({
2385
+ steps.push({
2318
2386
  name: 'Removing old files from lib folder',
2319
2387
  apply: () => __awaiter(void 0, void 0, void 0, function* () {
2320
2388
  return removeOldFiles(packagePath);
2321
2389
  }),
2322
2390
  });
2323
- buildStep({
2391
+ steps.push({
2324
2392
  name: 'Checking dependencies',
2325
2393
  apply: () => depCheck(packagePath),
2326
2394
  });
2327
- let success = yield buildProcess.catch((err) => {
2328
- let msg = typeof err === 'string' || err instanceof Error
2329
- ? err.toString()
2330
- : err.error && !err.error.toString().includes('Command failed:')
2331
- ? err.error
2332
- : err.stdout + '\n' + err.stderr;
2333
- if (logResults) {
2334
- spinner.stopAndPersist({
2335
- symbol: chalk.red('✖'),
2336
- // text: 'Build failed',
2337
- });
2338
- }
2339
- else {
2340
- console.error(chalk.red(packagePath.split('/').pop(), ' - Build failed:'));
2341
- console.error(err);
2342
- return msg;
2343
- }
2344
- console.log(msg);
2345
- });
2346
- //will be undefined if there was an error
2347
- if (typeof success !== 'undefined' && success !== false) {
2348
- if (logResults) {
2349
- spinner.stopAndPersist({
2350
- symbol: chalk.greenBright('✔'),
2351
- text: success === true
2352
- ? 'Build successful'
2353
- : 'Build successful with warnings',
2354
- });
2355
- }
2356
- }
2357
- else {
2358
- if (logResults) {
2359
- spinner.stopAndPersist({
2360
- symbol: chalk.red('✖'),
2361
- text: 'Build failed',
2362
- });
2363
- }
2364
- }
2365
- return success;
2366
- });
2395
+ return steps;
2396
+ };
2367
2397
  export const compilePackage = (...args_1) => __awaiter(void 0, [...args_1], void 0, function* (packagePath = process.cwd()) {
2368
2398
  //echo 'compiling CJS' && tsc -p tsconfig-cjs.json && echo 'compiling ESM' && tsc -p tsconfig-esm.json
2369
2399
  // let cjsConfig = fs.existsSync(path.join(packagePath,'tsconfig-cjs.json'));