@elementor/extract-i18n-wordpress-expressions-webpack-plugin 0.3.2 → 0.3.3

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
@@ -3,6 +3,12 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [0.3.3](https://github.com/elementor/elementor-packages/compare/@elementor/extract-i18n-wordpress-expressions-webpack-plugin@0.3.2...@elementor/extract-i18n-wordpress-expressions-webpack-plugin@0.3.3) (2024-08-05)
7
+
8
+ ### Bug Fixes
9
+
10
+ - publish only necessary files to npm ([#226](https://github.com/elementor/elementor-packages/issues/226)) ([d808e2f](https://github.com/elementor/elementor-packages/commit/d808e2f60eb7ca2d7b8560d0b79c0e62c2f969a8))
11
+
6
12
  ## [0.3.2](https://github.com/elementor/elementor-packages/compare/@elementor/extract-i18n-wordpress-expressions-webpack-plugin@0.3.1...@elementor/extract-i18n-wordpress-expressions-webpack-plugin@0.3.2) (2024-07-16)
7
13
 
8
14
  **Note:** Version bump only for package @elementor/extract-i18n-wordpress-expressions-webpack-plugin
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elementor/extract-i18n-wordpress-expressions-webpack-plugin",
3
- "version": "0.3.2",
3
+ "version": "0.3.3",
4
4
  "private": false,
5
5
  "author": "Elementor Team",
6
6
  "homepage": "https://elementor.com/",
@@ -18,7 +18,7 @@
18
18
  },
19
19
  "repository": {
20
20
  "type": "git",
21
- "url": "https://github.com/elementor/elementor-packages.git",
21
+ "url": "git+https://github.com/elementor/elementor-packages.git",
22
22
  "directory": "packages/tools/extract-i18n-wordpress-expressions-webpack-plugin"
23
23
  },
24
24
  "bugs": {
@@ -27,6 +27,13 @@
27
27
  "publishConfig": {
28
28
  "access": "public"
29
29
  },
30
+ "files": [
31
+ "README.md",
32
+ "CHANGELOG.md",
33
+ "/dist",
34
+ "/src",
35
+ "!**/__tests__"
36
+ ],
30
37
  "scripts": {
31
38
  "build": "tsup --config=../../tsup.build.ts",
32
39
  "dev": "tsup --config=../../tsup.dev.ts --format=esm,cjs"
@@ -37,5 +44,5 @@
37
44
  "dependencies": {
38
45
  "glob": "^10.3.10"
39
46
  },
40
- "gitHead": "10fd8663495a9ced2521f27a74879684ed0cf322"
47
+ "gitHead": "f4ca33da0842a29d83736d0a173633085edddaee"
41
48
  }
@@ -1,23 +0,0 @@
1
- // Jest Snapshot v1, https://goo.gl/fbAQLP
2
-
3
- exports[`@elementor/extract-i18n-wordpress-expressions-webpack-plugin should extract translations from scripts 1`] = `
4
- "__(
5
- 'Some long text with multiple lines in the function call',
6
- 'elementor'
7
- );
8
- __( "Unique domain", "some-plugin-slug" );
9
- // translators: %1$s - special placeholder.
10
- __('special placeholder %1$s','elementor' );
11
- // translators: %s - regular comment.
12
- __( 'regular comment %s','elementor');
13
- /* translators: %s - comment block. */
14
- __('comment block %s', 'elementor');
15
- __( 'inside console log', 'elementor' );
16
- _n( 'basic with', 'plural', 2, 'elementor' );
17
- _nx( 'another with' , 'plural' , 2 , 'elementor' );
18
- _x( 'context', 'elementor' );
19
- __('hook','elementor');
20
- __( "Component", 'elementor' );"
21
- `;
22
-
23
- exports[`@elementor/extract-i18n-wordpress-expressions-webpack-plugin should extract translations from scripts 2`] = `"__( 'from app 2', 'elementor' );"`;
@@ -1,142 +0,0 @@
1
- /**
2
- * @jest-environment node
3
- */
4
-
5
- import * as fs from 'fs';
6
- import * as path from 'path';
7
- import { webpack } from 'webpack';
8
- import { ExtractI18nWordpressExpressionsWebpackPlugin } from '../index';
9
- import { vol } from 'memfs';
10
-
11
- jest.mock( 'fs', () => jest.requireActual( 'memfs' ) );
12
-
13
- describe( '@elementor/extract-i18n-wordpress-expressions-webpack-plugin', () => {
14
- beforeEach( () => {
15
- // Entry file.
16
- fs.mkdirSync( path.resolve( '/app/dist' ), { recursive: true } );
17
- fs.writeFileSync( path.resolve( '/app/dist/index.js' ), '' );
18
-
19
- fs.mkdirSync( path.resolve( '/app2/dist' ), { recursive: true } );
20
- fs.writeFileSync( path.resolve( '/app2/dist/index.js' ), '' );
21
-
22
- // Should be in output.
23
- fs.mkdirSync( path.resolve( '/app/src' ), { recursive: true } );
24
- fs.mkdirSync( path.resolve( '/app/src/components' ), { recursive: true } );
25
- fs.mkdirSync( path.resolve( '/app/src/hooks' ), { recursive: true } );
26
-
27
- fs.writeFileSync(
28
- path.resolve( '/app/src/components/component.js' ),
29
- `
30
- export default function Component() {
31
- return __( "Component", 'elementor' );
32
- }
33
- `
34
- );
35
-
36
- fs.writeFileSync(
37
- path.resolve( '/app/src/hooks/hook.ts' ),
38
- `
39
- export default function useHook() {
40
- return __('hook','elementor');
41
- }
42
- `
43
- );
44
-
45
- fs.writeFileSync(
46
- path.resolve( '/app/src/index.js' ),
47
- `
48
- export default function Index() {
49
- __(
50
- 'Some long text with multiple lines in the function call',
51
- 'elementor'
52
- );
53
-
54
- __( "Unique domain", "some-plugin-slug" );
55
-
56
- // translators: %1$s - special placeholder.
57
- const withSpecialPlaceHolder = __('special placeholder %1$s','elementor' );
58
-
59
- // translators: %s - regular comment.
60
- const withComment = __( 'regular comment %s','elementor');
61
-
62
- /* translators: %s - comment block. */
63
- const withCommentBlock = __('comment block %s', 'elementor');
64
-
65
- console.log(__( 'inside console log', 'elementor' ))
66
-
67
- return [
68
- _n( 'basic with', 'plural', 2, 'elementor' ),
69
- _nx( 'another with' , 'plural' , 2 , 'elementor' ),
70
- _x( 'context', 'elementor' ),
71
- invalid__( 'invalid', 'elementor' ),
72
- ];
73
- }
74
- `
75
- );
76
-
77
- fs.mkdirSync( path.resolve( '/app2/src' ), { recursive: true } );
78
- fs.writeFileSync(
79
- path.resolve( '/app2/src/index.js' ),
80
- `
81
- export const test = __( 'from app 2', 'elementor' );
82
- `
83
- );
84
-
85
- // Should not be in output.
86
- const ignoredContent = `
87
- export default function ShouldIgnoreComponent() {
88
- return __('should ignore','elementor');
89
- }
90
- `;
91
-
92
- fs.mkdirSync( path.resolve( '/app/fake-src' ), { recursive: true } );
93
- fs.writeFileSync( path.resolve( '/app/fake-src/index.js' ), ignoredContent );
94
-
95
- fs.mkdirSync( path.resolve( '/app/src/__tests__' ), { recursive: true } );
96
- fs.writeFileSync( path.resolve( '/app/src/__tests__/mock.test.js' ), ignoredContent );
97
-
98
- fs.writeFileSync( path.resolve( '/app/src/not-a-js-file.txt' ), ignoredContent );
99
- } );
100
-
101
- afterEach( () => {
102
- vol.reset();
103
- } );
104
-
105
- it( 'should extract translations from scripts', ( done ) => {
106
- // Arrange.
107
- const compiler = webpack( {
108
- mode: 'development',
109
- entry: {
110
- app: path.resolve( '/app/dist/index.js' ),
111
- app2: path.resolve( '/app2/dist/index.js' ),
112
- },
113
- output: {
114
- filename: '[name]/[name].js',
115
- path: path.resolve( '/output' ),
116
- },
117
- plugins: [
118
- new ExtractI18nWordpressExpressionsWebpackPlugin( {
119
- pattern: ( entryPath ) => path.resolve( entryPath, '../../src/**/*.{ts,tsx,js,jsx}' ),
120
- } ),
121
- ],
122
- } );
123
-
124
- // Act.
125
- compiler.run( ( err, stats ) => {
126
- // Assert.
127
- expect( err ).toBe( null );
128
- expect( stats?.hasErrors() ).toBe( false );
129
- expect( stats?.hasWarnings() ).toBe( false );
130
-
131
- expect(
132
- fs.readFileSync( path.resolve( `/output/app/app.strings.js` ), { encoding: 'utf8' } )
133
- ).toMatchSnapshot();
134
-
135
- expect(
136
- fs.readFileSync( path.resolve( `/output/app2/app2.strings.js` ), { encoding: 'utf8' } )
137
- ).toMatchSnapshot();
138
-
139
- done();
140
- } );
141
- } );
142
- } );