<commit_before>import { ITarget } from '../config/ITarget';
import { readFile } from '../utils/utils';

export const BUNDLE_RUNTIME_NAMES = {
  ARG_REQUIRE_FUNCTION: '__fusereq',
  BUNDLE_FUNCTION: 'bundle',
  CACHE_MODULES: 'c',
  GLOBAL_OBJ: '__fuse',
  INTEROP_REQUIRE_DEFAULT_FUNCTION: 'dt',
  MODULE_COLLECTION: 'modules',
  REQUIRE_FUNCTION: 'r',
};

export function createGlobalModuleCall(moduleId: number) {
  const fn = BUNDLE_RUNTIME_NAMES.GLOBAL_OBJ + '.' + BUNDLE_RUNTIME_NAMES.REQUIRE_FUNCTION;
  return fn + '(' + moduleId + ');';
}

export type ICodeSplittingMap = {
  b: Record<number, { p: string; s?: string }>;
};

export interface IBundleRuntimeCore {
  codeSplittingMap?: ICodeSplittingMap;
  includeHMR?: boolean;
  interopRequireDefault?: boolean;
  isIsolated?: boolean;
  target: ITarget;
  typescriptHelpersPath?: string;
}

const INTEROP_DEFAULT = BUNDLE_RUNTIME_NAMES.INTEROP_REQUIRE_DEFAULT_FUNCTION;

function getCodeSplittingFunction(target: ITarget) {
  if (target === 'browser') {
    return `function lb(id, conf) {
  return new Promise(function(resolve, reject) {
    if (!conf.fns) {
      conf.fns = [resolve];
      function loadJS(){
        var script = document.createElement('script');
        document.head.appendChild(script);
        script.onload = function() {
          if (modules[id]) {
            conf.fns.map(function(x) {
              return x(f.r(id));<commit_msg>code splition broken for electron production build<commit_after>import { ITarget } from '../config/ITarget';
import { readFile } from '../utils/utils';

export const BUNDLE_RUNTIME_NAMES = {
  ARG_REQUIRE_FUNCTION: '__fusereq',
  BUNDLE_FUNCTION: 'bundle',
  CACHE_MODULES: 'c',
  GLOBAL_OBJ: '__fuse',
  INTEROP_REQUIRE_DEFAULT_FUNCTION: 'dt',
  MODULE_COLLECTION: 'modules',
  REQUIRE_FUNCTION: 'r',
};

export function createGlobalModuleCall(moduleId: number) {
  const fn = BUNDLE_RUNTIME_NAMES.GLOBAL_OBJ + '.' + BUNDLE_RUNTIME_NAMES.REQUIRE_FUNCTION;
  return fn + '(' + moduleId + ');';
}

export type ICodeSplittingMap = {
  b: Record<number, { p: string; s?: string }>;
};

export interface IBundleRuntimeCore {
  codeSplittingMap?: ICodeSplittingMap;
  includeHMR?: boolean;
  interopRequireDefault?: boolean;
  isIsolated?: boolean;
  target: ITarget;
  typescriptHelpersPath?: string;
}

const INTEROP_DEFAULT = BUNDLE_RUNTIME_NAMES.INTEROP_REQUIRE_DEFAULT_FUNCTION;

function getCodeSplittingFunction(target: ITarget) {
  if (target === 'browser' || target==='electron') {
    return `function lb(id, conf) {
  return new Promise(function(resolve, reject) {
    if (!conf.fns) {
      conf.fns = [resolve];
      function loadJS(){
        var script = document.createElement('script');
        document.head.appendChild(script);
        script.onload = function() {
          if (modules[id]) {
            conf.fns.map(function(x) {
              return x(f.r(id));
{'fraction_non_alphanumeric': 0.12931034482758622, 'fraction_numerical': 0.0, 'mean_word_length': 4.208258527827648, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5511275', 'n_tokens_mistral': 975, 'n_tokens_neox': 971, 'n_words': 194}