UNPKG

@modern-js/module-tools

Version:

Simple, powerful, high-performance modern npm package development solution.

75 lines (74 loc) 3.84 kB
"use strict"; var __create = Object.create; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __getProtoOf = Object.getPrototypeOf; 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 __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( // If the importer is in node compatibility mode or this is not an ESM // file that has been converted to a CommonJS file using a Babel- // compatible transform (i.e. "__esModule" has not been set), then set // "default" to the CommonJS "module.exports" for node compatibility. isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod )); var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); var feature_exports = {}; __export(feature_exports, { getInternalList: () => getInternalList }); module.exports = __toCommonJS(feature_exports); var import_dts = require("../../utils/dts"); var import_asset = require("./asset"); var import_format_cjs = require("./format-cjs"); var import_style = require("./style"); var import_terser = require("./terser"); async function getInternalList(context) { var _userTsconfig_compilerOptions; const internal = []; const { config } = context; internal.push(import_asset.asset, import_style.css); if (config.buildType === "bundle" && config.format === "cjs" && config.splitting) { internal.push(import_format_cjs.formatCjs); } if (config.buildType === "bundleless") { const { redirect } = await Promise.resolve().then(() => __toESM(require("./redirect"))); const { json } = await Promise.resolve().then(() => __toESM(require("./json"))); internal.push(redirect, json); } const userTsconfig = await (0, import_dts.getProjectTsconfig)(context.config.tsconfig); var _userTsconfig_compilerOptions_emitDecoratorMetadata; const emitDecoratorMetadata = (_userTsconfig_compilerOptions_emitDecoratorMetadata = userTsconfig === null || userTsconfig === void 0 ? void 0 : (_userTsconfig_compilerOptions = userTsconfig.compilerOptions) === null || _userTsconfig_compilerOptions === void 0 ? void 0 : _userTsconfig_compilerOptions.emitDecoratorMetadata) !== null && _userTsconfig_compilerOptions_emitDecoratorMetadata !== void 0 ? _userTsconfig_compilerOptions_emitDecoratorMetadata : false; const { transformImport, transformLodash, externalHelpers, format, target } = context.config; const enbaleSwcTransform = transformImport.length > 0 || transformLodash || externalHelpers || emitDecoratorMetadata; const enableSwcRenderChunk = enbaleSwcTransform ? format === "umd" : format === "umd" || target === "es5"; if (enbaleSwcTransform) { const { swcTransform } = await Promise.resolve().then(() => __toESM(require("./swc"))); internal.push(swcTransform(userTsconfig)); } if (enableSwcRenderChunk) { const { swcRenderChunk } = await Promise.resolve().then(() => __toESM(require("./swc"))); internal.push(swcRenderChunk); } if (config.minify && config.minify !== "esbuild") { internal.push(import_terser.minify); } return internal; } // Annotate the CommonJS export names for ESM import in node: 0 && (module.exports = { getInternalList });