diff --git a/packages/babel-preset/index.js b/packages/babel-preset/index.js index cf35e360..86fee469 100644 --- a/packages/babel-preset/index.js +++ b/packages/babel-preset/index.js @@ -229,6 +229,11 @@ function preset(api, explicitOptions = {}) { messagesDir: 'build/messages', }; + // unless explict, don't extract messages in dev mode + if (development && intlOpts.extractMessages == null) { + intlOpts.extractMessages = false; + } + presets.push([intlPreset, intlOpts]); } diff --git a/packages/babel-preset/intl-preset.js b/packages/babel-preset/intl-preset.js index 36bc61bd..b86d3af3 100644 --- a/packages/babel-preset/intl-preset.js +++ b/packages/babel-preset/intl-preset.js @@ -10,6 +10,7 @@ module.exports = function intlPreset(_, options = {}) { messagesDir, prefix, idInterpolationPattern = '[sha512:contenthash:base64:6]', + extractMessages = true, ...rest } = options; @@ -40,7 +41,7 @@ module.exports = function intlPreset(_, options = {}) { overrideIdFn, ...rest, onMsgExtracted(filename, messages) { - if (!messages?.length) return; + if (!messages?.length || !extractMessages) return; if (!filename.startsWith(workspaceRoot)) { throw new Error(