@o3r/testing 12.0.0-next.0 → 12.0.0-next.11
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/localization/localization-mock.js +1 -1
- package/localization/localization-mock.js.map +1 -1
- package/package.json +48 -47
- package/schematics/ng-add/templates/workspace/jest.config.ut.js.template +4 -4
- package/tools/path-replacement/path-replacement.d.ts.map +1 -1
- package/tools/path-replacement/path-replacement.js +1 -0
- package/tools/path-replacement/path-replacement.js.map +1 -1
|
@@ -53,7 +53,7 @@ var LocalizationDependencyMocks = /** @class */ (function () {
|
|
|
53
53
|
if (pipeWithPrefix === void 0) { pipeWithPrefix = false; }
|
|
54
54
|
return {
|
|
55
55
|
ngModule: LocalizationDependencyMocks_1,
|
|
56
|
-
providers: [{ provide: localization_1.
|
|
56
|
+
providers: [{ provide: localization_1.O3rLocalizationTranslatePipe, useClass: pipeWithPrefix ? O3rTranslatePipeMock : TranslatePipeMock }]
|
|
57
57
|
};
|
|
58
58
|
};
|
|
59
59
|
var LocalizationDependencyMocks_1;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"localization-mock.js","sourceRoot":"","sources":["../../src/localization/localization-mock.ts"],"names":[],"mappings":";;;AAsEA,wDAoBC;;AA1FD,sCAMuB;AACvB,4CAG6B;AAC7B,kDAI2B;AAC3B,6BAEc;AAEd,IAAM,gCAAgC,GAAG;IACvC,gBAAgB,EAAE,CAAC,IAAI,CAAC;IACxB,QAAQ,EAAE,IAAI;IACd,WAAW,EAAE,EAAE;IACf,gBAAgB,EAAE,IAAI;CAC+B,CAAC;AAGxD;IAAA;IAIA,CAAC;IAHQ,qCAAS,GAAhB;QAAiB,cAAc;aAAd,UAAc,EAAd,qBAAc,EAAd,IAAc;YAAd,yBAAc;;QAC7B,OAAO,IAAI,IAAI,IAAI,CAAC,GAAG,CAAC,UAAC,GAAG,IAAK,OAAA,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,EAAf,C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W,2BAA2B,CAOvC;IAAD,kCAAC;CAAA,AAPD,IAOC;AAPY,kEAA2B;AAgBxC;;;;;;;;GAQG;AACH,SAAgB,sBAAsB,CACpC,yBAAgG,EAChG,YAAmC,EACnC,2BAAsC,EACtC,QAAgB,EAChB,cAAsB;IAJtB,0CAAA,EAAA,4DAAgG;IAChG,6BAAA,EAAA,iBAAmC;IAEnC,yBAAA,EAAA,gBAAgB;IAChB,+BAAA,EAAA,sBAAsB;IAEtB;QACE,iCAAkB,CAAC,OAAO,CAAC,cAAM,OAAA,yBAAyB,EAAzB,CAAyB,CAAC;QAC3D,sBAAe,CAAC,OAAO,CAAC;YACtB,MAAM,EAAE;gBACN,OAAO,EAAE,sBAAe;gBACxB,QAAQ,EAAE;oBACR,cAAc,EAAE,UAAC,IAAY,IAAK,OAAA,IAAA,SAAE,EAAC,YAAY,CAAC,IAAI,CAAC,CAAC,EAAtB,CAAsB;iBACzD;aACF;YACD,QAAQ,EAAE,2BAA2B;SACtC,CAAC;OACC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,2BAA2B,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,QAC1E;AACJ,CAAC","sourcesContent":["import {\n ModuleWithProviders,\n NgModule,\n Pipe,\n PipeTransform,\n Provider,\n} from '@angular/core';\nimport {\n TranslateLoader,\n TranslateModule,\n} from '@ngx-translate/core';\nimport {\n LocalizationConfiguration,\n LocalizationModule,\n O3rLocalizationTranslatePipe,\n} from '@o3r/localization';\nimport {\n of,\n} from 'rxjs';\n\nconst defaultLocalizationConfiguration = {\n supportedLocales: ['en'],\n language: 'en',\n endPointUrl: '',\n fallbackLanguage: 'en'\n} as const satisfies Partial<LocalizationConfiguration>;\n\n@Pipe({ name: 'translate' })\nexport class TranslatePipeMock implements PipeTransform {\n public transform(...args: any[]): string | undefined {\n return args && args.map((arg) => JSON.parse(arg)).join(', ');\n }\n}\n\n@Pipe({ name: 'o3rTranslate' })\nexport class O3rTranslatePipeMock implements PipeTransform {\n public transform(...args: any[]): string | undefined {\n return args && args.map((arg) => JSON.parse(arg)).join(', ');\n }\n}\n\n@NgModule({\n declarations: [TranslatePipeMock, O3rTranslatePipeMock],\n exports: [TranslatePipeMock, O3rTranslatePipeMock]\n})\nexport class LocalizationDependencyMocks {\n public static forTest(pipeWithPrefix = false): ModuleWithProviders<LocalizationDependencyMocks> {\n return {\n ngModule: LocalizationDependencyMocks,\n providers: [{ provide: O3rLocalizationTranslatePipe, useClass: pipeWithPrefix ? O3rTranslatePipeMock : TranslatePipeMock }]\n };\n }\n}\n\n/** Mock to provide to the MockTranslation module */\nexport interface MockTranslations {\n [lang: string]: {\n [key: string]: any;\n };\n}\n\n/**\n * Function to get the list of modules required to test component using Localization module\n * @param localizationConfiguration Localization configuration\n * @param translations Translations to use\n * @param translationCompilerProvider Provider for translations compiler\n * @param mockPipe Enable translation pipe mocking\n * @param pipeWithPrefix Enable pipe with prefix\n * @returns List of modules to import in the TestBed\n */\nexport function mockTranslationModules(\n localizationConfiguration: Partial<LocalizationConfiguration> = defaultLocalizationConfiguration,\n translations: MockTranslations = {},\n translationCompilerProvider?: Provider,\n mockPipe = false,\n pipeWithPrefix = false\n): ModuleWithProviders<LocalizationModule>[] {\n return [\n LocalizationModule.forRoot(() => localizationConfiguration),\n TranslateModule.forRoot({\n loader: {\n provide: TranslateLoader,\n useValue: {\n getTranslation: (lang: string) => of(translations[lang])\n }\n },\n compiler: translationCompilerProvider\n }),\n ...(mockPipe ? [LocalizationDependencyMocks.forTest(pipeWithPrefix)] : [])\n ];\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@o3r/testing",
|
|
3
|
-
"version": "12.0.0-next.
|
|
3
|
+
"version": "12.0.0-next.11",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -98,30 +98,30 @@
|
|
|
98
98
|
},
|
|
99
99
|
"peerDependencies": {
|
|
100
100
|
"@amadeus-it-group/kassette": "^1.7.0",
|
|
101
|
-
"@angular-devkit/core": "^
|
|
102
|
-
"@angular-devkit/schematics": "^
|
|
103
|
-
"@angular/animations": "^
|
|
104
|
-
"@angular/cli": "^
|
|
105
|
-
"@angular/common": "^
|
|
106
|
-
"@angular/core": "^
|
|
107
|
-
"@angular/forms": "^
|
|
108
|
-
"@angular/platform-browser": "^
|
|
101
|
+
"@angular-devkit/core": "^19.0.0",
|
|
102
|
+
"@angular-devkit/schematics": "^19.0.0",
|
|
103
|
+
"@angular/animations": "^19.0.0",
|
|
104
|
+
"@angular/cli": "^19.0.0",
|
|
105
|
+
"@angular/common": "^19.0.0",
|
|
106
|
+
"@angular/core": "^19.0.0",
|
|
107
|
+
"@angular/forms": "^19.0.0",
|
|
108
|
+
"@angular/platform-browser": "^19.0.0",
|
|
109
109
|
"@material/slider": "^14.0.0",
|
|
110
|
-
"@ngrx/store": "^
|
|
110
|
+
"@ngrx/store": "^19.0.0",
|
|
111
111
|
"@ngx-translate/core": "^15.0.0",
|
|
112
|
-
"@o3r/core": "^12.0.0-next.
|
|
113
|
-
"@o3r/localization": "^12.0.0-next.
|
|
114
|
-
"@o3r/schematics": "^12.0.0-next.
|
|
112
|
+
"@o3r/core": "^12.0.0-next.11",
|
|
113
|
+
"@o3r/localization": "^12.0.0-next.11",
|
|
114
|
+
"@o3r/schematics": "^12.0.0-next.11",
|
|
115
115
|
"@playwright/test": "^1.49.0",
|
|
116
|
-
"@schematics/angular": "^
|
|
117
|
-
"pixelmatch": "^
|
|
116
|
+
"@schematics/angular": "^19.0.0",
|
|
117
|
+
"pixelmatch": "^6.0.0",
|
|
118
118
|
"pngjs": "^7.0.0",
|
|
119
119
|
"protractor": "^7.0.0",
|
|
120
120
|
"rxjs": "^7.8.1",
|
|
121
121
|
"temporal-polyfill": "^0.2.0",
|
|
122
|
+
"ts-node": "~10.9.2",
|
|
122
123
|
"type-fest": "^4.10.2",
|
|
123
|
-
"typescript": "^5.5.4"
|
|
124
|
-
"ts-node": "~10.9.2"
|
|
124
|
+
"typescript": "^5.5.4"
|
|
125
125
|
},
|
|
126
126
|
"peerDependenciesMeta": {
|
|
127
127
|
"@amadeus-it-group/kassette": {
|
|
@@ -180,44 +180,45 @@
|
|
|
180
180
|
},
|
|
181
181
|
"devDependencies": {
|
|
182
182
|
"@amadeus-it-group/kassette": "^1.7.0",
|
|
183
|
-
"@angular-devkit/build-angular": "~
|
|
184
|
-
"@angular-devkit/core": "~
|
|
185
|
-
"@angular-devkit/schematics": "~
|
|
186
|
-
"@angular/cli": "~
|
|
187
|
-
"@angular/common": "~
|
|
188
|
-
"@angular/compiler": "~
|
|
189
|
-
"@angular/compiler-cli": "~
|
|
190
|
-
"@angular/core": "~
|
|
191
|
-
"@angular/forms": "~
|
|
192
|
-
"@angular/platform-browser": "~
|
|
193
|
-
"@angular/platform-browser-dynamic": "~
|
|
183
|
+
"@angular-devkit/build-angular": "~19.0.0",
|
|
184
|
+
"@angular-devkit/core": "~19.0.0",
|
|
185
|
+
"@angular-devkit/schematics": "~19.0.0",
|
|
186
|
+
"@angular/cli": "~19.0.0",
|
|
187
|
+
"@angular/common": "~19.0.0",
|
|
188
|
+
"@angular/compiler": "~19.0.0",
|
|
189
|
+
"@angular/compiler-cli": "~19.0.0",
|
|
190
|
+
"@angular/core": "~19.0.0",
|
|
191
|
+
"@angular/forms": "~19.0.0",
|
|
192
|
+
"@angular/platform-browser": "~19.0.0",
|
|
193
|
+
"@angular/platform-browser-dynamic": "~19.0.0",
|
|
194
194
|
"@babel/core": "~7.26.0",
|
|
195
195
|
"@babel/preset-typescript": "~7.26.0",
|
|
196
196
|
"@compodoc/compodoc": "^1.1.19",
|
|
197
197
|
"@eslint-community/eslint-plugin-eslint-comments": "^4.4.0",
|
|
198
198
|
"@material/slider": "^14.0.0",
|
|
199
|
-
"@ngrx/store": "~
|
|
199
|
+
"@ngrx/store": "~19.0.0",
|
|
200
200
|
"@ngx-translate/core": "~15.0.0",
|
|
201
201
|
"@nx/eslint-plugin": "~19.8.0",
|
|
202
202
|
"@nx/jest": "~19.8.0",
|
|
203
|
-
"@o3r/build-helpers": "^12.0.0-next.
|
|
204
|
-
"@o3r/core": "^12.0.0-next.
|
|
205
|
-
"@o3r/eslint-plugin": "^12.0.0-next.
|
|
206
|
-
"@o3r/localization": "^12.0.0-next.
|
|
207
|
-
"@o3r/schematics": "^12.0.0-next.
|
|
208
|
-
"@o3r/test-helpers": "^12.0.0-next.
|
|
203
|
+
"@o3r/build-helpers": "^12.0.0-next.11",
|
|
204
|
+
"@o3r/core": "^12.0.0-next.11",
|
|
205
|
+
"@o3r/eslint-plugin": "^12.0.0-next.11",
|
|
206
|
+
"@o3r/localization": "^12.0.0-next.11",
|
|
207
|
+
"@o3r/schematics": "^12.0.0-next.11",
|
|
208
|
+
"@o3r/test-helpers": "^12.0.0-next.11",
|
|
209
209
|
"@playwright/test": "~1.49.0",
|
|
210
|
-
"@schematics/angular": "~
|
|
210
|
+
"@schematics/angular": "~19.0.0",
|
|
211
211
|
"@stylistic/eslint-plugin": "~2.7.0",
|
|
212
|
+
"@swc/helpers": "~0.5.0",
|
|
212
213
|
"@types/jest": "~29.5.2",
|
|
213
214
|
"@types/node": "^20.0.0",
|
|
214
215
|
"@types/pixelmatch": "^5.2.3",
|
|
215
216
|
"@types/pngjs": "^6.0.0",
|
|
216
|
-
"@typescript-eslint/parser": "~8.
|
|
217
|
-
"angular-eslint": "~
|
|
218
|
-
"concurrently": "^
|
|
217
|
+
"@typescript-eslint/parser": "~8.21.0",
|
|
218
|
+
"angular-eslint": "~19.0.0",
|
|
219
|
+
"concurrently": "^9.1.0",
|
|
219
220
|
"cpy-cli": "^5.0.0",
|
|
220
|
-
"eslint": "~9.
|
|
221
|
+
"eslint": "~9.17.0",
|
|
221
222
|
"eslint-import-resolver-node": "^0.3.9",
|
|
222
223
|
"eslint-import-resolver-typescript": "^3.6.3",
|
|
223
224
|
"eslint-plugin-import": "^2.31.0",
|
|
@@ -232,22 +233,22 @@
|
|
|
232
233
|
"jest": "~29.7.0",
|
|
233
234
|
"jest-environment-jsdom": "~29.7.0",
|
|
234
235
|
"jest-junit": "~16.0.0",
|
|
235
|
-
"jest-preset-angular": "~14.
|
|
236
|
+
"jest-preset-angular": "~14.5.0",
|
|
236
237
|
"jsonc-eslint-parser": "~2.4.0",
|
|
237
238
|
"nx": "~19.8.0",
|
|
238
239
|
"pid-from-port": "^1.1.3",
|
|
239
|
-
"pixelmatch": "^
|
|
240
|
+
"pixelmatch": "^6.0.0",
|
|
240
241
|
"pngjs": "^7.0.0",
|
|
241
242
|
"protractor": "^7.0.0",
|
|
242
243
|
"rxjs": "^7.8.1",
|
|
243
244
|
"semver": "^7.5.2",
|
|
244
245
|
"temporal-polyfill": "^0.2.0",
|
|
245
|
-
"ts-jest": "~29.2.
|
|
246
|
+
"ts-jest": "~29.2.5",
|
|
246
247
|
"ts-node": "~10.9.2",
|
|
247
|
-
"type-fest": "^4.
|
|
248
|
-
"typescript": "~5.
|
|
249
|
-
"typescript-eslint": "~8.
|
|
250
|
-
"zone.js": "~0.
|
|
248
|
+
"type-fest": "^4.30.1",
|
|
249
|
+
"typescript": "~5.6.2",
|
|
250
|
+
"typescript-eslint": "~8.21.0",
|
|
251
|
+
"zone.js": "~0.15.0"
|
|
251
252
|
},
|
|
252
253
|
"schematics": "./collection.json",
|
|
253
254
|
"ng-update": {
|
|
@@ -19,10 +19,10 @@ const baseTsconfigPath = resolve(__dirname, './tsconfig.json');
|
|
|
19
19
|
module.exports.getJestProjectConfig = (rootDir, isAngularSetup) => {
|
|
20
20
|
const { compilerOptions } = ts.parseConfigFileTextToJson(baseTsconfigPath, readFileSync(baseTsconfigPath, { encoding: 'utf-8' })).config;
|
|
21
21
|
const relativePath = relative(rootDir, __dirname);
|
|
22
|
-
const moduleNameMapper = Object.
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
22
|
+
const moduleNameMapper = Object.fromEntries(
|
|
23
|
+
Object.entries(pathsToModuleNameMapper(compilerOptions.paths || {}))
|
|
24
|
+
.map(([moduleName, paths]) => [moduleName, (Array.isArray(paths) ? paths : [paths]).map(path => `<rootDir>/${relativePath}/${path}`)])
|
|
25
|
+
);
|
|
26
26
|
moduleNameMapper['^@o3r/testing/core$'] = [require.resolve('@o3r/testing/core/angular')];
|
|
27
27
|
moduleNameMapper['^@o3r/testing/core/(.*)'] = [join(require.resolve('@o3r/testing/core/angular'), '$1')];
|
|
28
28
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"path-replacement.d.ts","sourceRoot":"","sources":["../../../src/tools/path-replacement/path-replacement.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,gBAAgB,EAEjB,MAAM,SAAS,CAAC;AAIjB;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,aAAa,EAAE,YAAY,GAAG,YAAY,EAAE,sBAAsB,GAAE,gBAAqB,
|
|
1
|
+
{"version":3,"file":"path-replacement.d.ts","sourceRoot":"","sources":["../../../src/tools/path-replacement/path-replacement.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,gBAAgB,EAEjB,MAAM,SAAS,CAAC;AAIjB;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,aAAa,EAAE,YAAY,GAAG,YAAY,EAAE,sBAAsB,GAAE,gBAAqB,QAiDnH"}
|
|
@@ -16,6 +16,7 @@ var module_from_string_1 = require("module-from-string");
|
|
|
16
16
|
function adjustPath(frameworkName, customTransformOptions) {
|
|
17
17
|
if (customTransformOptions === void 0) { customTransformOptions = {}; }
|
|
18
18
|
var modulesCache = {};
|
|
19
|
+
// eslint-disable-next-line @typescript-eslint/unbound-method -- No need to bind the method, we are using `apply`
|
|
19
20
|
var originalRequire = node_module_1.Module.prototype.require;
|
|
20
21
|
var regex = new RegExp("@o3r/testing/core(?!/".concat(frameworkName, ")(.*)"));
|
|
21
22
|
node_module_1.Module.prototype.require = function (id) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"path-replacement.js","sourceRoot":"","sources":["../../../src/tools/path-replacement/path-replacement.ts"],"names":[],"mappings":";;AAkBA,
|
|
1
|
+
{"version":3,"file":"path-replacement.js","sourceRoot":"","sources":["../../../src/tools/path-replacement/path-replacement.ts"],"names":[],"mappings":";;AAkBA,gCAiDC;;AAnED,4BAA8B;AAC9B,2CAEqB;AACrB,gCAAkC;AAClC,mCAGiB;AACjB,yDAE4B;AAC5B;;;;;GAKG;AACH,SAAgB,UAAU,CAAC,aAA0C,EAAE,sBAA6C;IAA7C,uCAAA,EAAA,2BAA6C;IAClH,IAAM,YAAY,GAAwB,EAAE,CAAC;IAC7C,iHAAiH;IACjH,IAAM,eAAe,GAAG,oBAAM,CAAC,SAAS,CAAC,OAAO,CAAC;IACjD,IAAM,KAAK,GAAG,IAAI,MAAM,CAAC,+BAAwB,aAAa,UAAO,CAAC,CAAC;IACvE,oBAAM,CAAC,SAAS,CAAC,OAAO,GAAG,UAA+B,EAAU;QAClE,IAAM,KAAK,GAAG,EAAE,CAAC,OAAO,CAAC,KAAK,EAAE,4BAAqB,aAAa,OAAI,CAAC,CAAC;QAExE,IAAI,CAAC;YACH,OAAO,OAAO,CAAC,KAAK,CAAC,eAAe,EAAE,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;QACvD,CAAC;QAAC,WAAM,CAAC;YACP,IAAM,KAAK,GAAI,EAAe;iBAC3B,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,UAAC,CAAC,IAAK,OAAA,CAAC,CAAC,OAAO,CAAC,oBAAoB,EAAE,EAAE,CAAC,EAAnC,CAAmC,CAAC,CAAC,CAAC;YAElF,IAAM,QAAQ,GAAG,OAAO,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,KAAK,OAAA,EAAE,CAAC,CAAC;YACnD,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,EAAE,CAAC;gBAC5B,IAAM,WAAW,GAAG,EAAE,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC;gBAC9C,IAAM,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,KAAK,CAAC,CAAC;gBAC/C,0CAA0C;gBAC1C,IAAM,KAAK,GAAG,IAAA,uBAAa,EAAC,WAAW,CAAC,QAAQ,EAAE,qBAChD,MAAM,EAAE,IAAI,EACZ,MAAM,EAAE,KAAK,EACb,MAAM,EAAE,QAAQ,EAChB,cAAc,EAAE,IAAI,EACpB,UAAU,EAAE,GAAG,IACZ,sBAAsB,EACzB,CAAC;gBAEH;;;;;;mBAMG;gBACH,IAAI,CAAC;oBACH,YAAY,CAAC,QAAQ,CAAC,GAAG,IAAA,sCAAiB,EAAC,KAAK,CAAC,IAAI,EAAE;wBACrD,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC;wBAC/B,gBAAgB,EAAE,IAAI;qBACvB,CAAC,CAAC;gBACL,CAAC;gBAAC,OAAO,EAAE,EAAE,CAAC;oBACZ,mEAAmE;oBACnE,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;gBACpB,CAAC;YACH,CAAC;YAED,OAAO,YAAY,CAAC,QAAQ,CAAC,CAAC;QAChC,CAAC;IACH,CAAmB,CAAC;AACtB,CAAC","sourcesContent":["import * as fs from 'node:fs';\nimport {\n Module,\n} from 'node:module';\nimport * as path from 'node:path';\nimport {\n TransformOptions,\n transformSync,\n} from 'esbuild';\nimport {\n requireFromString,\n} from 'module-from-string';\n/**\n * Switch to the needed implementation of core testing, when running e2e tests\n * transforms ESM into CJS when needed\n * @param frameworkName Name of the framework used for e2e testing (playwright|protractor)\n * @param customTransformOptions\n */\nexport function adjustPath(frameworkName: 'playwright' | 'protractor', customTransformOptions: TransformOptions = {}) {\n const modulesCache: Record<string, any> = {};\n // eslint-disable-next-line @typescript-eslint/unbound-method -- No need to bind the method, we are using `apply`\n const originalRequire = Module.prototype.require;\n const regex = new RegExp(`@o3r/testing/core(?!/${frameworkName})(.*)`);\n Module.prototype.require = function (this: NodeJS.Module, id: string) {\n const newId = id.replace(regex, `@o3r/testing/core/${frameworkName}$1`);\n\n try {\n return Reflect.apply(originalRequire, this, [newId]);\n } catch {\n const paths = ([] as string[])\n .concat(this.paths, this.paths.map((i) => i.replace(/[/\\\\]node_modules$/, '')));\n\n const filePath = require.resolve(newId, { paths });\n if (!modulesCache[filePath]) {\n const fileContent = fs.readFileSync(filePath);\n const cwd = path.resolve(process.cwd(), 'src');\n // we use ESBUILD to transform it into CJS\n const trans = transformSync(fileContent.toString(), {\n loader: 'js',\n format: 'cjs',\n target: 'es2016',\n sourcesContent: true,\n sourceRoot: cwd,\n ...customTransformOptions\n });\n\n /**\n * requireFromString will execute the file apart from just returning a module\n * It can throw an exception which will prevent stop the execution\n *\n * That main blocker includes IVY-compatible libraries which have\n * no compiler facade in a global scope.\n */\n try {\n modulesCache[filePath] = requireFromString(trans.code, {\n dirname: path.dirname(filePath),\n useCurrentGlobal: true\n });\n } catch (ex) {\n // eslint-disable-next-line no-console -- no other logger available\n console.error(ex);\n }\n }\n\n return modulesCache[filePath];\n }\n } as NodeJS.Require;\n}\n"]}
|