import type { LinkOptions } from './LinkOptions.js'; import type { BundlerCapabilitiesOptions } from './BundlerCapability.js'; import type { PackageJsonExports, GeneratedExports } from './PackageJson.js'; export interface PackageSettingsMatchObject { /** * Name of the package. Can use a trailing wildcard (e.g. `@scope/*`). `*` to match any name. * * To negate a match, use `!` as the first character (e.g. `!@scope/foo` or `!@scope/*`). */ name: string; /** * Version of the package. Unspecified matches any version. * * Note that if the package version is a prerelease, it will only match `*` or ranges that * explicitly include prereleases. For example, `^1.0.0` will not match `1.0.1-beta.0`. */ version?: string; } /** * Which package(s) the settings should be applied to. * A string is a shorthand for matching the name with any version (`*` to match any name). */ export type PackageSettingsMatch = string | PackageSettingsMatchObject; /** * Settings overrides for bundling a package (or multiple packages, depending on `match`). */ export interface PackageSettings { /** * Which package(s) the settings should be applied to. * A string is a shorthand for matching the name with any version (`*` to match any name). * An array allows multiple matches to be specified. */ match: PackageSettingsMatch | PackageSettingsMatch[]; /** * The dependencies which should be included when computing the import map. This is primarily used when * devDependencies are needed by the app. This often happens when a library has a demo app which relies * on devDependencies. * * Accepts `$devDependencies` as a special value to include all devDependencies. */ includedDependencies?: string[]; /** * The dependencies which should be ignored by Cloudpack verbs. For example, if "react-native" is a dependency * which should not be included in the import map or evaluated during `init`, it can be listed here to ignore it. * * Accepts `$peerDependencies` as a special value to exclude all peerDependencies. */ excludedDependencies?: string[]; /** * Dependencies which should be inlined in the library bundled by Cloudpack. This is useful for * libraries which are small and don't need to be loaded separately, have issues being resolved * by the browser, or provide reusable scss files. */ inlinedDependencies?: string[]; /** * Use this exports map instead of the original entry points from package.json. (Any Cloudpack- * generated exports will be merged.) This is useful if a library's exports map is missing * or broken, or to skip bundling entries which aren't needed at runtime. * * Generally, keys should be relative import paths starting with ./ (use . for the top-level import). * Other standard exports map syntax (such as conditions) is also supported. * For example: * ```json * { * ".": "./lib/index.js", * "./foo": "./lib/foo.js", * } * ``` */ exports?: PackageJsonExports; /** * If specified, Cloudpack will not attempt to auto-generate ESM stubs for the package, but will * instead use the array of named exports you provide (per entry key). Any keys not included * will have a default export, but no named exports (so `{}` means that all entries should have * only a default export). * An entry key is the output file path, relative to `outputPath` (with forward slashes and leading `./`) * and *without* the extension (unless it's non-JS). * * You can also use the special value `'types'` to generate stubs based on the TypeScript declaration file * if it exists. This will generate named exports for all types in the declaration file and relative imported files. * * Note: This is an escape hatch and should be used with caution, as it can lead to unexpected behavior. */ unsafeCjsExportNames?: { [entryKey: string]: string[]; } | 'types'; /** * Forces the package to be bundled using a specific bundler. */ bundler?: string; /** * @deprecated Use `bundler`. * * This should be removed once repo configs are updated to use `bundler`. */ bundlerType?: string; /** * Any bundler-specific options to be merged with the calculated bundler options. * `bundler` is also required if this is specified. * * This is an escape hatch which is generally not recommended, since it locks the package to * a specific bundler implementation. It's better to use built-in or custom bundler capabilities. * * WARNING: When merging package settings, `bundlerOptions` will be **overwritten** with * the last specified value. */ bundlerOptions?: Record; /** * Paths used for file monitoring and input hashing. Supports glob matching and `!` for exclusions. * Defaults are under `@ms-cloudpack/path-utilities` in `sourceFilesGlobs`. * Use `...` to include the default paths. (`node_modules` is always ignored.) * * For input hashing, both positive and negative globs are considered. * * For file watching, behavior depends on the watcher backend: * - Parcel watcher (default): only negative globs are respected for ignoring files * - Chokidar watcher: both positive and negative globs are supported */ inputPaths?: string[]; /** * Controls the behavior of the `verifyExports` feature when checking consumed exports from this package: * - If true, don't check this package's exports at all. * - If an object, this is a mapping from package import paths to export names to ignore. Examples: * - To ignore top-level exports: `{ ".": ["badName"] }` * - To ignore exports from another path: `{ "./lib/foo": ["badName"] }` */ ignoreMissingExports?: boolean | { [path: string]: string[]; }; /** * Only relevant for packages bundled with rollup: globs of files that include dynamic (async) * imports with non-literal paths, to be processed by `@rollup/plugin-dynamic-import-vars` (subject to * that plugin's [limitations](https://www.npmjs.com/package/\@rollup/plugin-dynamic-import-vars#limitations)). * Files matching `*.dynamic.*` are automatically included. * * This is not needed for ori/esbuild and webpack because they should handle these types of imports automatically. */ dynamicImports?: string[]; /** * Ignore these warning messages from the bundler (partial string matches). * This is intended for non-actionable messages from external dependencies which can't easily * be fixed, to avoid confusing users. */ ignoredBundlerWarnings?: string[]; /** * Settings to control how the package is linked in the resolve map. */ link?: LinkOptions; /** * Setting to control the bundler capabilities for this package. * This is used to enable or disable specific bundler capabilities. */ bundlerCapabilities?: BundlerCapabilitiesOptions; } /** * Subset of PackageSettings used in the generated config. */ export type GeneratedPackageSettings = Pick & { /** * This will be a string (name) for internal packages, or match with name and version for external. * The match in this case will NOT contain wildcards in the name. */ match: string | Required; /** * Generated exports. This will always be a simple object with import paths. */ exports?: GeneratedExports; }; //# sourceMappingURL=PackageSettings.d.ts.map