jest-preset-angular 14.2.0 → 14.2.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/CHANGELOG.md CHANGED
@@ -1,3 +1,21 @@
1
+ ## [14.2.2](https://github.com/thymikee/jest-preset-angular/compare/v14.2.1...v14.2.2) (2024-07-31)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * fix: publish correct build assets, closes [#2641](https://github.com/thymikee/jest-preset-angular/issues/2641)
7
+
8
+
9
+
10
+ ## [14.2.1](https://github.com/thymikee/jest-preset-angular/compare/v14.2.0...v14.2.1) (2024-07-30)
11
+
12
+
13
+ ### Bug Fixes
14
+
15
+ * fix: load ts lib files to properly transform constructor for `isolatedModules: true` ([31e78b1](https://github.com/thymikee/jest-preset-angular/commit/31e78b1))
16
+
17
+
18
+
1
19
  ## [14.2.0](https://github.com/thymikee/jest-preset-angular/compare/v14.1.1...v14.2.0) (2024-07-22)
2
20
 
3
21
 
@@ -4,8 +4,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.NgJestCompiler = void 0;
7
- const os_1 = __importDefault(require("os"));
8
- const path_1 = __importDefault(require("path"));
7
+ const node_os_1 = __importDefault(require("node:os"));
8
+ const node_path_1 = __importDefault(require("node:path"));
9
9
  const ts_jest_1 = require("ts-jest");
10
10
  const jit_transform_1 = require("../transformers/jit_transform");
11
11
  const replace_resources_1 = require("../transformers/replace-resources");
@@ -14,18 +14,37 @@ class NgJestCompiler extends ts_jest_1.TsCompiler {
14
14
  super(configSet, jestCacheFS);
15
15
  this.configSet = configSet;
16
16
  this.jestCacheFS = jestCacheFS;
17
+ this._libSourceFileCache = new Map();
17
18
  this._logger.debug('created NgJestCompiler');
19
+ this._defaultLibDirPath = node_path_1.default.dirname(this._ts.getDefaultLibFilePath(this._compilerOptions));
18
20
  }
19
21
  _transpileOutput(fileContent, filePath) {
20
- const sourceFile = this._ts.createSourceFile(filePath, fileContent, this._compilerOptions.target);
22
+ var _a;
23
+ const scriptTarget = (_a = this._compilerOptions.target) !== null && _a !== void 0 ? _a : this._ts.ScriptTarget.Latest;
24
+ const sourceFile = this._ts.createSourceFile(filePath, fileContent, scriptTarget);
21
25
  const compilerHost = {
22
- getSourceFile: (fileName) => (fileName === path_1.default.normalize(filePath) ? sourceFile : undefined),
26
+ getSourceFile: (fileName) => {
27
+ var _a;
28
+ if (fileName === node_path_1.default.normalize(filePath)) {
29
+ return sourceFile;
30
+ }
31
+ let libSourceFile = this._libSourceFileCache.get(fileName);
32
+ if (!libSourceFile) {
33
+ const libFilePath = node_path_1.default.join(this._defaultLibDirPath, fileName);
34
+ const libFileContent = (_a = this._ts.sys.readFile(libFilePath)) !== null && _a !== void 0 ? _a : '';
35
+ if (libFileContent) {
36
+ libSourceFile = this._ts.createSourceFile(fileName, libFileContent, scriptTarget);
37
+ this._libSourceFileCache.set(fileName, libSourceFile);
38
+ }
39
+ }
40
+ return libSourceFile;
41
+ },
23
42
  writeFile: () => { },
24
43
  getDefaultLibFileName: () => 'lib.d.ts',
25
44
  useCaseSensitiveFileNames: () => false,
26
45
  getCanonicalFileName: (fileName) => fileName,
27
46
  getCurrentDirectory: () => '',
28
- getNewLine: () => os_1.default.EOL,
47
+ getNewLine: () => node_os_1.default.EOL,
29
48
  fileExists: (fileName) => fileName === filePath,
30
49
  readFile: () => '',
31
50
  directoryExists: () => true,