UNPKG

@embroider/macros

Version:

Standardized build-time macros for ember apps.

72 lines (70 loc) 2.43 kB
"use strict"; /* Macro Type Signatures */ Object.defineProperty(exports, "__esModule", { value: true }); exports.dependencySatisfies = dependencySatisfies; exports.macroCondition = macroCondition; exports.each = each; exports.importSync = importSync; exports.getConfig = getConfig; exports.getOwnConfig = getOwnConfig; exports.getGlobalConfig = getGlobalConfig; exports.isDevelopingApp = isDevelopingApp; exports.isTesting = isTesting; exports.failBuild = failBuild; exports.moduleExists = moduleExists; /* CAUTION: this code is not necessarily what you are actually running. In general, the macros are implemented at build time using babel, and so calls to these functions get compiled away before they ever run. However, this code is here because it provides types to typescript users of the macros. Some macros also have runtime implementations that are useful in development mode, in addition to their build-time implementations in babel. You can find the runtime implementations in runtime.ts. Having a runtime mode lets us do things like produce a single build in development that works for both fastboot and browser, using the macros to switch between modes. For production, you would switch to the build-time macro implementation to get two optimized builds instead. */ function dependencySatisfies(packageName, semverRange) { throw new Oops(packageName, semverRange); } function macroCondition(predicate) { throw new Oops(predicate); } function each(array) { throw new Oops(array); } // We would prefer to write: // export function importSync<T extends string>(specifier: T): typeof import(T) { // but TS doesn't seem to support that at present. function importSync(specifier) { throw new Oops(specifier); } function getConfig(packageName) { throw new Oops(packageName); } function getOwnConfig() { throw new Oops(); } function getGlobalConfig() { throw new Oops(); } function isDevelopingApp() { throw new Oops(); } function isTesting() { throw new Oops(); } function failBuild(message) { throw new Oops(message); } function moduleExists(packageName) { throw new Oops(packageName); } class Oops extends Error { constructor(...params) { super(`this method is really implemented at compile time via a babel plugin. If you're seeing this exception, something went wrong`); this.params = params; } } //# sourceMappingURL=index.js.map