@hublo/sentinel 1.2.0-alpha.19 → 1.2.0-alpha.20

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.
@@ -170,6 +170,7 @@ function loadTransformers(root, program, declared) {
170
170
  });
171
171
  }
172
172
  var decoratorMetadata = (options) => {
173
+ const typeAware = (options.transformers ?? []).length > 0;
173
174
  let ts;
174
175
  let program;
175
176
  let compilerOptions;
@@ -184,19 +185,20 @@ var decoratorMetadata = (options) => {
184
185
  ts = loadCompiler(options.root);
185
186
  const config = readConfig(ts, options);
186
187
  compilerOptions = config.compilerOptions;
188
+ if (!typeAware) return;
187
189
  program = ts.createProgram(config.fileNames, config.compilerOptions);
188
190
  before = loadTransformers(options.root, program, options.transformers ?? []);
189
191
  },
190
192
  transform(code, id) {
191
193
  if (!TYPESCRIPT_SOURCE.test(id) || id.includes("node_modules")) return null;
192
- if (ts === void 0 || program === void 0 || compilerOptions === void 0) {
194
+ if (ts === void 0 || compilerOptions === void 0) {
193
195
  throw new Error(
194
196
  `sentinel build(nest): the compiler was never prepared, so ${id} would be emitted with defaults rather than this module's tsconfig.`
195
197
  );
196
198
  }
197
- const sourceFile = program.getSourceFile(id);
198
- if (sourceFile === void 0 || sourceFile.text !== code) {
199
- withoutTypes.push(id);
199
+ const sourceFile = program?.getSourceFile(id);
200
+ if (program === void 0 || sourceFile === void 0 || sourceFile.text !== code) {
201
+ if (typeAware) withoutTypes.push(id);
200
202
  const output = ts.transpileModule(code, { fileName: id, compilerOptions });
201
203
  return { code: output.outputText, map: output.sourceMapText ?? null };
202
204
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hublo/sentinel",
3
- "version": "1.2.0-alpha.19",
3
+ "version": "1.2.0-alpha.20",
4
4
  "description": "One CLI that guards code health across Hublo repos: shared lint/typescript/build/test presets, static & dynamic analysis, and architecture checks.",
5
5
  "type": "module",
6
6
  "license": "MIT",