{"version":3,"file":"rescript-worker-loader.mjs","sources":["../src/index.js"],"sourcesContent":["const getCacheIdentifier = require('react-dev-utils/getCacheIdentifier');\n\nexport default config => {\n  const isEnvProduction = config.mode === 'production';\n  const isEnvDevelopment = !isEnvProduction;\n  // get something that has setted appSrc and fill here\n  const appSrc = config.module.rules[1].include;\n  // https://github.com/webpack/webpack/issues/6642#issuecomment-371087342\n  config.output.globalObject = 'this';\n  // find the rule with 'oneOf'\n  const loaderListRule = config.module.rules.find(ruleObj => Array.isArray(ruleObj.oneOf));\n  if (!loaderListRule) {\n    throw new Error('No found loader config list');\n  }\n  loaderListRule.oneOf.unshift({\n    test: /\\.worker\\.(js|mjs|ts)$/,\n    include: appSrc,\n    use: [\n      require.resolve('worker-loader'),\n      {\n        loader: require.resolve('babel-loader'),\n        options: {\n          customize: require.resolve('babel-preset-react-app/webpack-overrides'),\n          babelrc: false,\n          configFile: false,\n          // get preset setting from loader that matches normal js file and fill here\n          presets: loaderListRule.oneOf[1].options.presets,\n          // Make sure we have a unique cache identifier, erring on the\n          // side of caution.\n          // We remove this when the user ejects because the default\n          // is sane and uses Babel options. Instead of options, we use\n          // the react-scripts and babel-preset-react-app versions.\n          cacheIdentifier: getCacheIdentifier(isEnvProduction ? 'production' : isEnvDevelopment && 'development', [\n            'babel-plugin-named-asset-import',\n            'babel-preset-react-app',\n            'react-dev-utils',\n            'react-scripts',\n          ]),\n          plugins: [\n            ...loaderListRule.oneOf[1].options.plugins,\n            [\n              require.resolve('babel-plugin-named-asset-import'),\n              {\n                loaderMap: {\n                  svg: {\n                    ReactComponent: '@svgr/webpack?-prettier,-svgo![path]',\n                  },\n                },\n              },\n            ],\n          ],\n          // This is a feature of `babel-loader` for webpack (not Babel itself).\n          // It enables caching results in ./node_modules/.cache/babel-loader/\n          // directory for faster rebuilds.\n          cacheDirectory: true,\n          cacheCompression: isEnvProduction,\n          compact: isEnvProduction,\n        },\n      },\n    ],\n  });\n\n  return config;\n};\n"],"names":["const","getCacheIdentifier","require","config","isEnvProduction","mode","isEnvDevelopment","appSrc","module","rules","include","output","globalObject","loaderListRule","find","ruleObj","Array","isArray","oneOf","Error","unshift","test","use","resolve","loader","options","customize","babelrc","configFile","presets","cacheIdentifier","plugins","loaderMap","svg","ReactComponent","cacheDirectory","cacheCompression","compact"],"mappings":"AAAAA,IAAMC,EAAqBC,QAAQ,8DAEpBC,OACPC,EAAkC,eAAhBD,EAAOE,KACzBC,GAAoBF,EAEpBG,EAASJ,EAAOK,OAAOC,MAAM,GAAGC,QAEtCP,EAAOQ,OAAOC,aAAe,WAEvBC,EAAiBV,EAAOK,OAAOC,MAAMK,cAAKC,UAAWC,MAAMC,QAAQF,EAAQG,aAC5EL,QACG,IAAIM,MAAM,sCAElBN,EAAeK,MAAME,QAAQ,CAC3BC,KAAM,yBACNX,QAASH,EACTe,IAAK,CACHpB,QAAQqB,QAAQ,iBAChB,CACEC,OAAQtB,QAAQqB,QAAQ,gBACxBE,QAAS,CACPC,UAAWxB,QAAQqB,QAAQ,4CAC3BI,SAAS,EACTC,YAAY,EAEZC,QAAShB,EAAeK,MAAM,GAAGO,QAAQI,QAMzCC,gBAAiB7B,EAAmBG,EAAkB,aAAeE,GAAoB,cAAe,CACtG,kCACA,yBACA,kBACA,kBAEFyB,QACKlB,EAAeK,MAAM,GAAGO,wBAC3B,CACEvB,QAAQqB,QAAQ,mCAChB,CACES,UAAW,CACTC,IAAK,CACHC,eAAgB,6CAS1BC,gBAAgB,EAChBC,iBAAkBhC,EAClBiC,QAASjC,OAMVD"}