UNPKG

@gasket/plugin-intl

Version:
38 lines (37 loc) 1.41 kB
/// <reference types="@gasket/core" /> Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, /** * Init lifecycle hook - polyfills Intl for Node < 14 * * For SSR with Node < 14, we must polyfill Intl to make sure all locale data is * available. For the browser, this may need polyfilled matching app requirements. * @see https://techoverflow.net/2018/09/19/fixing-nodejs-intl-datetimeformat-not-formatting-properly-for-locales/ * * For Node >= 14, full-icu is supported, so we avoid the polyfill * @see https://formatjs.io/docs/guides/runtime-requirements/#nodejs * @type {import('@gasket/core').HookHandler<'init'>} * @returns {void} */ "default", { enumerable: true, get: function() { return init; } }); const _debug = /*#__PURE__*/ _interop_require_default(require("debug")); const _semver = /*#__PURE__*/ _interop_require_default(require("semver")); const _intl = /*#__PURE__*/ _interop_require_default(require("intl")); function _interop_require_default(obj) { return obj && obj.__esModule ? obj : { default: obj }; } const debugLog = (0, _debug.default)('gasket:plugin:intl:init'); function init() { const current = _semver.default.coerce(process.version).version; if (!_semver.default.satisfies(current, '>=14')) { global.Intl = _intl.default; debugLog('Using Intl polyfill'); } }