UNPKG

@modern-js/builder

Version:
62 lines (61 loc) 2.5 kB
"use strict"; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __hasOwnProp = Object.prototype.hasOwnProperty; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); var arco_exports = {}; __export(arco_exports, { builderPluginArco: () => builderPluginArco }); module.exports = __toCommonJS(arco_exports); var import_utils = require("@modern-js/utils"); var import_antd = require("./antd"); const builderPluginArco = () => ({ name: `builder-plugin-arco`, setup(api) { const ARCO_NAME = "@arco-design/web-react"; const ARCO_ICON = `${ARCO_NAME}/icon`; api.modifyBuilderConfig((builderConfig) => { var _builderConfig; const { transformImport = [] } = builderConfig.source || {}; if (transformImport === false || !(0, import_utils.isPackageInstalled)(ARCO_NAME, api.context.rootPath)) { return; } const isUseSSR = (0, import_antd.useSSR)(api.context.target); if (!(transformImport === null || transformImport === void 0 ? void 0 : transformImport.some((item) => item.libraryName === ARCO_NAME))) { transformImport.push({ libraryName: ARCO_NAME, libraryDirectory: isUseSSR ? "lib" : "es", camelToDashComponentName: false, style: true }); } if (!(transformImport === null || transformImport === void 0 ? void 0 : transformImport.some((item) => item.libraryName === ARCO_ICON))) { transformImport.push({ libraryName: ARCO_ICON, libraryDirectory: isUseSSR ? "react-icon-cjs" : "react-icon", camelToDashComponentName: false }); } (_builderConfig = builderConfig).source || (_builderConfig.source = {}); builderConfig.source.transformImport = transformImport; }); } }); // Annotate the CommonJS export names for ESM import in node: 0 && (module.exports = { builderPluginArco });