"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
Object.defineProperty(exports, "RspackManifestPlugin", {
  enumerable: true,
  get: function () {
    return _rspackManifestPlugin().RspackManifestPlugin;
  }
});
exports.cssParser = void 0;
exports.fontRule = fontRule;
Object.defineProperty(exports, "generateAssetManifest", {
  enumerable: true,
  get: function () {
    return _rspackModules().generateAssetManifest;
  }
});
exports.imageInlineSizeLimit = void 0;
exports.mjsRule = mjsRule;
exports.moduleFileExtensions = void 0;
exports.resolveAlias = resolveAlias;
exports.shouldUseSourceMap = exports.resolveFallbackDev = exports.resolveFallback = void 0;
exports.sourceMapRule = sourceMapRule;
exports.styleRules = styleRules;
exports.swcRule = swcRule;
function _webpack() {
  const data = require("@teambit/webpack");
  _webpack = function () {
    return data;
  };
  return data;
}
function stylesRegexps() {
  const data = _interopRequireWildcard(require("@teambit/webpack.modules.style-regexps"));
  stylesRegexps = function () {
    return data;
  };
  return data;
}
function _rspackManifestPlugin() {
  const data = require("rspack-manifest-plugin");
  _rspackManifestPlugin = function () {
    return data;
  };
  return data;
}
function _rspackModules() {
  const data = require("@teambit/rspack.modules.generate-asset-manifest");
  _rspackModules = function () {
    return data;
  };
  return data;
}
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
const moduleFileExtensions = exports.moduleFileExtensions = ['web.mjs', 'mjs', 'web.js', 'js', 'web.ts', 'ts', 'web.tsx', 'tsx', 'json', 'web.jsx', 'jsx'];
const shouldUseSourceMap = exports.shouldUseSourceMap = process.env.GENERATE_SOURCEMAP === 'true';
const imageInlineSizeLimit = exports.imageInlineSizeLimit = parseInt(process.env.IMAGE_INLINE_SIZE_LIMIT || '10000');
function resolveAlias(opts) {
  return _objectSpread(_objectSpread({
    'react/jsx-runtime': require.resolve('react/jsx-runtime'),
    react: require.resolve('react'),
    'react-dom/server': require.resolve('react-dom/server'),
    'react-dom': require.resolve('react-dom')
  }, opts?.profile && {
    'react-dom$': 'react-dom/profiling',
    'scheduler/tracing': 'scheduler/tracing-profiling'
  }), {}, {
    '@teambit/component.ui.component-compare.context': require.resolve('@teambit/component.ui.component-compare.context'),
    '@teambit/base-react.navigation.link': require.resolve('@teambit/base-react.navigation.link'),
    '@teambit/base-ui.graph.tree.recursive-tree': require.resolve('@teambit/base-ui.graph.tree.recursive-tree'),
    '@teambit/semantics.entities.semantic-schema': require.resolve('@teambit/semantics.entities.semantic-schema'),
    '@teambit/code.ui.code-editor': require.resolve('@teambit/code.ui.code-editor'),
    '@teambit/api-reference.hooks.use-api': require.resolve('@teambit/api-reference.hooks.use-api'),
    '@teambit/api-reference.hooks.use-api-renderers': require.resolve('@teambit/api-reference.hooks.use-api-renderers'),
    '@teambit/lanes.hooks.use-lanes': require.resolve('@teambit/lanes.hooks.use-lanes')
  });
}
const resolveFallback = exports.resolveFallback = {
  module: false,
  path: _webpack().fallbacks.path,
  dgram: false,
  dns: false,
  fs: false,
  stream: false,
  http2: false,
  net: false,
  tls: false,
  child_process: false,
  process: _webpack().fallbacks.process
};
const resolveFallbackDev = exports.resolveFallbackDev = {
  fs: false,
  path: _webpack().fallbacks.path,
  stream: false,
  process: _webpack().fallbacks.process
};

// Keep CSS module imports webpack-compatible: `import styles from './x.module.scss'`.
const cssParser = exports.cssParser = {
  css: {
    namedExports: false
  },
  'css/auto': {
    namedExports: false
  },
  'css/module': {
    namedExports: false
  }
};
function swcRule(options) {
  return {
    test: /\.(js|mjs|jsx|ts|tsx)$/,
    exclude: /node_modules/,
    use: {
      loader: 'builtin:swc-loader',
      options: {
        jsc: {
          parser: {
            syntax: 'typescript',
            tsx: true
          },
          transform: {
            react: _objectSpread(_objectSpread({
              runtime: 'automatic'
            }, options?.dev && {
              development: true
            }), options?.refresh && {
              refresh: true
            })
          },
          target: 'es2015'
        }
      }
    },
    type: 'javascript/auto'
  };
}
function sourceMapRule() {
  return {
    test: /\.js$/,
    enforce: 'pre',
    include: /node_modules/,
    descriptionData: {
      componentId: value => !!value
    },
    extractSourceMap: true
  };
}
function fontRule() {
  return {
    test: /\.(woff(2)?|ttf|eot|svg)(\?v=\d+\.\d+\.\d+)?$/,
    type: 'asset',
    generator: {
      filename: 'static/fonts/[hash][ext][query]'
    }
  };
}
function mjsRule() {
  return {
    test: /\.m?js/,
    resolve: {
      fullySpecified: false
    }
  };
}
/**
 * Returns all 6 style rules: CSS, SCSS, LESS — each as modules and non-modules.
 */
function styleRules(opts) {
  const postCss = opts.postCssConfig ? [{
    loader: require.resolve('postcss-loader'),
    options: opts.postCssConfig
  }] : [];
  const resolveUrl = opts.resolveUrlLoader ? [{
    loader: require.resolve('resolve-url-loader'),
    options: {
      sourceMap: opts.sourceMap
    }
  }] : [];
  const moduleGenerator = _objectSpread({
    localIdentName: '[name]__[local]--[hash:base64:5]',
    // Keep interop with CJS outputs that use __importDefault(require('*.module.scss')).
    esModule: false
  }, opts.exportsOnly && {
    exportsOnly: true
  });
  const regularGenerator = opts.exportsOnly ? {
    exportsOnly: true
  } : undefined;
  const sassLoader = {
    loader: require.resolve('sass-loader'),
    options: {
      sourceMap: true
    }
  };
  return [_objectSpread(_objectSpread({
    test: stylesRegexps().cssNoModulesRegex,
    type: 'css',
    use: [...postCss]
  }, regularGenerator && {
    generator: regularGenerator
  }), {}, {
    sideEffects: true
  }), {
    test: stylesRegexps().cssModuleRegex,
    type: 'css/module',
    use: [...postCss],
    generator: moduleGenerator
  }, _objectSpread(_objectSpread({
    test: stylesRegexps().sassNoModuleRegex,
    type: 'css',
    use: [...postCss, ...resolveUrl, sassLoader]
  }, regularGenerator && {
    generator: regularGenerator
  }), {}, {
    sideEffects: true
  }), {
    test: stylesRegexps().sassModuleRegex,
    type: 'css/module',
    use: [...postCss, ...resolveUrl, sassLoader],
    generator: moduleGenerator
  }];
}

//# sourceMappingURL=rspack.common.js.map