loaderMain.js 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.create = exports.LoaderMain = void 0;
  6. var _configLoader = require("../common/configLoader");
  7. var _process = require("../common/process");
  8. var _testLoader = require("../common/testLoader");
  9. var _compilationCache = require("../transform/compilationCache");
  10. var _poolBuilder = require("../common/poolBuilder");
  11. var _esmLoaderHost = require("../common/esmLoaderHost");
  12. /**
  13. * Copyright Microsoft Corporation. All rights reserved.
  14. *
  15. * Licensed under the Apache License, Version 2.0 (the "License");
  16. * you may not use this file except in compliance with the License.
  17. * You may obtain a copy of the License at
  18. *
  19. * http://www.apache.org/licenses/LICENSE-2.0
  20. *
  21. * Unless required by applicable law or agreed to in writing, software
  22. * distributed under the License is distributed on an "AS IS" BASIS,
  23. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  24. * See the License for the specific language governing permissions and
  25. * limitations under the License.
  26. */
  27. class LoaderMain extends _process.ProcessRunner {
  28. constructor(serializedConfig) {
  29. super();
  30. this._serializedConfig = void 0;
  31. this._configPromise = void 0;
  32. this._poolBuilder = _poolBuilder.PoolBuilder.createForLoader();
  33. this._serializedConfig = serializedConfig;
  34. }
  35. _config() {
  36. if (!this._configPromise) this._configPromise = _configLoader.ConfigLoader.deserialize(this._serializedConfig);
  37. return this._configPromise;
  38. }
  39. async loadTestFile(params) {
  40. const testErrors = [];
  41. const config = await this._config();
  42. const fileSuite = await (0, _testLoader.loadTestFile)(params.file, config.config.rootDir, testErrors);
  43. this._poolBuilder.buildPools(fileSuite);
  44. return {
  45. fileSuite: fileSuite._deepSerialize(),
  46. testErrors
  47. };
  48. }
  49. async getCompilationCacheFromLoader() {
  50. await (0, _esmLoaderHost.incorporateCompilationCache)();
  51. return (0, _compilationCache.serializeCompilationCache)();
  52. }
  53. }
  54. exports.LoaderMain = LoaderMain;
  55. const create = config => new LoaderMain(config);
  56. exports.create = create;