UNPKG

@modern-js/module-tools

Version:

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

311 lines (310 loc) • 7.27 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 preset_exports = {}; __export(preset_exports, { componentPreset: () => componentPreset, componentPresetWithTarget: () => componentPresetWithTarget, componentUmdPreset: () => componentUmdPreset, componentUmdPresetWithTarget: () => componentUmdPresetWithTarget, internalPreset: () => internalPreset, libraryPreset: () => libraryPreset, libraryPresetWithTarget: () => libraryPresetWithTarget, libraryUmdPreset: () => libraryUmdPreset, libraryUmdPresetWithTarget: () => libraryUmdPresetWithTarget, nodeBuildConfig: () => nodeBuildConfig, npmComponentPresetConfig: () => npmComponentPresetConfig, npmComponentWithUmdPresetConfig: () => npmComponentWithUmdPresetConfig, npmLibraryPresetConfig: () => npmLibraryPresetConfig, npmLibraryWithUmdPresetConfig: () => npmLibraryWithUmdPresetConfig, presetList: () => presetList, targets: () => targets, universalBuildConfig: () => universalBuildConfig }); module.exports = __toCommonJS(preset_exports); const targets = [ "es5", "es6", "es2015", "es2016", "es2017", "es2018", "es2019", "es2020", "es2021", "es2022", "esnext" ]; const npmLibraryPresetConfig = [ { format: "cjs", target: "es6", buildType: "bundle", outDir: "./dist/lib", dts: false }, { format: "esm", target: "es6", buildType: "bundle", outDir: "./dist/es", dts: false }, { buildType: "bundle", dts: { only: true, distPath: "./types" } } ]; const npmLibraryWithUmdPresetConfig = [ { format: "cjs", target: "es6", buildType: "bundle", outDir: "./dist/lib", dts: false }, { format: "esm", target: "es6", buildType: "bundle", outDir: "./dist/es", dts: false }, { format: "umd", target: "es6", platform: "browser", buildType: "bundle", outDir: "./dist/umd", dts: false }, { buildType: "bundle", dts: { only: true, distPath: "./types" } } ]; const npmComponentPresetConfig = [ { format: "cjs", target: "es6", buildType: "bundleless", outDir: "./dist/lib", dts: false }, { format: "esm", target: "es6", buildType: "bundleless", outDir: "./dist/es", dts: false }, { buildType: "bundleless", outDir: "./dist/types", dts: { only: true } } ]; const npmComponentWithUmdPresetConfig = [ { format: "cjs", target: "es6", buildType: "bundleless", outDir: "./dist/lib", dts: false }, { format: "esm", target: "es6", buildType: "bundleless", outDir: "./dist/es", dts: false }, { format: "umd", target: "es6", platform: "browser", buildType: "bundle", outDir: "./dist/umd", dts: false }, { buildType: "bundleless", dts: { only: true, distPath: "./types" } } ]; const libraryPreset = { "npm-library": npmLibraryPresetConfig }; const libraryPresetWithTarget = targets.reduce((ret, target) => { ret[`npm-library-${target}`] = libraryPreset["npm-library"].map((config) => { return { ...config, target }; }); return ret; }, {}); const libraryUmdPreset = { "npm-library-with-umd": npmLibraryWithUmdPresetConfig }; const libraryUmdPresetWithTarget = targets.reduce((ret, target) => { ret[`npm-library-with-umd-${target}`] = libraryUmdPreset["npm-library-with-umd"].map((config) => { return { ...config, target }; }); return ret; }, {}); const componentPreset = { "npm-component": npmComponentPresetConfig }; const componentPresetWithTarget = targets.reduce((ret, target) => { ret[`npm-component-${target}`] = componentPreset["npm-component"].map((config) => { return { ...config, target }; }); return ret; }, {}); const componentUmdPreset = { "npm-component-with-umd": npmComponentWithUmdPresetConfig }; const componentUmdPresetWithTarget = targets.reduce((ret, target) => { ret[`npm-component-with-umd-${target}`] = componentUmdPreset["npm-component-with-umd"].map((config) => { return { ...config, target }; }); return ret; }, {}); const nodeBuildConfig = [ { buildType: "bundleless", format: "cjs", target: "es2019", dts: false, externalHelpers: true, outDir: "./dist/cjs" }, { buildType: "bundleless", format: "esm", target: "es2019", dts: false, externalHelpers: true, outDir: "./dist/esm" }, { buildType: "bundleless", dts: { only: true }, outDir: "./dist/types" } ]; const universalBuildConfig = [ { buildType: "bundleless", format: "cjs", target: "es2019", dts: false, externalHelpers: true, outDir: "./dist/cjs" }, { buildType: "bundleless", format: "esm", target: "es5", dts: false, externalHelpers: true, outDir: "./dist/esm" }, { buildType: "bundleless", format: "esm", target: "es2019", dts: false, externalHelpers: true, outDir: "./dist/esm-node" }, { buildType: "bundleless", dts: { only: true }, outDir: "./dist/types" } ]; const presetList = { ...libraryPreset, ...libraryPresetWithTarget, ...libraryUmdPreset, ...libraryUmdPresetWithTarget, ...componentPreset, ...componentPresetWithTarget, ...componentUmdPreset, ...componentUmdPresetWithTarget, "modern-js-node": nodeBuildConfig, "modern-js-universal": universalBuildConfig }; const internalPreset = { NPM_LIBRARY: npmLibraryPresetConfig, "npm-library": npmLibraryPresetConfig, NPM_LIBRARY_WITH_UMD: npmLibraryWithUmdPresetConfig, "npm-library-with-umd": npmLibraryWithUmdPresetConfig, NPM_COMPONENT: npmComponentPresetConfig, "npm-component": npmComponentPresetConfig, NPM_COMPONENT_WITH_UMD: npmComponentWithUmdPresetConfig, "npm-component-with-umd": npmComponentWithUmdPresetConfig, "modern-js-node": nodeBuildConfig, "modern-js-universal": universalBuildConfig }; // Annotate the CommonJS export names for ESM import in node: 0 && (module.exports = { componentPreset, componentPresetWithTarget, componentUmdPreset, componentUmdPresetWithTarget, internalPreset, libraryPreset, libraryPresetWithTarget, libraryUmdPreset, libraryUmdPresetWithTarget, nodeBuildConfig, npmComponentPresetConfig, npmComponentWithUmdPresetConfig, npmLibraryPresetConfig, npmLibraryWithUmdPresetConfig, presetList, targets, universalBuildConfig });