Repository: facebook/jest
File: packages/jest-runtime/src/index.ts (TypeScript)

Code before:
    if (specifier.startsWith('data:')) {
      if (
        await this._shouldMockModule(
          referencingIdentifier,
          specifier,
          this._explicitShouldMockModule,
        )
      ) {
        return this.importMock(referencingIdentifier, specifier, context);
      }

      const fromCache = this._esmoduleRegistry.get(specifier);

      if (fromCache) {
        return fromCache;
      }

      const match = specifier.match(dataURIRegex);

      if (!match || !match.groups) {
        throw new Error('Invalid data URI');
      }

      const mime = match.groups.mime;
      if (mime === 'application/wasm') {
        throw new Error('WASM in data URLs is currently not supported');
      }

      const encoding = match.groups.encoding;
      let code = match.groups.code;
      if (!encoding || encoding === 'charset=utf-8') {
        code = decodeURIComponent(code);
      } else if (encoding === 'base64') {
        code = Buffer.from(code, 'base64').toString();
      } else {
        throw new Error(`Invalid data URI encoding: ${encoding}`);
      }

      let module;
      if (mime === 'application/json') {
        module = new SyntheticModule(
          ['default'],
          function () {
            const obj = JSON.parse(code);
            // @ts-expect-error: TS doesn't know what `this` is
            this.setExport('default', obj);
          },
          {context, identifier: specifier},
        );
      } else {
        module = new SourceTextModule(code, {

Review comment (suggestion):
should be somewhat straightforward to support this as well, I think? Just have `_importWasmModule` take some source instead of reading from disk

Code after:
      }
      const globals = this.getGlobalsForEsm(referencingIdentifier, context);
      this._esmoduleRegistry.set('@jest/globals', globals);

      return globals;
    }

    if (specifier.startsWith('data:')) {
      if (
        await this._shouldMockModule(
          referencingIdentifier,
          specifier,
          this._explicitShouldMockModule,
        )
      ) {
        return this.importMock(referencingIdentifier, specifier, context);
      }

      const fromCache = this._esmoduleRegistry.get(specifier);

      if (fromCache) {
        return fromCache;
      }

      const match = specifier.match(dataURIRegex);

      if (!match || !match.groups) {
        throw new Error('Invalid data URI');
      }

      const mime = match.groups.mime;
      const encoding = match.groups.encoding;
      let module;

      if (mime === 'application/wasm') {
        if (!encoding) {
          throw new Error('Missing data URI encoding');
        }
        if (encoding !== 'base64') {
          throw new Error(`Invalid data URI encoding: ${encoding}`);
        }
        module = await this._importWasmModule(
          Buffer.from(match.groups.code, 'base64'),
          specifier,
          context,
        );
      } else {
        let code = match.groups.code;
        if (!encoding || encoding === 'charset=utf-8') {
          code = decodeURIComponent(code);
        } else if (encoding === 'base64') {