@internationalized/string-compiler 3.2.6 → 3.3.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@internationalized/string-compiler",
3
- "version": "3.2.6",
3
+ "version": "3.3.0",
4
4
  "description": "Localized string compiler for @internationalized/string",
5
5
  "license": "Apache-2.0",
6
6
  "main": "src/stringCompiler.js",
@@ -19,5 +19,5 @@
19
19
  "publishConfig": {
20
20
  "access": "public"
21
21
  },
22
- "gitHead": "71f0ef23053f9e03ee7e97df736e8b083e006849"
22
+ "gitHead": "66e51757606b43a89ed02c574ca24517323a2ab9"
23
23
  }
@@ -10,8 +10,16 @@
10
10
  * governing permissions and limitations under the License.
11
11
  */
12
12
 
13
+ interface Options {
14
+ /**
15
+ * Output module format.
16
+ * @default 'cjs'
17
+ */
18
+ format?: 'cjs' | 'esm'
19
+ }
20
+
13
21
  /** Compiles an object containing ICU message strings to a JavaScript module. */
14
- export function compileStrings(messages: Record<string, string>): string;
22
+ export function compileStrings(messages: Record<string, string>, options?: Options): string;
15
23
 
16
24
  /** Compiles a single ICU message string to JavaScript source code. */
17
25
  export function compileString(message: string): string;
@@ -12,8 +12,8 @@
12
12
 
13
13
  const {parse, TYPE} = require('@formatjs/icu-messageformat-parser');
14
14
 
15
- function compileStrings(messages) {
16
- let res = 'module.exports = {';
15
+ function compileStrings(messages, options) {
16
+ let res = options?.format === 'esm' ? 'export default {' : 'module.exports = {';
17
17
  for (let key in messages) {
18
18
  res += ' ' + JSON.stringify(key) + ': ' + compileString(messages[key]) + ',\n';
19
19
  }