@warp-drive/build-config
Version:
Provides Build Configuration for projects using WarpDrive
178 lines (177 loc) • 4.87 kB
TypeScript
import { getDeprecations } from "./-private/utils/deprecations.js";
import { getFeatures } from "./-private/utils/features.js";
import * as LOGGING from "./debugging.js";
import type { PluginItem } from "@babel/core";
/**
* Create the Babel plugin for WarpDrive
*
* Note: If your project already uses [@embroider/macros](https://www.npmjs.com/package/@embroider/macros)
* then you should use {@link setConfig} instead of this function.
*
* @param options WarpDrive configuration options
* @returns An array of Babel plugins
*/
export declare function babelPlugin(options: WarpDriveConfig): {
gts: Function[];
js: PluginItem[];
};
/**
* Build Configuration options for WarpDrive that
* allow adjusting logging, deprecations, canary features
* and optional features.
*/
export interface WarpDriveConfig {
/**
* An object of key/value pairs of logging flags
*
* see {@link LOGGING | debugging} for the available flags.
*
* ```ts
* {
* LOG_CACHE: true,
* }
* ```
*
* @public
*/
debug?: Partial<InternalWarpDriveConfig["debug"]>;
/**
* If you are using the library in an environment that does not
* support `window.crypto.randomUUID` you can enable a polyfill
* for it.
*
* @public
*/
polyfillUUID?: boolean;
/**
* By default, the integration required to support the ember-inspector
* browser extension is included in production builds only when using
* the `ember-data` package.
*
* Otherwise the default is to exclude it. This setting allows to explicitly
* enable/disable it in production builds.
*
* @public
*/
includeDataAdapterInProduction?: boolean;
/**
* The most recent version of the library from which all
* deprecations have been resolved.
*
* For instance if all deprecations released prior to or
* within `5.3` have been resolved, then setting this to
* `5.3` will remove all the support for the deprecated
* features for associated deprecations.
*
* :::caution **Universal Apps**
* This value should be at least `5.6` for universal/non-ember
* applications as that was the first version that builds
* without any ember-source dependencies provided all deprecations
* are resolved.
* :::
*
* See {@link DEPRECATIONS | deprecations} for more details.
*/
compatWith?: `${number}.${number}`;
/**
* An object of key/value pairs of logging flags
*
* see {@link DEPRECATIONS | deprecations} for the available flags.
*
* ```ts
* {
* DEPRECATE_THING: false,
* }
* ```
*
* @public
*/
deprecations?: Partial<InternalWarpDriveConfig["deprecations"]>;
/**
* An object of key/value pairs of canary feature flags
* for use when testing new features gated behind a flag
* in a canary release version.
*
* see {@link FEATURES | features} for the available flags.
*
* ```ts
* {
* FEATURE_A: true,
* }
* ```
*
* @public
*/
features?: Partial<InternalWarpDriveConfig["features"]>;
/**
* @private
*/
forceMode?: "testing" | "production" | "development";
}
interface InternalWarpDriveConfig {
debug: typeof LOGGING;
polyfillUUID: boolean;
includeDataAdapter: boolean;
compatWith: `${number}.${number}` | null;
deprecations: ReturnType<typeof getDeprecations>;
features: ReturnType<typeof getFeatures>;
activeLogging: typeof LOGGING;
env: {
TESTING: boolean;
PRODUCTION: boolean;
DEBUG: boolean;
};
}
/**
* Sets the build configuration for WarpDrive that ensures
* environment specific behaviors are activated/deactivated
* and enables adjusting log instrumentation, removing code
* that supports deprecated features, enabling canary features
* and enabling/disabling optional features.
*
* The library uses [@embroider/macros](https://www.npmjs.com/package/@embroider/macros)
* to perform this final configuration code transform.
*
* This is a low level API for configuring WarpDrive. If your
* project does not use `@embroider/macros` then you should use
* {@link babelPlugin} instead of this function.
*
* ### Example
*
* ```ts
* import { setConfig } from '@warp-drive/core/build-config';
* import { buildMacros } from '@embroider/macros/babel';
*
* const Macros = buildMacros({
* configure: (config) => {
* setConfig(config, {
* compatWith: '5.6'
* });
* },
* });
*
* export default {
* plugins: [
* // babel-plugin-debug-macros is temporarily needed
* // to convert deprecation/warn calls into console.warn
* [
* 'babel-plugin-debug-macros',
* {
* flags: [],
*
* debugTools: {
* isDebug: true,
* source: '@ember/debug',
* assertPredicateIndex: 1,
* },
* },
* 'ember-data-specific-macros-stripping-test',
* ],
* ...Macros.babelMacros,
* ],
* };
* ```
*/
export declare function setConfig(macros: object, config: WarpDriveConfig): void;
export declare function setConfig(context: object, appRoot: string, config: WarpDriveConfig): void;
export {};