@elementor/extract-i18n-wordpress-expressions-webpack-plugin 0.3.4 → 0.3.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # Change Log
2
2
 
3
+ ## 0.3.6
4
+
5
+ ### Patch Changes
6
+
7
+ - 21bef2b: Set specific webpack version in peer dependencies
8
+
9
+ ## 0.3.5
10
+
11
+ ### Patch Changes
12
+
13
+ - 1926fe1: Update dependencies
14
+
3
15
  ## 0.3.4
4
16
 
5
17
  ### Patch Changes
package/dist/index.js CHANGED
@@ -28,19 +28,19 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
28
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
29
 
30
30
  // src/index.ts
31
- var src_exports = {};
32
- __export(src_exports, {
31
+ var index_exports = {};
32
+ __export(index_exports, {
33
33
  ExtractI18nWordpressExpressionsWebpackPlugin: () => ExtractI18nWordpressExpressionsWebpackPlugin
34
34
  });
35
- module.exports = __toCommonJS(src_exports);
35
+ module.exports = __toCommonJS(index_exports);
36
36
 
37
37
  // src/plugin.ts
38
- var path = __toESM(require("path"));
39
38
  var fs2 = __toESM(require("fs"));
39
+ var path = __toESM(require("path"));
40
40
 
41
41
  // src/utils.ts
42
- var import_glob = require("glob");
43
42
  var fs = __toESM(require("fs"));
43
+ var import_glob = require("glob");
44
44
  var COMMENTS_REGEXPS = [
45
45
  // Matches translators comment block: `/* translators: %s */`.
46
46
  /\/\*[\t ]*translators:.*\*\//gm,
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/plugin.ts","../src/utils.ts"],"sourcesContent":["export { default as ExtractI18nWordpressExpressionsWebpackPlugin } from './plugin';\n","import * as path from 'path';\nimport * as fs from 'fs';\nimport { Compilation, Compiler } from 'webpack';\nimport { EntrySettings } from './types';\nimport { createStringsFilePath, generateStringsFileContent, getFilesContents, getFilesPaths } from './utils';\n\ntype Options = {\n\tpattern: ( entryPath: string, entryId: string ) => string;\n};\n\nexport default class ExtractI18nWordpressExpressionsWebpackPlugin {\n\toptions: Options;\n\n\tconstructor( options: Options ) {\n\t\tthis.options = options;\n\t}\n\n\tapply( compiler: Compiler ) {\n\t\tcompiler.hooks.afterEmit.tapPromise( this.constructor.name, async ( compilation ) => {\n\t\t\tconst entries = this.getEntries( compilation );\n\n\t\t\tawait Promise.all(\n\t\t\t\tentries.map( async ( entry ) => {\n\t\t\t\t\tconst fileContents = await getFilesContents( await getFilesPaths( entry.pattern ) );\n\n\t\t\t\t\tconst entryContent = generateStringsFileContent( fileContents );\n\n\t\t\t\t\t// Writing manually instead of using `chunk.files.add()` in order to avoid passing\n\t\t\t\t\t// the file through the loaders (transpilers, minifiers, etc.).\n\t\t\t\t\tawait fs.promises.writeFile( entry.path, entryContent );\n\t\t\t\t} )\n\t\t\t);\n\t\t} );\n\t}\n\n\tgetEntries( compilation: Compilation ) {\n\t\treturn [ ...compilation.entrypoints ]\n\t\t\t.map( ( [ id, entrypoint ] ) => {\n\t\t\t\tconst chunk = entrypoint.chunks.find( ( { name } ) => name === id );\n\n\t\t\t\tif ( ! chunk ) {\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\n\t\t\t\tconst chunkJSFile = [ ...chunk.files ].find( ( f ) => /\\.(js|ts)$/i.test( f ) );\n\n\t\t\t\tif ( ! chunkJSFile ) {\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\n\t\t\t\tconst { path: basePath } = compilation.options.output;\n\n\t\t\t\tif ( ! basePath ) {\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\n\t\t\t\tconst filePath = createStringsFilePath( compilation.getPath( '[file]', { filename: chunkJSFile } ) );\n\n\t\t\t\treturn {\n\t\t\t\t\tid,\n\t\t\t\t\tchunk,\n\t\t\t\t\tpath: path.join( basePath, filePath ),\n\t\t\t\t\tpattern: this.options.pattern( path.resolve( process.cwd(), entrypoint.origins[ 0 ].request ), id ),\n\t\t\t\t};\n\t\t\t} )\n\t\t\t.filter( Boolean ) as EntrySettings[];\n\t}\n}\n","import { TranslationCallExpression } from './types';\nimport { glob } from 'glob';\nimport * as fs from 'fs';\n\nconst COMMENTS_REGEXPS = [\n\t// Matches translators comment block: `/* translators: %s */`.\n\t/\\/\\*[\\t ]*translators:.*\\*\\//gm,\n\t// Matches translators inline comment: `// translators: %s`.\n\t/(\\/\\/)[\\t ]*translators:[^\\r\\n]*/gm,\n] as const;\n\nconst TRANSLATIONS_REGEXPS = [\n\t// Matches translation functions: `__('Hello', 'elementor')`, `_n('Me', 'Us', 2, 'elementor-pro')`.\n\t/\\b_(?:_|n|nx|x)\\(.*?,\\s*(?<c>['\"`])[\\w-]+\\k<c>\\s*?\\)/gs,\n] as const;\n\nexport function createStringsFilePath( path: string, suffix = '.strings.js' ) {\n\treturn path.replace( /(\\.min)?\\.js$/i, suffix );\n}\n\nexport function getFilesPaths( pattern: string ) {\n\treturn glob( pattern, {\n\t\tignore: {\n\t\t\tignored: ( p ) => ! /\\.(js|ts|jsx|tsx)$/.test( p.name ),\n\t\t\tchildrenIgnored: ( p ) => p.isNamed( '__tests__' ) || p.isNamed( '__mocks__' ),\n\t\t},\n\n\t\t/**\n\t\t * Fix for Windows paths escaping.\n\t\t * Note: This means we don't support paths with special character (like `*`,`?`, etc.)\n\t\t * and only allow patterns that are constructed using `path.join()` or `path.resolve()`.\n\t\t *\n\t\t * @see https://github.com/isaacs/node-glob#options\n\t\t * @see https://github.com/isaacs/node-glob#windows\n\t\t * @see https://github.com/isaacs/node-glob/issues/212#issuecomment-1449062925\n\t\t */\n\t\twindowsPathsNoEscape: true,\n\t} );\n}\n\nexport function getFilesContents( paths: string[] ) {\n\treturn Promise.all( paths.map( ( filePath ) => fs.promises.readFile( filePath, 'utf-8' ) ) );\n}\n\nexport function generateStringsFileContent( contents: string[] ) {\n\treturn (\n\t\tcontents\n\t\t\t.map( ( content ) => extractExpressions( content ) )\n\t\t\t.flat()\n\t\t\t// Add a semicolon when needed.\n\t\t\t.map( ( expr ) => `${ expr.value }${ expr.type === 'comment' ? '' : ';' }` )\n\t\t\t// Join all the expressions to a single string with line-breaks between them.\n\t\t\t.join( '\\n' )\n\t);\n}\n\nfunction extractExpressions( content: string ): TranslationCallExpression[] {\n\tconst expressions: TranslationCallExpression[] = [];\n\n\t[ ...TRANSLATIONS_REGEXPS, ...COMMENTS_REGEXPS ].forEach( ( regexp ) => {\n\t\t[ ...content.matchAll( regexp ) ].forEach( ( res ) => {\n\t\t\texpressions.push( {\n\t\t\t\ttype: COMMENTS_REGEXPS.includes( regexp ) ? 'comment' : 'call-expression',\n\t\t\t\tindex: res.index || 0,\n\t\t\t\tvalue: res[ 0 ],\n\t\t\t} );\n\t\t} );\n\t} );\n\n\t// Sort by the index it was found in the file based on the regexp (and not by the order it was added to the array).\n\treturn expressions.sort( ( a, b ) => a.index - b.index );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,WAAsB;AACtB,IAAAA,MAAoB;;;ACApB,kBAAqB;AACrB,SAAoB;AAEpB,IAAM,mBAAmB;AAAA;AAAA,EAExB;AAAA;AAAA,EAEA;AACD;AAEA,IAAM,uBAAuB;AAAA;AAAA,EAE5B;AACD;AAEO,SAAS,sBAAuBC,OAAc,SAAS,eAAgB;AAC7E,SAAOA,MAAK,QAAS,kBAAkB,MAAO;AAC/C;AAEO,SAAS,cAAe,SAAkB;AAChD,aAAO,kBAAM,SAAS;AAAA,IACrB,QAAQ;AAAA,MACP,SAAS,CAAE,MAAO,CAAE,qBAAqB,KAAM,EAAE,IAAK;AAAA,MACtD,iBAAiB,CAAE,MAAO,EAAE,QAAS,WAAY,KAAK,EAAE,QAAS,WAAY;AAAA,IAC9E;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAWA,s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QACvD,CAAE;AAAA,MACH;AAAA,IACD,CAAE;AAAA,EACH;AAAA,EAEA,WAAY,aAA2B;AACtC,WAAO,CAAE,GAAG,YAAY,WAAY,EAClC,IAAK,CAAE,CAAE,IAAI,UAAW,MAAO;AAC/B,YAAM,QAAQ,WAAW,OAAO,KAAM,CAAE,EAAE,KAAK,MAAO,SAAS,EAAG;AAElE,UAAK,CAAE,OAAQ;AACd,eAAO;AAAA,MACR;AAEA,YAAM,cAAc,CAAE,GAAG,MAAM,KAAM,EAAE,KAAM,CAAE,MAAO,cAAc,KAAM,CAAE,CAAE;AAE9E,UAAK,CAAE,aAAc;AACpB,eAAO;AAAA,MACR;AAEA,YAAM,EAAE,MAAM,SAAS,IAAI,YAAY,QAAQ;AAE/C,UAAK,CAAE,UAAW;AACjB,eAAO;AAAA,MACR;AAEA,YAAM,WAAW,sBAAuB,YAAY,QAAS,UAAU,EAAE,UAAU,YAAY,CAAE,CAAE;AAEnG,aAAO;AAAA,QACN;AAAA,QACA;AAAA,QACA,MAAW,UAAM,UAAU,QAAS;AAAA,QACpC,SAAS,KAAK,QAAQ,QAAc,aAAS,QAAQ,IAAI,GAAG,WAAW,QAAS,CAAE,EAAE,OAAQ,GAAG,EAAG;AAAA,MACnG;AAAA,IACD,CAAE,EACD,OAAQ,OAAQ;AAAA,EACnB;AACD;","names":["fs","path"]}
1
+ {"version":3,"sources":["../src/index.ts","../src/plugin.ts","../src/utils.ts"],"sourcesContent":["export { default as ExtractI18nWordpressExpressionsWebpackPlugin } from './plugin';\n","import * as fs from 'fs';\nimport * as path from 'path';\nimport { type Compilation, type Compiler } from 'webpack';\n\nimport { type EntrySettings } from './types';\nimport { createStringsFilePath, generateStringsFileContent, getFilesContents, getFilesPaths } from './utils';\n\ntype Options = {\n\tpattern: ( entryPath: string, entryId: string ) => string;\n};\n\nexport default class ExtractI18nWordpressExpressionsWebpackPlugin {\n\toptions: Options;\n\n\tconstructor( options: Options ) {\n\t\tthis.options = options;\n\t}\n\n\tapply( compiler: Compiler ) {\n\t\tcompiler.hooks.afterEmit.tapPromise( this.constructor.name, async ( compilation ) => {\n\t\t\tconst entries = this.getEntries( compilation );\n\n\t\t\tawait Promise.all(\n\t\t\t\tentries.map( async ( entry ) => {\n\t\t\t\t\tconst fileContents = await getFilesContents( await getFilesPaths( entry.pattern ) );\n\n\t\t\t\t\tconst entryContent = generateStringsFileContent( fileContents );\n\n\t\t\t\t\t// Writing manually instead of using `chunk.files.add()` in order to avoid passing\n\t\t\t\t\t// the file through the loaders (transpilers, minifiers, etc.).\n\t\t\t\t\tawait fs.promises.writeFile( entry.path, entryContent );\n\t\t\t\t} )\n\t\t\t);\n\t\t} );\n\t}\n\n\tgetEntries( compilation: Compilation ) {\n\t\treturn [ ...compilation.entrypoints ]\n\t\t\t.map( ( [ id, entrypoint ] ) => {\n\t\t\t\tconst chunk = entrypoint.chunks.find( ( { name } ) => name === id );\n\n\t\t\t\tif ( ! chunk ) {\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\n\t\t\t\tconst chunkJSFile = [ ...chunk.files ].find( ( f ) => /\\.(js|ts)$/i.test( f ) );\n\n\t\t\t\tif ( ! chunkJSFile ) {\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\n\t\t\t\tconst { path: basePath } = compilation.options.output;\n\n\t\t\t\tif ( ! basePath ) {\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\n\t\t\t\tconst filePath = createStringsFilePath( compilation.getPath( '[file]', { filename: chunkJSFile } ) );\n\n\t\t\t\treturn {\n\t\t\t\t\tid,\n\t\t\t\t\tchunk,\n\t\t\t\t\tpath: path.join( basePath, filePath ),\n\t\t\t\t\tpattern: this.options.pattern( path.resolve( process.cwd(), entrypoint.origins[ 0 ].request ), id ),\n\t\t\t\t};\n\t\t\t} )\n\t\t\t.filter( Boolean ) as EntrySettings[];\n\t}\n}\n","import * as fs from 'fs';\nimport { glob } from 'glob';\n\nimport { type TranslationCallExpression } from './types';\n\nconst COMMENTS_REGEXPS = [\n\t// Matches translators comment block: `/* translators: %s */`.\n\t/\\/\\*[\\t ]*translators:.*\\*\\//gm,\n\t// Matches translators inline comment: `// translators: %s`.\n\t/(\\/\\/)[\\t ]*translators:[^\\r\\n]*/gm,\n] as const;\n\nconst TRANSLATIONS_REGEXPS = [\n\t// Matches translation functions: `__('Hello', 'elementor')`, `_n('Me', 'Us', 2, 'elementor-pro')`.\n\t/\\b_(?:_|n|nx|x)\\(.*?,\\s*(?<c>['\"`])[\\w-]+\\k<c>\\s*?\\)/gs,\n] as const;\n\nexport function createStringsFilePath( path: string, suffix = '.strings.js' ) {\n\treturn path.replace( /(\\.min)?\\.js$/i, suffix );\n}\n\nexport function getFilesPaths( pattern: string ) {\n\treturn glob( pattern, {\n\t\tignore: {\n\t\t\tignored: ( p ) => ! /\\.(js|ts|jsx|tsx)$/.test( p.name ),\n\t\t\tchildrenIgnored: ( p ) => p.isNamed( '__tests__' ) || p.isNamed( '__mocks__' ),\n\t\t},\n\n\t\t/**\n\t\t * Fix for Windows paths escaping.\n\t\t * Note: This means we don't support paths with special character (like `*`,`?`, etc.)\n\t\t * and only allow patterns that are constructed using `path.join()` or `path.resolve()`.\n\t\t *\n\t\t * @see https://github.com/isaacs/node-glob#options\n\t\t * @see https://github.com/isaacs/node-glob#windows\n\t\t * @see https://github.com/isaacs/node-glob/issues/212#issuecomment-1449062925\n\t\t */\n\t\twindowsPathsNoEscape: true,\n\t} );\n}\n\nexport function getFilesContents( paths: string[] ) {\n\treturn Promise.all( paths.map( ( filePath ) => fs.promises.readFile( filePath, 'utf-8' ) ) );\n}\n\nexport function generateStringsFileContent( contents: string[] ) {\n\treturn (\n\t\tcontents\n\t\t\t.map( ( content ) => extractExpressions( content ) )\n\t\t\t.flat()\n\t\t\t// Add a semicolon when needed.\n\t\t\t.map( ( expr ) => `${ expr.value }${ expr.type === 'comment' ? '' : ';' }` )\n\t\t\t// Join all the expressions to a single string with line-breaks between them.\n\t\t\t.join( '\\n' )\n\t);\n}\n\nfunction extractExpressions( content: string ): TranslationCallExpression[] {\n\tconst expressions: TranslationCallExpression[] = [];\n\n\t[ ...TRANSLATIONS_REGEXPS, ...COMMENTS_REGEXPS ].forEach( ( regexp ) => {\n\t\t[ ...content.matchAll( regexp ) ].forEach( ( res ) => {\n\t\t\texpressions.push( {\n\t\t\t\ttype: COMMENTS_REGEXPS.includes( regexp ) ? 'comment' : 'call-expression',\n\t\t\t\tindex: res.index || 0,\n\t\t\t\tvalue: res[ 0 ],\n\t\t\t} );\n\t\t} );\n\t} );\n\n\t// Sort by the index it was found in the file based on the regexp (and not by the order it was added to the array).\n\treturn expressions.sort( ( a, b ) => a.index - b.index );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,IAAAA,MAAoB;AACpB,WAAsB;;;ACDtB,SAAoB;AACpB,kBAAqB;AAIrB,IAAM,mBAAmB;AAAA;AAAA,EAExB;AAAA;AAAA,EAEA;AACD;AAEA,IAAM,uBAAuB;AAAA;AAAA,EAE5B;AACD;AAEO,SAAS,sBAAuBC,OAAc,SAAS,eAAgB;AAC7E,SAAOA,MAAK,QAAS,kBAAkB,MAAO;AAC/C;AAEO,SAAS,cAAe,SAAkB;AAChD,aAAO,kBAAM,SAAS;AAAA,IACrB,QAAQ;AAAA,MACP,SAAS,CAAE,MAAO,CAAE,qBAAqB,KAAM,EAAE,IAAK;AAAA,MACtD,iBAAiB,CAAE,MAAO,EAAE,QAAS,WAAY,KAAK,EAAE,QAAS,WAAY;AAAA,IAC9E;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAWA,sBAAsB;AAAA,EACvB,CAAE;AACH;AAEO,SAAS,iBAAkB,OAAkB;AACnD,SAAO,QAAQ,IAAK,MAAM,IAAK,CAAE,aAAiB,YAAS,SAAU,UAAU,OAAQ,CAAE,CAAE;AAC5F;AAEO,SAAS,2BAA4B,UAAqB;AAChE,SACC,SAC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AAE,EAAE,KAAK,MAAO,SAAS,EAAG;AAElE,UAAK,CAAE,OAAQ;AACd,eAAO;AAAA,MACR;AAEA,YAAM,cAAc,CAAE,GAAG,MAAM,KAAM,EAAE,KAAM,CAAE,MAAO,cAAc,KAAM,CAAE,CAAE;AAE9E,UAAK,CAAE,aAAc;AACpB,eAAO;AAAA,MACR;AAEA,YAAM,EAAE,MAAM,SAAS,IAAI,YAAY,QAAQ;AAE/C,UAAK,CAAE,UAAW;AACjB,eAAO;AAAA,MACR;AAEA,YAAM,WAAW,sBAAuB,YAAY,QAAS,UAAU,EAAE,UAAU,YAAY,CAAE,CAAE;AAEnG,aAAO;AAAA,QACN;AAAA,QACA;AAAA,QACA,MAAW,UAAM,UAAU,QAAS;AAAA,QACpC,SAAS,KAAK,QAAQ,QAAc,aAAS,QAAQ,IAAI,GAAG,WAAW,QAAS,CAAE,EAAE,OAAQ,GAAG,EAAG;AAAA,MACnG;AAAA,IACD,CAAE,EACD,OAAQ,OAAQ;AAAA,EACnB;AACD;","names":["fs","path"]}
package/dist/index.mjs CHANGED
@@ -1,10 +1,10 @@
1
1
  // src/plugin.ts
2
- import * as path from "path";
3
2
  import * as fs2 from "fs";
3
+ import * as path from "path";
4
4
 
5
5
  // src/utils.ts
6
- import { glob } from "glob";
7
6
  import * as fs from "fs";
7
+ import { glob } from "glob";
8
8
  var COMMENTS_REGEXPS = [
9
9
  // Matches translators comment block: `/* translators: %s */`.
10
10
  /\/\*[\t ]*translators:.*\*\//gm,
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/plugin.ts","../src/utils.ts"],"sourcesContent":["import * as path from 'path';\nimport * as fs from 'fs';\nimport { Compilation, Compiler } from 'webpack';\nimport { EntrySettings } from './types';\nimport { createStringsFilePath, generateStringsFileContent, getFilesContents, getFilesPaths } from './utils';\n\ntype Options = {\n\tpattern: ( entryPath: string, entryId: string ) => string;\n};\n\nexport default class ExtractI18nWordpressExpressionsWebpackPlugin {\n\toptions: Options;\n\n\tconstructor( options: Options ) {\n\t\tthis.options = options;\n\t}\n\n\tapply( compiler: Compiler ) {\n\t\tcompiler.hooks.afterEmit.tapPromise( this.constructor.name, async ( compilation ) => {\n\t\t\tconst entries = this.getEntries( compilation );\n\n\t\t\tawait Promise.all(\n\t\t\t\tentries.map( async ( entry ) => {\n\t\t\t\t\tconst fileContents = await getFilesContents( await getFilesPaths( entry.pattern ) );\n\n\t\t\t\t\tconst entryContent = generateStringsFileContent( fileContents );\n\n\t\t\t\t\t// Writing manually instead of using `chunk.files.add()` in order to avoid passing\n\t\t\t\t\t// the file through the loaders (transpilers, minifiers, etc.).\n\t\t\t\t\tawait fs.promises.writeFile( entry.path, entryContent );\n\t\t\t\t} )\n\t\t\t);\n\t\t} );\n\t}\n\n\tgetEntries( compilation: Compilation ) {\n\t\treturn [ ...compilation.entrypoints ]\n\t\t\t.map( ( [ id, entrypoint ] ) => {\n\t\t\t\tconst chunk = entrypoint.chunks.find( ( { name } ) => name === id );\n\n\t\t\t\tif ( ! chunk ) {\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\n\t\t\t\tconst chunkJSFile = [ ...chunk.files ].find( ( f ) => /\\.(js|ts)$/i.test( f ) );\n\n\t\t\t\tif ( ! chunkJSFile ) {\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\n\t\t\t\tconst { path: basePath } = compilation.options.output;\n\n\t\t\t\tif ( ! basePath ) {\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\n\t\t\t\tconst filePath = createStringsFilePath( compilation.getPath( '[file]', { filename: chunkJSFile } ) );\n\n\t\t\t\treturn {\n\t\t\t\t\tid,\n\t\t\t\t\tchunk,\n\t\t\t\t\tpath: path.join( basePath, filePath ),\n\t\t\t\t\tpattern: this.options.pattern( path.resolve( process.cwd(), entrypoint.origins[ 0 ].request ), id ),\n\t\t\t\t};\n\t\t\t} )\n\t\t\t.filter( Boolean ) as EntrySettings[];\n\t}\n}\n","import { TranslationCallExpression } from './types';\nimport { glob } from 'glob';\nimport * as fs from 'fs';\n\nconst COMMENTS_REGEXPS = [\n\t// Matches translators comment block: `/* translators: %s */`.\n\t/\\/\\*[\\t ]*translators:.*\\*\\//gm,\n\t// Matches translators inline comment: `// translators: %s`.\n\t/(\\/\\/)[\\t ]*translators:[^\\r\\n]*/gm,\n] as const;\n\nconst TRANSLATIONS_REGEXPS = [\n\t// Matches translation functions: `__('Hello', 'elementor')`, `_n('Me', 'Us', 2, 'elementor-pro')`.\n\t/\\b_(?:_|n|nx|x)\\(.*?,\\s*(?<c>['\"`])[\\w-]+\\k<c>\\s*?\\)/gs,\n] as const;\n\nexport function createStringsFilePath( path: string, suffix = '.strings.js' ) {\n\treturn path.replace( /(\\.min)?\\.js$/i, suffix );\n}\n\nexport function getFilesPaths( pattern: string ) {\n\treturn glob( pattern, {\n\t\tignore: {\n\t\t\tignored: ( p ) => ! /\\.(js|ts|jsx|tsx)$/.test( p.name ),\n\t\t\tchildrenIgnored: ( p ) => p.isNamed( '__tests__' ) || p.isNamed( '__mocks__' ),\n\t\t},\n\n\t\t/**\n\t\t * Fix for Windows paths escaping.\n\t\t * Note: This means we don't support paths with special character (like `*`,`?`, etc.)\n\t\t * and only allow patterns that are constructed using `path.join()` or `path.resolve()`.\n\t\t *\n\t\t * @see https://github.com/isaacs/node-glob#options\n\t\t * @see https://github.com/isaacs/node-glob#windows\n\t\t * @see https://github.com/isaacs/node-glob/issues/212#issuecomment-1449062925\n\t\t */\n\t\twindowsPathsNoEscape: true,\n\t} );\n}\n\nexport function getFilesContents( paths: string[] ) {\n\treturn Promise.all( paths.map( ( filePath ) => fs.promises.readFile( filePath, 'utf-8' ) ) );\n}\n\nexport function generateStringsFileContent( contents: string[] ) {\n\treturn (\n\t\tcontents\n\t\t\t.map( ( content ) => extractExpressions( content ) )\n\t\t\t.flat()\n\t\t\t// Add a semicolon when needed.\n\t\t\t.map( ( expr ) => `${ expr.value }${ expr.type === 'comment' ? '' : ';' }` )\n\t\t\t// Join all the expressions to a single string with line-breaks between them.\n\t\t\t.join( '\\n' )\n\t);\n}\n\nfunction extractExpressions( content: string ): TranslationCallExpression[] {\n\tconst expressions: TranslationCallExpression[] = [];\n\n\t[ ...TRANSLATIONS_REGEXPS, ...COMMENTS_REGEXPS ].forEach( ( regexp ) => {\n\t\t[ ...content.matchAll( regexp ) ].forEach( ( res ) => {\n\t\t\texpressions.push( {\n\t\t\t\ttype: COMMENTS_REGEXPS.includes( regexp ) ? 'comment' : 'call-expression',\n\t\t\t\tindex: res.index || 0,\n\t\t\t\tvalue: res[ 0 ],\n\t\t\t} );\n\t\t} );\n\t} );\n\n\t// Sort by the index it was found in the file based on the regexp (and not by the order it was added to the array).\n\treturn expressions.sort( ( a, b ) => a.index - b.index );\n}\n"],"mappings":";AAAA,YAAY,UAAU;AACtB,YAAYA,SAAQ;;;ACApB,SAAS,YAAY;AACrB,YAAY,QAAQ;AAEpB,IAAM,mBAAmB;AAAA;AAAA,EAExB;AAAA;AAAA,EAEA;AACD;AAEA,IAAM,uBAAuB;AAAA;AAAA,EAE5B;AACD;AAEO,SAAS,sBAAuBC,OAAc,SAAS,eAAgB;AAC7E,SAAOA,MAAK,QAAS,kBAAkB,MAAO;AAC/C;AAEO,SAAS,cAAe,SAAkB;AAChD,SAAO,KAAM,SAAS;AAAA,IACrB,QAAQ;AAAA,MACP,SAAS,CAAE,MAAO,CAAE,qBAAqB,KAAM,EAAE,IAAK;AAAA,MACtD,iBAAiB,CAAE,MAAO,EAAE,QAAS,WAAY,KAAK,EAAE,QAAS,WAAY;AAAA,IAC9E;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAWA,sBAAsB;AAAA,EACvB,CAAE;AACH;AAEO,SAAS,iBAAkB,OAAkB;AACnD,SAAO,QAAQ,IAAK,MAAM,IAAK,CAAE,aAAiB,YAAS,SAAU,UAAU,OAAQ,CAAE,CAAE;AAC5F;AAEO,SAAS,2BAA4B,UAAqB;AAChE,SACC,SACE,IAAK,CAAE,YAAa,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O,SAAS,EAAG;AAElE,UAAK,CAAE,OAAQ;AACd,eAAO;AAAA,MACR;AAEA,YAAM,cAAc,CAAE,GAAG,MAAM,KAAM,EAAE,KAAM,CAAE,MAAO,cAAc,KAAM,CAAE,CAAE;AAE9E,UAAK,CAAE,aAAc;AACpB,eAAO;AAAA,MACR;AAEA,YAAM,EAAE,MAAM,SAAS,IAAI,YAAY,QAAQ;AAE/C,UAAK,CAAE,UAAW;AACjB,eAAO;AAAA,MACR;AAEA,YAAM,WAAW,sBAAuB,YAAY,QAAS,UAAU,EAAE,UAAU,YAAY,CAAE,CAAE;AAEnG,aAAO;AAAA,QACN;AAAA,QACA;AAAA,QACA,MAAW,UAAM,UAAU,QAAS;AAAA,QACpC,SAAS,KAAK,QAAQ,QAAc,aAAS,QAAQ,IAAI,GAAG,WAAW,QAAS,CAAE,EAAE,OAAQ,GAAG,EAAG;AAAA,MACnG;AAAA,IACD,CAAE,EACD,OAAQ,OAAQ;AAAA,EACnB;AACD;","names":["fs","path"]}
1
+ {"version":3,"sources":["../src/plugin.ts","../src/utils.ts"],"sourcesContent":["import * as fs from 'fs';\nimport * as path from 'path';\nimport { type Compilation, type Compiler } from 'webpack';\n\nimport { type EntrySettings } from './types';\nimport { createStringsFilePath, generateStringsFileContent, getFilesContents, getFilesPaths } from './utils';\n\ntype Options = {\n\tpattern: ( entryPath: string, entryId: string ) => string;\n};\n\nexport default class ExtractI18nWordpressExpressionsWebpackPlugin {\n\toptions: Options;\n\n\tconstructor( options: Options ) {\n\t\tthis.options = options;\n\t}\n\n\tapply( compiler: Compiler ) {\n\t\tcompiler.hooks.afterEmit.tapPromise( this.constructor.name, async ( compilation ) => {\n\t\t\tconst entries = this.getEntries( compilation );\n\n\t\t\tawait Promise.all(\n\t\t\t\tentries.map( async ( entry ) => {\n\t\t\t\t\tconst fileContents = await getFilesContents( await getFilesPaths( entry.pattern ) );\n\n\t\t\t\t\tconst entryContent = generateStringsFileContent( fileContents );\n\n\t\t\t\t\t// Writing manually instead of using `chunk.files.add()` in order to avoid passing\n\t\t\t\t\t// the file through the loaders (transpilers, minifiers, etc.).\n\t\t\t\t\tawait fs.promises.writeFile( entry.path, entryContent );\n\t\t\t\t} )\n\t\t\t);\n\t\t} );\n\t}\n\n\tgetEntries( compilation: Compilation ) {\n\t\treturn [ ...compilation.entrypoints ]\n\t\t\t.map( ( [ id, entrypoint ] ) => {\n\t\t\t\tconst chunk = entrypoint.chunks.find( ( { name } ) => name === id );\n\n\t\t\t\tif ( ! chunk ) {\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\n\t\t\t\tconst chunkJSFile = [ ...chunk.files ].find( ( f ) => /\\.(js|ts)$/i.test( f ) );\n\n\t\t\t\tif ( ! chunkJSFile ) {\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\n\t\t\t\tconst { path: basePath } = compilation.options.output;\n\n\t\t\t\tif ( ! basePath ) {\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\n\t\t\t\tconst filePath = createStringsFilePath( compilation.getPath( '[file]', { filename: chunkJSFile } ) );\n\n\t\t\t\treturn {\n\t\t\t\t\tid,\n\t\t\t\t\tchunk,\n\t\t\t\t\tpath: path.join( basePath, filePath ),\n\t\t\t\t\tpattern: this.options.pattern( path.resolve( process.cwd(), entrypoint.origins[ 0 ].request ), id ),\n\t\t\t\t};\n\t\t\t} )\n\t\t\t.filter( Boolean ) as EntrySettings[];\n\t}\n}\n","import * as fs from 'fs';\nimport { glob } from 'glob';\n\nimport { type TranslationCallExpression } from './types';\n\nconst COMMENTS_REGEXPS = [\n\t// Matches translators comment block: `/* translators: %s */`.\n\t/\\/\\*[\\t ]*translators:.*\\*\\//gm,\n\t// Matches translators inline comment: `// translators: %s`.\n\t/(\\/\\/)[\\t ]*translators:[^\\r\\n]*/gm,\n] as const;\n\nconst TRANSLATIONS_REGEXPS = [\n\t// Matches translation functions: `__('Hello', 'elementor')`, `_n('Me', 'Us', 2, 'elementor-pro')`.\n\t/\\b_(?:_|n|nx|x)\\(.*?,\\s*(?<c>['\"`])[\\w-]+\\k<c>\\s*?\\)/gs,\n] as const;\n\nexport function createStringsFilePath( path: string, suffix = '.strings.js' ) {\n\treturn path.replace( /(\\.min)?\\.js$/i, suffix );\n}\n\nexport function getFilesPaths( pattern: string ) {\n\treturn glob( pattern, {\n\t\tignore: {\n\t\t\tignored: ( p ) => ! /\\.(js|ts|jsx|tsx)$/.test( p.name ),\n\t\t\tchildrenIgnored: ( p ) => p.isNamed( '__tests__' ) || p.isNamed( '__mocks__' ),\n\t\t},\n\n\t\t/**\n\t\t * Fix for Windows paths escaping.\n\t\t * Note: This means we don't support paths with special character (like `*`,`?`, etc.)\n\t\t * and only allow patterns that are constructed using `path.join()` or `path.resolve()`.\n\t\t *\n\t\t * @see https://github.com/isaacs/node-glob#options\n\t\t * @see https://github.com/isaacs/node-glob#windows\n\t\t * @see https://github.com/isaacs/node-glob/issues/212#issuecomment-1449062925\n\t\t */\n\t\twindowsPathsNoEscape: true,\n\t} );\n}\n\nexport function getFilesContents( paths: string[] ) {\n\treturn Promise.all( paths.map( ( filePath ) => fs.promises.readFile( filePath, 'utf-8' ) ) );\n}\n\nexport function generateStringsFileContent( contents: string[] ) {\n\treturn (\n\t\tcontents\n\t\t\t.map( ( content ) => extractExpressions( content ) )\n\t\t\t.flat()\n\t\t\t// Add a semicolon when needed.\n\t\t\t.map( ( expr ) => `${ expr.value }${ expr.type === 'comment' ? '' : ';' }` )\n\t\t\t// Join all the expressions to a single string with line-breaks between them.\n\t\t\t.join( '\\n' )\n\t);\n}\n\nfunction extractExpressions( content: string ): TranslationCallExpression[] {\n\tconst expressions: TranslationCallExpression[] = [];\n\n\t[ ...TRANSLATIONS_REGEXPS, ...COMMENTS_REGEXPS ].forEach( ( regexp ) => {\n\t\t[ ...content.matchAll( regexp ) ].forEach( ( res ) => {\n\t\t\texpressions.push( {\n\t\t\t\ttype: COMMENTS_REGEXPS.includes( regexp ) ? 'comment' : 'call-expression',\n\t\t\t\tindex: res.index || 0,\n\t\t\t\tvalue: res[ 0 ],\n\t\t\t} );\n\t\t} );\n\t} );\n\n\t// Sort by the index it was found in the file based on the regexp (and not by the order it was added to the array).\n\treturn expressions.sort( ( a, b ) => a.index - b.index );\n}\n"],"mappings":";AAAA,YAAYA,SAAQ;AACpB,YAAY,UAAU;;;ACDtB,YAAY,QAAQ;AACpB,SAAS,YAAY;AAIrB,IAAM,mBAAmB;AAAA;AAAA,EAExB;AAAA;AAAA,EAEA;AACD;AAEA,IAAM,uBAAuB;AAAA;AAAA,EAE5B;AACD;AAEO,SAAS,sBAAuBC,OAAc,SAAS,eAAgB;AAC7E,SAAOA,MAAK,QAAS,kBAAkB,MAAO;AAC/C;AAEO,SAAS,cAAe,SAAkB;AAChD,SAAO,KAAM,SAAS;AAAA,IACrB,QAAQ;AAAA,MACP,SAAS,CAAE,MAAO,CAAE,qBAAqB,KAAM,EAAE,IAAK;AAAA,MACtD,iBAAiB,CAAE,MAAO,EAAE,QAAS,WAAY,KAAK,EAAE,QAAS,WAAY;AAAA,IAC9E;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAWA,sBAAsB;AAAA,EACvB,CAAE;AACH;AAEO,SAAS,iBAAkB,OAAkB;AACnD,SAAO,QAAQ,IAAK,MAAM,IAAK,CAAE,aAAiB,YAAS,SAAU,UAAU,OAAQ,CAAE,CAAE;AAC5F;AAEO,SAAS,2BAA4B,UAAqB;AAChE,SACC,SACE,IAAK,CAAE,YAAa,mBAAoB,OAAQ,CAAE,EAClD,KAAK,EAEL,IAAK,CAAE,SAAU,GAAI,KAAK,KAAM,GAAI,KAAK,SAAS,YAAY,KAAK,GAAI,EAAG,EAE1E,KAAM,IAAK;AAEf;AAEA,SAAS,mBAAoB,SAA+C;AAC3E,QAAM,cAA2C,CAAC;AAElD,GAAE,GAAG,sBAAsB,GAAG,gBAAiB,EAAE,QAAS,CAAE,WAAY;AACvE,KAAE,GAAG,QAAQ,SAAU,MAAO,CAA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YAAM,WAAW,sBAAuB,YAAY,QAAS,UAAU,EAAE,UAAU,YAAY,CAAE,CAAE;AAEnG,aAAO;AAAA,QACN;AAAA,QACA;AAAA,QACA,MAAW,UAAM,UAAU,QAAS;AAAA,QACpC,SAAS,KAAK,QAAQ,QAAc,aAAS,QAAQ,IAAI,GAAG,WAAW,QAAS,CAAE,EAAE,OAAQ,GAAG,EAAG;AAAA,MACnG;AAAA,IACD,CAAE,EACD,OAAQ,OAAQ;AAAA,EACnB;AACD;","names":["fs","path"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elementor/extract-i18n-wordpress-expressions-webpack-plugin",
3
- "version": "0.3.4",
3
+ "version": "0.3.6",
4
4
  "private": false,
5
5
  "author": "Elementor Team",
6
6
  "homepage": "https://elementor.com/",
@@ -39,9 +39,12 @@
39
39
  "dev": "tsup --config=../../tsup.dev.ts --format=esm,cjs"
40
40
  },
41
41
  "peerDependencies": {
42
- "webpack": "5.x"
42
+ "webpack": "^5.0.0"
43
43
  },
44
44
  "dependencies": {
45
- "glob": "^10.3.10"
45
+ "glob": "^11.0.0"
46
+ },
47
+ "devDependencies": {
48
+ "tsup": "^8.3.5"
46
49
  }
47
50
  }
package/src/plugin.ts CHANGED
@@ -1,7 +1,8 @@
1
- import * as path from 'path';
2
1
  import * as fs from 'fs';
3
- import { Compilation, Compiler } from 'webpack';
4
- import { EntrySettings } from './types';
2
+ import * as path from 'path';
3
+ import { type Compilation, type Compiler } from 'webpack';
4
+
5
+ import { type EntrySettings } from './types';
5
6
  import { createStringsFilePath, generateStringsFileContent, getFilesContents, getFilesPaths } from './utils';
6
7
 
7
8
  type Options = {
package/src/types.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Chunk } from 'webpack';
1
+ import { type Chunk } from 'webpack';
2
2
 
3
3
  export type EntrySettings = {
4
4
  id: string;
package/src/utils.ts CHANGED
@@ -1,6 +1,7 @@
1
- import { TranslationCallExpression } from './types';
2
- import { glob } from 'glob';
3
1
  import * as fs from 'fs';
2
+ import { glob } from 'glob';
3
+
4
+ import { type TranslationCallExpression } from './types';
4
5
 
5
6
  const COMMENTS_REGEXPS = [
6
7
  // Matches translators comment block: `/* translators: %s */`.