@_linked/cli 1.30.1 → 1.32.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,74 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.32.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#181](https://github.com/linked-fw/cli/pull/181) [`adb992a`](https://github.com/linked-fw/cli/commit/adb992aad55399ff8daee4888cff97c01302e7fc) Thanks [@flyon](https://github.com/flyon)! - `linked build` now enforces the shape-registration standard: every package registers its whole
8
+ shape set through `src/shapes/index.ts`, and apps load it with `import '<pkg>/shapes/index'`.
9
+
10
+ Two new build steps, after "Checking shape references":
11
+
12
+ - **Checking shapes/index** loads `lib/esm/shapes/index.js` on its own in a fresh process and fails
13
+ when it misses any of the package's shapes that its shape modules register when each is loaded
14
+ alone (the per-module loads are shared with the shape-references check, not repeated). It also
15
+ fails when the package has shapes but no `shapes/index`, or when the index throws on load. The
16
+ error lists the missing shapes and the exact `import './X.js';` lines to add. A package without
17
+ shapes passes.
18
+ - **Checking sideEffects** fails when `package.json` `sideEffects` is `false`, or is a list that
19
+ does not match every `lib/esm/shapes/**/*.js`: a bundler drops a side-effect-only import of a
20
+ module declared side-effect-free, so the index would register nothing in production. The error
21
+ names the uncovered modules and what to write instead (omit the field, or
22
+ `["lib/esm/shapes/index.js", "lib/esm/shapes/*.js"]`).
23
+
24
+ `linked create-shape` now writes to the `src/shapes/index.ts` next to the source folder it created
25
+ the shape in, rather than the one under the current directory. The package template's
26
+ `shapes/index.ts` states the side-effect-imports-only rule, and the React Native template's shapes
27
+ package gains a `src/shapes/index.ts` that its entry imports.
28
+
29
+ The shape-references check no longer tolerates `@_linked/core`'s `PropertyShape.in -> List`: core
30
+ now registers `List` wherever `PropertyShape` is registered, so the known-unresolved list is empty
31
+ and that reference fails the build like any other.
32
+
33
+ ## 1.31.0
34
+
35
+ ### Minor Changes
36
+
37
+ - [#157](https://github.com/linked-fw/cli/pull/157) [`5197e61`](https://github.com/linked-fw/cli/commit/5197e61dc3226ba89402adf34b9ca445631424be) Thanks [@flyon](https://github.com/flyon)! - `create-package` now produces a package that is correct the moment it exists.
38
+
39
+ Three defects, fixed together because fixing one alone turns a silent defect into a hard
40
+ build failure:
41
+
42
+ - **The ontology register sibling was never wired up.** The template's `src/index.ts`
43
+ imported the terms module rather than `<name>.register.js`, and `createPackage` omitted
44
+ `example-ontology.register.ts` from both its substitution list and its rename list. A new
45
+ package therefore kept a stray `example-ontology.register.ts` full of unsubstituted
46
+ `${...}` placeholders, and nothing imported either register file — so `linkedOntology()`
47
+ never ran and the ontology was never registered. `createOntology` now adds the register
48
+ import to the index too.
49
+ - **The template still shipped an entry-graph compile** (`files: [types.ts, index.ts]`,
50
+ `include: [backend.ts]`). It now uses the whole-folder shape the fleet converged on:
51
+ `files: ["./src/index.ts"]`, `include: ["./src/**/*.ts", "./src/backend.ts"]`, with tests
52
+ excluded. This had to follow the fix above: a whole-folder compile would otherwise reach
53
+ the unsubstituted placeholder and fail.
54
+ - **A new package had no `.gitignore`**, so `lib/` and `node_modules/` were committable from
55
+ minute one. The template now ships `gitignore.template` (`lib`, `node_modules`,
56
+ `*.tsbuildinfo`), renamed by the existing dotfile pass.
57
+
58
+ - **`"types"` produced a double mapping.** The template declared
59
+ `"types": "lib/esm/index.d.ts"` alongside `typesVersions: {"*":{"*":["lib/esm/*"]}}`,
60
+ which TypeScript applies to the `types` field too — so it asked for
61
+ `lib/esm/lib/esm/index.d.ts` and `node10` resolution failed outright. Restored to
62
+ `"types": "index.d.ts"`, the convention the shipped packages already use, with a `//types`
63
+ note in the file saying why it is correct as written.
64
+
65
+ Also fixes the `data.defauilt` typo in the example ontology's ESM JSON import, which made
66
+ `loadData()` resolve to `undefined` under ESM.
67
+
68
+ A new gated suite, `tests/template/package.full.test.ts` (`npm run test:template`),
69
+ scaffolds with the built CLI, installs, builds, and asserts each of these as a property
70
+ rather than a claim.
71
+
3
72
  ## 1.30.1
4
73
 
5
74
  ### Patch Changes
@@ -1,2 +1,4 @@
1
1
  import './package';
2
+ // Registers every shape in the package.
3
+ import './shapes/index';
2
4
  export * from './shapes/Example';
@@ -0,0 +1,5 @@
1
+ // Shape registry: one side-effect import per shape module, so loading this file
2
+ // registers every shape in the package. Imports only — no exports. `linked build`
3
+ // fails when a shape module is missing from this list.
4
+ // Extensionless on purpose: Metro does not map `.js` specifiers to `.ts` source.
5
+ import './Example';
@@ -0,0 +1,3 @@
1
+ lib
2
+ node_modules
3
+ *.tsbuildinfo
@@ -14,7 +14,8 @@
14
14
  "linkedPackage": true,
15
15
  "main": "lib/cjs/index.js",
16
16
  "module": "lib/esm/index.js",
17
- "types": "lib/esm/index.d.ts",
17
+ "//types": "Correct as written, do not 'fix' it: typesVersions below is applied to the types field too, so \"index.d.ts\" resolves to lib/esm/index.d.ts. Writing that literal path applies the mapping twice (lib/esm/lib/esm/index.d.ts) and breaks node10 resolution. Verify with ts.resolveModuleName under node10 AND bundler, not by looking for the file on disk.",
18
+ "types": "index.d.ts",
18
19
  "license": "ISC",
19
20
  "scripts": {
20
21
  "start": "linked dev",
@@ -1,5 +1,9 @@
1
1
  import './types.js';
2
- import './ontologies/${hyphen_name}.js';
2
+ // Registers the ontology. This MUST be the `.register.js` sibling, not the terms module
3
+ // itself: importing the terms module alone never calls `linkedOntology()`, so the ontology
4
+ // is silently never registered. See the comment in the register file for why registration
5
+ // cannot live in the terms module.
6
+ import './ontologies/${hyphen_name}.register.js';
3
7
 
4
8
  //SHAPES FIRST — all shapes register via the barrel
5
9
  import './shapes/index.js';
@@ -11,7 +11,7 @@ export var loadData = () => {
11
11
  } else {
12
12
  // ESM import
13
13
  //@ts-ignore
14
- return import('../data/${hyphen_name}.json',{ with: { type: "json" } }).then((data) => data.defauilt);
14
+ return import('../data/${hyphen_name}.json',{ with: { type: "json" } }).then((data) => data.default);
15
15
  }
16
16
  };
17
17
 
@@ -1,5 +1,7 @@
1
1
  // Shape registry — every shape in this package is imported here so its @linkedShape
2
2
  // decorator runs and the shape registers on BOTH boot paths: the backend entry
3
3
  // (src/backend.ts, which materializes shapes into app-data on boot) and the frontend
4
- // entry. `linked create-shape` maintains the list below.
4
+ // entry. Apps load the whole set with `import '<package>/shapes/index'`.
5
+ // Side-effect imports only: no exports, components or providers. `linked create-shape`
6
+ // maintains the list below, and `linked build` fails when a shape module is missing.
5
7
  //SHAPES
@@ -9,10 +9,22 @@
9
9
  "resolveJsonModule": true,
10
10
  "esModuleInterop": true,
11
11
  "pretty": true,
12
+ "skipLibCheck": true,
12
13
  "jsx": "react",
13
14
  "types": ["node"]
14
15
  },
15
16
  "files": [
16
- "./src/types.ts","./src/index.ts"],
17
- "include": ["./src/backend.ts"]
17
+ "./src/index.ts"
18
+ ],
19
+ "include": [
20
+ "./src/**/*.ts",
21
+ "./src/backend.ts"
22
+ ],
23
+ "exclude": [
24
+ "**/*.test.ts",
25
+ "**/*.test.tsx",
26
+ "./src/__tests__/**",
27
+ "./src/tests/**",
28
+ "./src/test-helpers/**"
29
+ ]
18
30
  }
@@ -1 +1 @@
1
- {"version":3,"file":"cli-methods.d.ts","sourceRoot":"","sources":["../../src/cli-methods.ts"],"names":[],"mappings":"AAkCA,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,iBAAiB,CAAC;AAepD;;;;;;GAMG;AAKH,OAAO,EACL,uBAAuB,EACvB,wBAAwB,EACxB,gBAAgB,EAChB,qBAAqB,EACrB,YAAY,EACb,MAAM,gBAAgB,CAAC;AAExB,OAAO,EACL,uBAAuB,EACvB,wBAAwB,EACxB,gBAAgB,EAChB,qBAAqB,EACrB,YAAY,GACb,CAAC;AAoBF,MAAM,MAAM,WAAW,GAAG,KAAK,GAAG,cAAc,CAAC;AAEjD,KAAK,WAAW,GAAG;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CA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cAAc,GAAa,aAAQ,EAAE,YAAO,SAMtD,CAAC;AACF,eAAO,IAAI,YAAY,GAAmB,iBAAwB,kBA8FjE,CAAC;AAEF,eAAO,IAAI,wBAAwB,GAAa,gBAAW,EAAE,YAAO,SAsCnE,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,cAAc,GAAU,gBAAW,qBA8B/C,CAAC"}
@@ -20,7 +20,8 @@ import { planPackageSetup } from './utils/packageSetup.js';
20
20
  import { detectPackageManager, execBinCommand, runScriptCommand, } from './utils/packageManager.js';
21
21
  import { rewriteExtensionlessImports } from './utils/esmSpecifiers.js';
22
22
  import { checkShapeNames } from './utils/shapeNames.js';
23
- import { checkShapeReferences } from './utils/shapeReferences.js';
23
+ import { checkShapeReferences, inspectShapeReferences, } from './utils/shapeReferences.js';
24
+ import { checkShapesIndex, checkShapesSideEffects } from './utils/shapesIndex.js';
24
25
  import { spawn as spawnChild } from 'child_process';
25
26
  import { findNearestPackageJson } from 'find-nearest-package-json';
26
27
  import { statSync } from 'fs';
@@ -1065,15 +1066,21 @@ export const createOntology = (prefix_1, uriBase_1, ...args_1) => __awaiter(void
1065
1066
  //if this is not a lincd app (but a lincd package instead)
1066
1067
  if (!sourceFolder.includes('frontend')) {
1067
1068
  //then also add an import to index
1068
- let indexPath = addLineToIndex(`import './ontologies/${hyphenName}.js';`, 'ontologies');
1069
+ // Import the register sibling, not the terms module: only the sibling calls
1070
+ // linkedOntology(). See the comment in example-ontology.register.ts.
1071
+ let indexPath = addLineToIndex(`import './ontologies/${hyphenName}.register.js';`, 'ontologies');
1069
1072
  log(`Added an import of this file from ${chalk.magenta(indexPath)}`);
1070
1073
  }
1071
1074
  });
1072
1075
  // The shapes barrel (src/shapes/index.ts) is imported by both the frontend index and
1073
1076
  // the backend entry, so every shape registers on both boot paths (and materializes into
1074
1077
  // app-data on boot). `create-shape` adds each new shape here — NOT to the main index.
1078
+ // It holds side-effect imports only (no exports), in packages and apps alike: apps load a
1079
+ // package's whole set with `import '<pkg>/shapes/index'`, and `linked build` fails a
1080
+ // package whose shapes/index misses one of its shapes.
1075
1081
  const SHAPES_BARREL_HEADER = `// Shape registry — every shape is imported here so its @linkedShape decorator runs and\n` +
1076
- `// the shape registers on both boot paths (backend materialization + frontend). \`linked\n` +
1082
+ `// the shape registers on both boot paths (backend materialization + frontend).\n` +
1083
+ `// Side-effect imports only: no exports, components or providers. \`linked\n` +
1077
1084
  `// create-shape\` maintains this list.\n//SHAPES\n`;
1078
1085
  const ensureBackendImportsShapes = function (root = process.cwd()) {
1079
1086
  const backendPath = path.join(root, 'src', 'backend.ts');
@@ -1264,7 +1271,9 @@ export const createShape = (name_1, ...args_1) => __awaiter(void 0, [name_1, ...
1264
1271
  // Register the shape in the shapes barrel (src/shapes/index.ts) — NOT the main index —
1265
1272
  // and make sure the barrel is loaded on both boot paths. This is what makes the app
1266
1273
  // materialize its own shapes on boot.
1267
- const barrelPath = addShapeToBarrel(hyphenName);
1274
+ // The barrel sits next to the shape: in the source folder's parent, not the cwd, which
1275
+ // is only the same folder when the command runs from the package or app root.
1276
+ const barrelPath = addShapeToBarrel(hyphenName, path.dirname(sourceFolder));
1268
1277
  log(`Registered the shape in ${chalk.magenta(barrelPath.replace(basePath, ''))}`);
1269
1278
  });
1270
1279
  export const createSetComponent = (name_1, ...args_1) => __awaiter(void 0, [name_1, ...args_1], void 0, function* (name, basePath = process.cwd()) {
@@ -1865,6 +1874,7 @@ export const createPackage = (name_1, uriBase_1, ...args_1) => __awaiter(void 0,
1865
1874
  'Gruntfile.js',
1866
1875
  'src/package.ts',
1867
1876
  'src/ontologies/example-ontology.ts',
1877
+ 'src/ontologies/example-ontology.register.ts',
1868
1878
  'src/data/example-ontology.json',
1869
1879
  ]
1870
1880
  .map((f) => path.join(targetFolder, f))
@@ -1874,6 +1884,10 @@ export const createPackage = (name_1, uriBase_1, ...args_1) => __awaiter(void 0,
1874
1884
  //rename these to a file name similar to the pkg name
1875
1885
  [
1876
1886
  'src/ontologies/example-ontology.ts',
1887
+ // The register sibling is what index.ts imports; without it here the scaffold keeps a
1888
+ // literal `example-ontology.register.ts` full of unsubstituted `${...}` placeholders and
1889
+ // nothing ever calls linkedOntology().
1890
+ 'src/ontologies/example-ontology.register.ts',
1877
1891
  'src/data/example-ontology.json',
1878
1892
  'src/data/example-ontology.json.d.ts',
1879
1893
  ].forEach((f) => {
@@ -2162,130 +2176,149 @@ const loadServerClass = () => __awaiter(void 0, void 0, void 0, function* () {
2162
2176
  `Install it, or run the frontend only.\nCause: ${err instanceof Error ? err.message : err}`);
2163
2177
  }
2164
2178
  });
2165
- export const planBuildSteps = (pkgJson, packagePath) => [
2166
- {
2167
- name: 'Checking imports',
2168
- apply: () => checkImports(packagePath + '/src'),
2169
- },
2170
- {
2171
- name: 'Compiling ESM',
2172
- apply: () => __awaiter(void 0, void 0, void 0, function* () {
2173
- return compilePackageESM(packagePath);
2174
- }),
2175
- },
2176
- {
2177
- name: 'Compiling CJS',
2178
- apply: () => __awaiter(void 0, void 0, void 0, function* () {
2179
- return compilePackageCJS(packagePath);
2180
- }),
2181
- },
2182
- {
2183
- name: 'Copying files to lib folder',
2184
- apply: () => __awaiter(void 0, void 0, void 0, function* () {
2185
- const files = yield glob(packagePath + '/src/**/*.{json,d.ts,css,scss}');
2186
- let cjsPublished = false;
2187
- try {
2188
- cjsPublished = packagePublishesCjs(JSON.parse(fs.readFileSync(path.join(packagePath, 'package.json'), 'utf8')));
2189
- }
2190
- catch (_a) { }
2191
- return Promise.all(files.map((file) => __awaiter(void 0, void 0, void 0, function* () {
2179
+ export const planBuildSteps = (pkgJson, packagePath) => {
2180
+ // Loading every shape module in a child process of its own is the slow part of
2181
+ // a build; the shape checks below share one run, started by the first to ask.
2182
+ let inspection;
2183
+ const inspectShapes = () => (inspection !== null && inspection !== void 0 ? inspection : (inspection = inspectShapeReferences(packagePath)));
2184
+ return [
2185
+ {
2186
+ name: 'Checking imports',
2187
+ apply: () => checkImports(packagePath + '/src'),
2188
+ },
2189
+ {
2190
+ name: 'Compiling ESM',
2191
+ apply: () => __awaiter(void 0, void 0, void 0, function* () {
2192
+ return compilePackageESM(packagePath);
2193
+ }),
2194
+ },
2195
+ {
2196
+ name: 'Compiling CJS',
2197
+ apply: () => __awaiter(void 0, void 0, void 0, function* () {
2198
+ return compilePackageCJS(packagePath);
2199
+ }),
2200
+ },
2201
+ {
2202
+ name: 'Copying files to lib folder',
2203
+ apply: () => __awaiter(void 0, void 0, void 0, function* () {
2204
+ const files = yield glob(packagePath + '/src/**/*.{json,d.ts,css,scss}');
2205
+ let cjsPublished = false;
2192
2206
  try {
2193
- yield fs.copy(file, packagePath +
2194
- '/lib/esm/' +
2195
- file.replace(packagePath + '/src/', ''));
2196
- // Only mirror into lib/cjs when there is a CJS build to mirror.
2197
- if (cjsPublished) {
2207
+ cjsPublished = packagePublishesCjs(JSON.parse(fs.readFileSync(path.join(packagePath, 'package.json'), 'utf8')));
2208
+ }
2209
+ catch (_a) { }
2210
+ return Promise.all(files.map((file) => __awaiter(void 0, void 0, void 0, function* () {
2211
+ try {
2198
2212
  yield fs.copy(file, packagePath +
2199
- '/lib/cjs/' +
2213
+ '/lib/esm/' +
2200
2214
  file.replace(packagePath + '/src/', ''));
2215
+ // Only mirror into lib/cjs when there is a CJS build to mirror.
2216
+ if (cjsPublished) {
2217
+ yield fs.copy(file, packagePath +
2218
+ '/lib/cjs/' +
2219
+ file.replace(packagePath + '/src/', ''));
2220
+ }
2221
+ return true;
2222
+ }
2223
+ catch (err) {
2224
+ console.warn(err);
2225
+ return false;
2201
2226
  }
2227
+ }))).then((allResults) => {
2228
+ return allResults.every((r) => r === true);
2229
+ });
2230
+ }),
2231
+ },
2232
+ {
2233
+ name: 'Dual package support',
2234
+ apply: () => {
2235
+ // Skip if no tsconfig files (e.g. pure-CSS packages).
2236
+ if (!fs.existsSync(path.join(packagePath, 'tsconfig-esm.json')) ||
2237
+ !fs.existsSync(path.join(packagePath, 'tsconfig-cjs.json'))) {
2238
+ return Promise.resolve(true);
2239
+ }
2240
+ // Nothing to make dual when only one format is published — otherwise this
2241
+ // leaves a lib/cjs holding a lone `{"type":"commonjs"}` marker and no code.
2242
+ try {
2243
+ if (!packagePublishesCjs(JSON.parse(fs.readFileSync(path.join(packagePath, 'package.json'), 'utf8')))) {
2244
+ return Promise.resolve(true);
2245
+ }
2246
+ }
2247
+ catch (_a) { }
2248
+ // Resolve the binary from the nearest node_modules (supports both
2249
+ // per-package and workspace-root installs of tsconfig-to-dual-package).
2250
+ return execPromise('npx tsconfig-to-dual-package ./tsconfig-cjs.json ./tsconfig-esm.json', false, false, { cwd: packagePath }).then((res) => {
2251
+ return res === '';
2252
+ });
2253
+ },
2254
+ },
2255
+ {
2256
+ name: 'Removing old files from lib folder',
2257
+ apply: () => __awaiter(void 0, void 0, void 0, function* () {
2258
+ return removeOldFiles(packagePath);
2259
+ }),
2260
+ },
2261
+ {
2262
+ // MUST run after 'Copying files to lib folder' and after 'Removing old
2263
+ // files from lib folder', because the rewrite resolves each specifier
2264
+ // against the files actually present in lib/esm:
2265
+ // - the copy step brings in the assets (`./x.scss`) and hand-written
2266
+ // `.d.ts` from src; before it, an asset import looks unresolvable (a
2267
+ // spurious "build with warnings") and a copied `.d.ts` is never rewritten;
2268
+ // - the cleanup step deletes stale output; before it, a leftover `x.js`
2269
+ // makes './x' resolve to './x.js' and the cleanup then removes the file
2270
+ // the specifier now points at.
2271
+ name: 'Rewriting ESM import specifiers',
2272
+ apply: () => __awaiter(void 0, void 0, void 0, function* () {
2273
+ // No tsconfig-esm.json means the ESM compile was skipped (e.g. pure-CSS
2274
+ // packages), so there is nothing to rewrite and nothing to fail over.
2275
+ if (!fs.existsSync(path.join(packagePath, 'tsconfig-esm.json'))) {
2202
2276
  return true;
2203
2277
  }
2204
- catch (err) {
2205
- console.warn(err);
2206
- return false;
2278
+ const libEsm = path.join(packagePath, 'lib', 'esm');
2279
+ if (!fs.existsSync(libEsm)) {
2280
+ return {
2281
+ error: 'lib/esm was not emitted while tsconfig-esm.json is present. Check the ESM compile.',
2282
+ };
2207
2283
  }
2208
- }))).then((allResults) => {
2209
- return allResults.every((r) => r === true);
2210
- });
2211
- }),
2212
- },
2213
- {
2214
- name: 'Dual package support',
2215
- apply: () => {
2216
- // Skip if no tsconfig files (e.g. pure-CSS packages).
2217
- if (!fs.existsSync(path.join(packagePath, 'tsconfig-esm.json')) ||
2218
- !fs.existsSync(path.join(packagePath, 'tsconfig-cjs.json'))) {
2219
- return Promise.resolve(true);
2220
- }
2221
- // Nothing to make dual when only one format is published — otherwise this
2222
- // leaves a lib/cjs holding a lone `{"type":"commonjs"}` marker and no code.
2223
- try {
2224
- if (!packagePublishesCjs(JSON.parse(fs.readFileSync(path.join(packagePath, 'package.json'), 'utf8')))) {
2225
- return Promise.resolve(true);
2284
+ const { changed, unresolved } = yield rewriteExtensionlessImports(libEsm);
2285
+ if (unresolved.length > 0) {
2286
+ return `could not resolve ${unresolved.length} import(s), left unchanged: ${unresolved.join(', ')}`;
2226
2287
  }
2227
- }
2228
- catch (_a) { }
2229
- // Resolve the binary from the nearest node_modules (supports both
2230
- // per-package and workspace-root installs of tsconfig-to-dual-package).
2231
- return execPromise('npx tsconfig-to-dual-package ./tsconfig-cjs.json ./tsconfig-esm.json', false, false, { cwd: packagePath }).then((res) => {
2232
- return res === '';
2233
- });
2288
+ return changed > 0 ? { info: `rewrote ${changed} file(s)` } : true;
2289
+ }),
2234
2290
  },
2235
- },
2236
- {
2237
- name: 'Removing old files from lib folder',
2238
- apply: () => __awaiter(void 0, void 0, void 0, function* () {
2239
- return removeOldFiles(packagePath);
2240
- }),
2241
- },
2242
- {
2243
- // MUST run after 'Copying files to lib folder' and after 'Removing old
2244
- // files from lib folder', because the rewrite resolves each specifier
2245
- // against the files actually present in lib/esm:
2246
- // - the copy step brings in the assets (`./x.scss`) and hand-written
2247
- // `.d.ts` from src; before it, an asset import looks unresolvable (a
2248
- // spurious "build with warnings") and a copied `.d.ts` is never rewritten;
2249
- // - the cleanup step deletes stale output; before it, a leftover `x.js`
2250
- // makes './x' resolve to './x.js' and the cleanup then removes the file
2251
- // the specifier now points at.
2252
- name: 'Rewriting ESM import specifiers',
2253
- apply: () => __awaiter(void 0, void 0, void 0, function* () {
2254
- // No tsconfig-esm.json means the ESM compile was skipped (e.g. pure-CSS
2255
- // packages), so there is nothing to rewrite and nothing to fail over.
2256
- if (!fs.existsSync(path.join(packagePath, 'tsconfig-esm.json'))) {
2257
- return true;
2258
- }
2259
- const libEsm = path.join(packagePath, 'lib', 'esm');
2260
- if (!fs.existsSync(libEsm)) {
2261
- return {
2262
- error: 'lib/esm was not emitted while tsconfig-esm.json is present. Check the ESM compile.',
2263
- };
2264
- }
2265
- const { changed, unresolved } = yield rewriteExtensionlessImports(libEsm);
2266
- if (unresolved.length > 0) {
2267
- return `could not resolve ${unresolved.length} import(s), left unchanged: ${unresolved.join(', ')}`;
2268
- }
2269
- return changed > 0 ? { info: `rewrote ${changed} file(s)` } : true;
2270
- }),
2271
- },
2272
- {
2273
- // Reads the emitted lib/esm, so it runs after everything that writes it.
2274
- name: 'Checking shape names',
2275
- apply: () => checkShapeNames(packagePath),
2276
- },
2277
- {
2278
- // Loads each compiled shape module on its own, so it needs the final
2279
- // lib/esm too. Fails the build: an unresolved reference is a query that
2280
- // throws "Shape class not found" in a consumer's bundle.
2281
- name: 'Checking shape references',
2282
- apply: () => checkShapeReferences(packagePath),
2283
- },
2284
- {
2285
- name: 'Checking dependencies',
2286
- apply: () => depCheck(packagePath),
2287
- },
2288
- ];
2291
+ {
2292
+ // Reads the emitted lib/esm, so it runs after everything that writes it.
2293
+ name: 'Checking shape names',
2294
+ apply: () => checkShapeNames(packagePath),
2295
+ },
2296
+ {
2297
+ // Loads each compiled shape module on its own, so it needs the final
2298
+ // lib/esm too. Fails the build: an unresolved reference is a query that
2299
+ // throws "Shape class not found" in a consumer's bundle.
2300
+ name: 'Checking shape references',
2301
+ apply: () => checkShapeReferences(packagePath, undefined, inspectShapes()),
2302
+ },
2303
+ {
2304
+ // Same per-module loads: loading lib/esm/shapes/index.js alone must register
2305
+ // every shape of this package that its shape modules register one by one,
2306
+ // because apps load a package's shapes with `import '<pkg>/shapes/index'`.
2307
+ name: 'Checking shapes/index',
2308
+ apply: () => checkShapesIndex(packagePath, undefined, inspectShapes()),
2309
+ },
2310
+ {
2311
+ // A bundler drops the side-effect-only imports in shapes/index of a module
2312
+ // package.json calls side-effect-free.
2313
+ name: 'Checking sideEffects',
2314
+ apply: () => __awaiter(void 0, void 0, void 0, function* () { return checkShapesSideEffects(packagePath); }),
2315
+ },
2316
+ {
2317
+ name: 'Checking dependencies',
2318
+ apply: () => depCheck(packagePath),
2319
+ },
2320
+ ];
2321
+ };
2289
2322
  export const compilePackage = (...args_1) => __awaiter(void 0, [...args_1], void 0, function* (packagePath = process.cwd()) {
2290
2323
  //echo 'compiling CJS' && tsc -p tsconfig-cjs.json && echo 'compiling ESM' && tsc -p tsconfig-esm.json
2291
2324
  // let cjsConfig = fs.existsSync(path.join(packagePath,'tsconfig-cjs.json'));