Skip to content

Commit

Permalink
Fix transpilation of dataviews for Jetpack Protect
Browse files Browse the repository at this point in the history
  • Loading branch information
nateweller committed Feb 4, 2025
1 parent be1c318 commit 33306a4
Showing 1 changed file with 54 additions and 2 deletions.
56 changes: 54 additions & 2 deletions projects/plugins/protect/webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
const path = require( 'path' );
const jetpackWebpackConfig = require( '@automattic/jetpack-webpack-config/webpack' );

const baseI18nFunctions = [ '__', '_x', '_n', '_nx' ];
const i18nFunctions = [ ...baseI18nFunctions ];
for ( let i = 0; i < 100; i++ ) {
i18nFunctions.push( `__${ i }` );
i18nFunctions.push( `_x${ i }` );
i18nFunctions.push( `_n${ i }` );
i18nFunctions.push( `_nx${ i }` );
}

module.exports = [
{
entry: {
Expand Down Expand Up @@ -39,13 +48,56 @@ module.exports = [
* @see https://github.com/Automattic/jetpack/issues/39907
*/
jetpackWebpackConfig.TranspileRule( {
includeNodeModules: [ '@wordpress/dataviews/wp/' ],
includeNodeModules: [ '@wordpress/dataviews/build-wp/' ],
babelOpts: {
configFile: false,
plugins: [
[
require.resolve( '@automattic/babel-plugin-replace-textdomain' ),
{ textdomain: 'jetpack-protect' },
{
textdomain: 'jetpack-protect',
functions: {
__: 1,
__1: 1,
__2: 1,
__3: 1,
__4: 1,
__5: 1,
__6: 1,
__7: 1,
__8: 1,
__9: 1,
__10: 1,
__11: 1,
__12: 1,
__13: 1,
__14: 1,
__15: 1,
__16: 1,
__17: 1,
__18: 1,
__19: 1,
__20: 1,
__21: 1,
__22: 1,
__23: 1,
__24: 1,
__25: 1,
__26: 1,
__27: 1,
__28: 1,
__29: 1,
__30: 1,
_x: 2,
_x1: 2,
_x2: 2,
_x3: 2,
_x4: 2,
_x5: 2,
_n: 3,
_nx: 4,
},
},
],
],
},
Expand Down

0 comments on commit 33306a4

Please sign in to comment.