@ng-native/testing 0.13.0 → 0.14.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/package.json +7 -7
- package/runner/compile.mjs +22 -1
- package/runner/loader.mjs +5 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ng-native/testing",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.14.0",
|
|
4
4
|
"description": "Test Angular Native components in Node with no simulator: a fake Fabric, Testing Library queries and events, and Vitest and node:test integration.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"angular",
|
|
@@ -34,16 +34,16 @@
|
|
|
34
34
|
"access": "public"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@ng-native/fabric": "0.
|
|
38
|
-
"@ng-native/metro": "0.
|
|
39
|
-
"@ng-native/platform": "0.
|
|
37
|
+
"@ng-native/fabric": "0.14.0",
|
|
38
|
+
"@ng-native/metro": "0.14.0",
|
|
39
|
+
"@ng-native/platform": "0.14.0"
|
|
40
40
|
},
|
|
41
41
|
"peerDependencies": {
|
|
42
42
|
"@angular/compiler": "^22.0.0",
|
|
43
43
|
"@angular/core": "^22.0.0",
|
|
44
44
|
"vite": "^6.0.0 || ^7.0.0 || ^8.0.0",
|
|
45
45
|
"vitest": "^4.0.8 || ^5.0.0",
|
|
46
|
-
"@ng-native/components": "0.
|
|
46
|
+
"@ng-native/components": "0.14.0"
|
|
47
47
|
},
|
|
48
48
|
"peerDependenciesMeta": {
|
|
49
49
|
"@angular/compiler": {
|
|
@@ -62,8 +62,8 @@
|
|
|
62
62
|
"@angular/core": "22.2.0",
|
|
63
63
|
"@angular/forms": "22.2.0",
|
|
64
64
|
"@angular/router": "22.2.0",
|
|
65
|
-
"@ng-native/components": "0.
|
|
66
|
-
"@ng-native/router": "0.
|
|
65
|
+
"@ng-native/components": "0.14.0",
|
|
66
|
+
"@ng-native/router": "0.14.0",
|
|
67
67
|
"vite": "^8.3.1",
|
|
68
68
|
"vitest": "^5.0.2"
|
|
69
69
|
},
|
package/runner/compile.mjs
CHANGED
|
@@ -16,8 +16,9 @@
|
|
|
16
16
|
* `@ng-native/*` package and most Angular libraries on npm are full of `ɵɵngDeclare*` calls, which compile eagerly at module evaluation
|
|
17
17
|
* and throw "needs to be compiled using the JIT compiler" without the linker.
|
|
18
18
|
*/
|
|
19
|
-
import { createRequire } from 'node:module';
|
|
19
|
+
import { createRequire, Module } from 'node:module';
|
|
20
20
|
import path from 'node:path';
|
|
21
|
+
import { pathToFileURL } from 'node:url';
|
|
21
22
|
|
|
22
23
|
const require = createRequire(import.meta.url);
|
|
23
24
|
|
|
@@ -40,6 +41,26 @@ export function needsAngular(source, file) {
|
|
|
40
41
|
: IS_PARTIAL_COMPILED.test(source);
|
|
41
42
|
}
|
|
42
43
|
|
|
44
|
+
/**
|
|
45
|
+
* Imports the ES modules the compiler `require`s, `@oxc-angular/vite`'s API and
|
|
46
|
+
* `@angular/compiler`, into `require.cache`, where its `require` finds them. For a hook to call
|
|
47
|
+
* before it is registered: Node 22 and early Node 24 releases cannot `require` an ES module that
|
|
48
|
+
* imports anything on the thread that runs `module.register`'s hooks, and throw
|
|
49
|
+
* `ERR_METHOD_NOT_IMPLEMENTED` from `resolveSync` for every file compiled. A test that compiles
|
|
50
|
+
* anything loads both anyway.
|
|
51
|
+
*/
|
|
52
|
+
export async function importCompilerModules() {
|
|
53
|
+
const compiler = createRequire(require.resolve('@ng-native/metro/angular-transform.cjs'));
|
|
54
|
+
for (const specifier of ['@oxc-angular/vite/api', '@angular/compiler']) {
|
|
55
|
+
const file = compiler.resolve(specifier);
|
|
56
|
+
const module = new Module(file);
|
|
57
|
+
module.filename = file;
|
|
58
|
+
module.exports = await import(pathToFileURL(file).href);
|
|
59
|
+
module.loaded = true;
|
|
60
|
+
require.cache[file] = module;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
43
64
|
/**
|
|
44
65
|
* Compile or link one file. The output of a decorated source is still TypeScript: the runner's
|
|
45
66
|
* own type stripping takes it from there, as Metro's babel preset does in an app.
|
package/runner/loader.mjs
CHANGED
|
@@ -22,10 +22,15 @@ import {
|
|
|
22
22
|
compileAngular,
|
|
23
23
|
compileMarkdown,
|
|
24
24
|
domComponentReference,
|
|
25
|
+
importCompilerModules,
|
|
25
26
|
needsAngular,
|
|
26
27
|
stubAssets,
|
|
27
28
|
} from './compile.mjs';
|
|
28
29
|
|
|
30
|
+
// Before this hook is in place, so loading them cannot come back through it. See
|
|
31
|
+
// `importCompilerModules`.
|
|
32
|
+
await importCompilerModules();
|
|
33
|
+
|
|
29
34
|
/** @type {string[]} */
|
|
30
35
|
let skip = [];
|
|
31
36
|
/** @type {string[]} */
|