text: "use strict";
  Object.defineProperty(exports, "__esModule", { value: true });
  const typewiz_core_1 = require("typewiz-core");
  const type_collector_snippet_1 = require("typewiz-core/dist/type-collector-snippet");
  function register(options) {
      const finalOptions = Object.assign({
          extensions: ['.ts', '.tsx'],
          typewizConfig: 'typewiz.json',
      }, options);
      const configurationParser = new typewiz_core_1.ConfigurationParser();
      configurationParser.parseSync(finalOptions.typewizConfig);
      global.$_$twiz = type_collector_snippet_1.$_$twiz;
      const oldHooks = {};
      for (const extension of finalOptions.extensions) {
          const oldHook = require.extensions[extension] || require.extensions['.js'];
          oldHooks[extension] = oldHook;
          require.extensions[extension] = (m, file) => {
              const oldCompile = m._compile;
              m._compile = (source, filename) => {
                  m._compile = oldCompile;
                  m._compile(typewiz_core_1.instrument(source, filename, configurationParser.getInstrumentOptions()), filename);
              };
              oldHook(m, file);
          };
      }
      return function unregister() {
          for (const extension of Object.keys(oldHooks)) {
              require.extensions[extension] = oldHooks[extension];
          }
      };
  }
  exports.register = register;
  //# sourceMappingURL=node-register.js.map