diff --git a/babel.config.js b/babel.config.js index deb0ff2394f8f..72e717275f207 100644 --- a/babel.config.js +++ b/babel.config.js @@ -91,7 +91,8 @@ module.exports = function getBabelConfig(api) { { test: /date-fns-jalali/i, replacer: 'date-fns-jalali-v3', - ignoreFilenames: 'AdapterDateFnsJalali.ts', + // this option is added by `babel-plugin-replace-imports+1.0.2.patch` + filenameIncludes: 'src/AdapterDateFnsJalaliV3/' }, 'replace-date-fns-jalali-imports', ]); @@ -100,7 +101,8 @@ module.exports = function getBabelConfig(api) { { test: /date-fns/i, replacer: 'date-fns-v3', - ignoreFilenames: 'AdapterDateFns.ts', + // this option is added by `babel-plugin-replace-imports+1.0.2.patch` + filenameIncludes: 'src/AdapterDateFnsV3/' }, ]); } diff --git a/patches/babel-plugin-replace-imports+1.0.2.patch b/patches/babel-plugin-replace-imports+1.0.2.patch index 1c47ea8f960d3..d55906eb85297 100644 --- a/patches/babel-plugin-replace-imports+1.0.2.patch +++ b/patches/babel-plugin-replace-imports+1.0.2.patch @@ -5,5 +5,5 @@ index 8da63ad..9712bcc 100644 @@ -1 +1 @@ -'use strict';Object.defineProperty(exports,'__esModule',{value:!0}),exports.optionLabels=void 0,exports.getErrorMessage=getErrorMessage;var _lodash=require('lodash.isempty'),_lodash2=_interopRequireDefault(_lodash),_lodash3=require('lodash.isstring'),_lodash4=_interopRequireDefault(_lodash3),_lodash5=require('lodash.isregexp'),_lodash6=_interopRequireDefault(_lodash5),_lodash7=require('lodash.isobject'),_lodash8=_interopRequireDefault(_lodash7),_lodash9=require('lodash.isfunction'),_lodash10=_interopRequireDefault(_lodash9);function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}var PLUGIN='babel-plugin-replace-imports',ERRORS={0:'options are required.',1:'option is required.',2:'option must be a RegExp.',3:'option must be a String or a Function',4:'options item must be an Object.'},optionLabels=exports.optionLabels={test:'test',replacer:'replacer'};function getErrorMessage(code,text){var msg=((text?'\xAB'+text+'\xBB':'')+' '+ERRORS[code]).trim();return'\n'+PLUGIN+': '+msg}function init(_ref){function throwError(code,text){var msg=getErrorMessage(code,text);throw new Error(msg)}function getOption(option){return(!(0,_lodash8.default)(option)||(0,_lodash6.default)(option)||Array.isArray(option))&&throwError(4),option}function getTestOption(option){return!(0,_lodash6.default)(option)&&(0,_lodash2.default)(option)&&throwError(1,optionLabels.test),(0,_lodash6.default)(option)||throwError(2,optionLabels.test),option}function getReplacerListOption(option){return(0,_lodash10.default)(option)?[option]:((0,_lodash2.default)(option)&&throwError(1,optionLabels.replacer),Array.isArray(option)?option:[option])}function getReplacerOption(option){return(0,_lodash4.default)(option)||(0,_lodash10.default)(option)||throwError(3,optionLabels.replacer),option}var types=_ref.types;return{visitor:{ImportDeclaration:function ImportDeclaration(path,_ref2){var opts=_ref2.opts;if(!path.node.__processed){(0,_lodash2.default)(opts)&&throwError(0);var source=path.node.source.value,transforms=[],options=opts;Array.isArray(options)||(options=[opts]);for(var _ret,_loop=function(i){var opt=getOption(options[i]),regex=getTestOption(opt[optionLabels.test]);if(regex.test(source)){var replacerList=getReplacerListOption(opt[optionLabels.replacer]);return replacerList.forEach(function(replacer){var repl=getReplacerOption(replacer),importDeclaration=types.importDeclaration(path.node.specifiers,types.stringLiteral(source.replace(regex,repl)));importDeclaration.__processed=!0,transforms.push(importDeclaration)}),'break'}},i=0;i