@formatjs/cli-lib 6.1.5 → 6.2.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": "@formatjs/cli-lib",
3
- "version": "6.1.5",
3
+ "version": "6.2.0",
4
4
  "description": "Lib for CLI for formatjs.",
5
5
  "keywords": [
6
6
  "intl",
@@ -47,11 +47,11 @@
47
47
  "typescript": "^4.7 || 5"
48
48
  },
49
49
  "peerDependencies": {
50
- "@vue/compiler-core": "^3.2.23",
51
- "@vue/compiler-sfc": "^3.2.34"
50
+ "@vue/compiler-core": "^3.3.4",
51
+ "vue": "^3.3.4"
52
52
  },
53
53
  "peerDependenciesMeta": {
54
- "@vue/compiler-sfc": {
54
+ "vue": {
55
55
  "optional": true
56
56
  },
57
57
  "@vue/compiler-core": {
package/src/extract.js CHANGED
@@ -153,6 +153,9 @@ ${JSON.stringify(message, undefined, 2)}`);
153
153
  }
154
154
  results[id] = msg;
155
155
  }
156
+ if (typeof formatter.serialize === 'function') {
157
+ return formatter.serialize(formatter.format(results));
158
+ }
156
159
  return (0, json_stable_stringify_1.default)(formatter.format(results), {
157
160
  space: 2,
158
161
  cmp: formatter.compareMessages || undefined,
@@ -1,5 +1,6 @@
1
1
  import { MessageDescriptor } from '@formatjs/ts-transformer';
2
2
  export type FormatFn<T = Record<string, MessageDescriptor>> = (msgs: Record<string, MessageDescriptor>) => T;
3
3
  export type CompileFn<T = Record<string, MessageDescriptor>> = (msgs: T) => Record<string, string>;
4
+ export type SerializeFn<T = Record<string, MessageDescriptor>> = (msgs: T) => string;
4
5
  export declare const format: FormatFn;
5
6
  export declare const compile: CompileFn;
@@ -1,6 +1,7 @@
1
- import { FormatFn, CompileFn } from './default';
2
- import { Comparator } from 'json-stable-stringify';
1
+ import { FormatFn, SerializeFn, CompileFn } from './default';
2
+ import type { Comparator } from 'json-stable-stringify';
3
3
  export interface Formatter {
4
+ serialize: SerializeFn;
4
5
  format: FormatFn;
5
6
  compile: CompileFn;
6
7
  compareMessages?: Comparator;
@@ -1,4 +1,4 @@
1
- import { Comparator } from 'json-stable-stringify';
1
+ import type { Comparator } from 'json-stable-stringify';
2
2
  import { CompileFn, FormatFn } from './default';
3
3
  export interface SmartlingDirectives {
4
4
  translate_paths: [
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.parseFile = void 0;
4
- const compiler_sfc_1 = require("@vue/compiler-sfc");
4
+ const compiler_sfc_1 = require("vue/compiler-sfc");
5
5
  // Duplicate `NodeTypes` here because they are defined as
6
6
  // const enum, which does not work with swc transpilation: https://github.com/vuejs/core/issues/1228
7
7
  const ELEMENT = 1;
@@ -45,7 +45,12 @@ function templateSimpleExpressionNodeVisitor(parseScriptFn) {
45
45
  // Wrap this in () since a vue comp node attribute can just be
46
46
  // an object literal which, by itself is invalid TS
47
47
  // but with () it becomes an ExpressionStatement
48
- parseScriptFn(`(${content})`);
48
+ try {
49
+ parseScriptFn(`(${content})`);
50
+ }
51
+ catch (e) {
52
+ console.warn(`Failed to parse "${content}". Ignore this if content has no extractable message`, e);
53
+ }
49
54
  };
50
55
  }
51
56
  function parseFile(source, filename, parseScriptFn) {