@formatjs/ts-transformer 3.9.10 → 3.9.11

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.
Files changed (60) hide show
  1. package/index.d.ts +4 -0
  2. package/index.d.ts.map +1 -0
  3. package/index.js +6 -0
  4. package/package.json +2 -2
  5. package/src/console_utils.d.ts +4 -0
  6. package/src/console_utils.d.ts.map +1 -0
  7. package/src/console_utils.js +31 -0
  8. package/src/interpolate-name.d.ts +15 -0
  9. package/src/interpolate-name.d.ts.map +1 -0
  10. package/src/interpolate-name.js +90 -0
  11. package/src/transform.d.ts +78 -0
  12. package/src/transform.d.ts.map +1 -0
  13. package/src/transform.js +479 -0
  14. package/src/types.d.ts +12 -0
  15. package/src/types.d.ts.map +1 -0
  16. package/src/types.js +2 -0
  17. package/ts-jest-integration.d.ts +6 -0
  18. package/ts-jest-integration.d.ts.map +1 -0
  19. package/ts-jest-integration.js +10 -0
  20. package/BUILD +0 -82
  21. package/CHANGELOG.md +0 -713
  22. package/examples/compile.ts +0 -50
  23. package/index.ts +0 -3
  24. package/integration-tests/BUILD +0 -37
  25. package/integration-tests/integration/comp.tsx +0 -40
  26. package/integration-tests/integration/jest.config.js +0 -25
  27. package/integration-tests/integration/ts-jest.test.tsx +0 -32
  28. package/integration-tests/package.json +0 -5
  29. package/integration-tests/vue/fixtures/index.vue +0 -30
  30. package/integration-tests/vue/fixtures/main.ts +0 -4
  31. package/integration-tests/vue/integration.test.ts +0 -75
  32. package/src/console_utils.ts +0 -32
  33. package/src/interpolate-name.ts +0 -147
  34. package/src/transform.ts +0 -764
  35. package/src/types.ts +0 -12
  36. package/tests/__snapshots__/index.test.ts.snap +0 -908
  37. package/tests/fixtures/FormattedMessage.tsx +0 -35
  38. package/tests/fixtures/additionalComponentNames.tsx +0 -16
  39. package/tests/fixtures/additionalFunctionNames.tsx +0 -20
  40. package/tests/fixtures/ast.tsx +0 -83
  41. package/tests/fixtures/defineMessages.tsx +0 -67
  42. package/tests/fixtures/defineMessagesPreserveWhitespace.tsx +0 -87
  43. package/tests/fixtures/descriptionsAsObjects.tsx +0 -17
  44. package/tests/fixtures/extractFromFormatMessage.tsx +0 -45
  45. package/tests/fixtures/extractFromFormatMessageStateless.tsx +0 -46
  46. package/tests/fixtures/extractSourceLocation.tsx +0 -8
  47. package/tests/fixtures/formatMessageCall.tsx +0 -44
  48. package/tests/fixtures/inline.tsx +0 -26
  49. package/tests/fixtures/nested.tsx +0 -10
  50. package/tests/fixtures/noImport.tsx +0 -52
  51. package/tests/fixtures/overrideIdFn.tsx +0 -70
  52. package/tests/fixtures/removeDefaultMessage.tsx +0 -22
  53. package/tests/fixtures/removeDescription.tsx +0 -22
  54. package/tests/fixtures/resourcePath.tsx +0 -23
  55. package/tests/fixtures/stringConcat.tsx +0 -26
  56. package/tests/fixtures/templateLiteral.tsx +0 -21
  57. package/tests/index.test.ts +0 -127
  58. package/tests/interpolate-name.test.ts +0 -14
  59. package/ts-jest-integration.ts +0 -9
  60. package/tsconfig.json +0 -5
@@ -0,0 +1,479 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.transform = exports.transformWithTs = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const typescript = tslib_1.__importStar(require("typescript"));
6
+ const interpolate_name_1 = require("./interpolate-name");
7
+ const icu_messageformat_parser_1 = require("@formatjs/icu-messageformat-parser");
8
+ const console_utils_1 = require("./console_utils");
9
+ const json_stable_stringify_1 = tslib_1.__importDefault(require("json-stable-stringify"));
10
+ const MESSAGE_DESC_KEYS = [
11
+ 'id',
12
+ 'defaultMessage',
13
+ 'description',
14
+ ];
15
+ function primitiveToTSNode(factory, v) {
16
+ return typeof v === 'string'
17
+ ? factory.createStringLiteral(v)
18
+ : typeof v === 'number'
19
+ ? factory.createNumericLiteral(v + '')
20
+ : typeof v === 'boolean'
21
+ ? v
22
+ ? factory.createTrue()
23
+ : factory.createFalse()
24
+ : undefined;
25
+ }
26
+ function isValidIdentifier(k) {
27
+ try {
28
+ new Function(`return {${k}:1}`);
29
+ return true;
30
+ }
31
+ catch (e) {
32
+ return false;
33
+ }
34
+ }
35
+ function objToTSNode(factory, obj) {
36
+ if (typeof obj === 'object' && !obj) {
37
+ return factory.createNull();
38
+ }
39
+ const props = Object.entries(obj)
40
+ .filter(([_, v]) => typeof v !== 'undefined')
41
+ .map(([k, v]) => factory.createPropertyAssignment(isValidIdentifier(k) ? k : factory.createStringLiteral(k), primitiveToTSNode(factory, v) ||
42
+ (Array.isArray(v)
43
+ ? factory.createArrayLiteralExpression(v
44
+ .filter(n => typeof n !== 'undefined')
45
+ .map(n => objToTSNode(factory, n)))
46
+ : objToTSNode(factory, v))));
47
+ return factory.createObjectLiteralExpression(props);
48
+ }
49
+ function messageASTToTSNode(factory, ast) {
50
+ return factory.createArrayLiteralExpression(ast.map(el => objToTSNode(factory, el)));
51
+ }
52
+ function literalToObj(ts, n) {
53
+ if (ts.isNumericLiteral(n)) {
54
+ return +n.text;
55
+ }
56
+ if (ts.isStringLiteral(n)) {
57
+ return n.text;
58
+ }
59
+ if (n.kind === ts.SyntaxKind.TrueKeyword) {
60
+ return true;
61
+ }
62
+ if (n.kind === ts.SyntaxKind.FalseKeyword) {
63
+ return false;
64
+ }
65
+ }
66
+ function objectLiteralExpressionToObj(ts, obj) {
67
+ return obj.properties.reduce((all, prop) => {
68
+ if (ts.isPropertyAssignment(prop) && prop.name) {
69
+ if (ts.isIdentifier(prop.name)) {
70
+ all[prop.name.escapedText.toString()] = literalToObj(ts, prop.initializer);
71
+ }
72
+ else if (ts.isStringLiteral(prop.name)) {
73
+ all[prop.name.text] = literalToObj(ts, prop.initializer);
74
+ }
75
+ }
76
+ return all;
77
+ }, {});
78
+ }
79
+ const DEFAULT_OPTS = {
80
+ onMsgExtracted: () => undefined,
81
+ onMetaExtracted: () => undefined,
82
+ };
83
+ function isMultipleMessageDecl(ts, node) {
84
+ return (ts.isIdentifier(node.expression) &&
85
+ node.expression.text === 'defineMessages');
86
+ }
87
+ function isSingularMessageDecl(ts, node, additionalComponentNames) {
88
+ const compNames = new Set([
89
+ 'FormattedMessage',
90
+ 'defineMessage',
91
+ 'formatMessage',
92
+ '$formatMessage',
93
+ ...additionalComponentNames,
94
+ ]);
95
+ let fnName = '';
96
+ if (ts.isCallExpression(node) && ts.isIdentifier(node.expression)) {
97
+ fnName = node.expression.text;
98
+ }
99
+ else if (ts.isJsxOpeningElement(node) && ts.isIdentifier(node.tagName)) {
100
+ fnName = node.tagName.text;
101
+ }
102
+ else if (ts.isJsxSelfClosingElement(node) &&
103
+ ts.isIdentifier(node.tagName)) {
104
+ fnName = node.tagName.text;
105
+ }
106
+ return compNames.has(fnName);
107
+ }
108
+ function evaluateStringConcat(ts, node) {
109
+ const { right, left } = node;
110
+ if (!ts.isStringLiteral(right)) {
111
+ return ['', false];
112
+ }
113
+ if (ts.isStringLiteral(left)) {
114
+ return [left.text + right.text, true];
115
+ }
116
+ if (ts.isBinaryExpression(left)) {
117
+ const [result, isStatic] = evaluateStringConcat(ts, left);
118
+ return [result + right.text, isStatic];
119
+ }
120
+ return ['', false];
121
+ }
122
+ function extractMessageDescriptor(ts, node, { overrideIdFn, extractSourceLocation, preserveWhitespace }, sf) {
123
+ let properties = undefined;
124
+ if (ts.isObjectLiteralExpression(node)) {
125
+ properties = node.properties;
126
+ }
127
+ else if (ts.isJsxOpeningElement(node) || ts.isJsxSelfClosingElement(node)) {
128
+ properties = node.attributes.properties;
129
+ }
130
+ const msg = { id: '' };
131
+ if (!properties) {
132
+ return;
133
+ }
134
+ properties.forEach(prop => {
135
+ const { name } = prop;
136
+ const initializer = ts.isPropertyAssignment(prop) || ts.isJsxAttribute(prop)
137
+ ? prop.initializer
138
+ : undefined;
139
+ if (name && ts.isIdentifier(name) && initializer) {
140
+ // {id: 'id'}
141
+ if (ts.isStringLiteral(initializer)) {
142
+ switch (name.text) {
143
+ case 'id':
144
+ msg.id = initializer.text;
145
+ break;
146
+ case 'defaultMessage':
147
+ msg.defaultMessage = initializer.text;
148
+ break;
149
+ case 'description':
150
+ msg.description = initializer.text;
151
+ break;
152
+ }
153
+ }
154
+ // {id: `id`}
155
+ else if (ts.isNoSubstitutionTemplateLiteral(initializer)) {
156
+ switch (name.text) {
157
+ case 'id':
158
+ msg.id = initializer.text;
159
+ break;
160
+ case 'defaultMessage':
161
+ msg.defaultMessage = initializer.text;
162
+ break;
163
+ case 'description':
164
+ msg.description = initializer.text;
165
+ break;
166
+ }
167
+ }
168
+ else if (ts.isJsxExpression(initializer) && initializer.expression) {
169
+ // <FormattedMessage foo={'barbaz'} />
170
+ if (ts.isStringLiteral(initializer.expression)) {
171
+ switch (name.text) {
172
+ case 'id':
173
+ msg.id = initializer.expression.text;
174
+ break;
175
+ case 'defaultMessage':
176
+ msg.defaultMessage = initializer.expression.text;
177
+ break;
178
+ case 'description':
179
+ msg.description = initializer.expression.text;
180
+ break;
181
+ }
182
+ }
183
+ // description={{custom: 1}}
184
+ else if (ts.isObjectLiteralExpression(initializer.expression) &&
185
+ name.text === 'description') {
186
+ msg.description = objectLiteralExpressionToObj(ts, initializer.expression);
187
+ }
188
+ // <FormattedMessage foo={`bar`} />
189
+ else if (ts.isNoSubstitutionTemplateLiteral(initializer.expression)) {
190
+ const { expression } = initializer;
191
+ switch (name.text) {
192
+ case 'id':
193
+ msg.id = expression.text;
194
+ break;
195
+ case 'defaultMessage':
196
+ msg.defaultMessage = expression.text;
197
+ break;
198
+ case 'description':
199
+ msg.description = expression.text;
200
+ break;
201
+ }
202
+ }
203
+ // <FormattedMessage foo={'bar' + 'baz'} />
204
+ else if (ts.isBinaryExpression(initializer.expression)) {
205
+ const { expression } = initializer;
206
+ const [result, isStatic] = evaluateStringConcat(ts, expression);
207
+ if (isStatic) {
208
+ switch (name.text) {
209
+ case 'id':
210
+ msg.id = result;
211
+ break;
212
+ case 'defaultMessage':
213
+ msg.defaultMessage = result;
214
+ break;
215
+ case 'description':
216
+ msg.description = result;
217
+ break;
218
+ }
219
+ }
220
+ }
221
+ }
222
+ // {defaultMessage: 'asd' + bar'}
223
+ else if (ts.isBinaryExpression(initializer)) {
224
+ const [result, isStatic] = evaluateStringConcat(ts, initializer);
225
+ if (isStatic) {
226
+ switch (name.text) {
227
+ case 'id':
228
+ msg.id = result;
229
+ break;
230
+ case 'defaultMessage':
231
+ msg.defaultMessage = result;
232
+ break;
233
+ case 'description':
234
+ msg.description = result;
235
+ break;
236
+ }
237
+ }
238
+ }
239
+ // description: {custom: 1}
240
+ else if (ts.isObjectLiteralExpression(initializer) &&
241
+ name.text === 'description') {
242
+ msg.description = objectLiteralExpressionToObj(ts, initializer);
243
+ }
244
+ }
245
+ });
246
+ // We extracted nothing
247
+ if (!msg.defaultMessage && !msg.id) {
248
+ return;
249
+ }
250
+ if (msg.defaultMessage && !preserveWhitespace) {
251
+ msg.defaultMessage = msg.defaultMessage.trim().replace(/\s+/gm, ' ');
252
+ }
253
+ if (msg.defaultMessage && overrideIdFn) {
254
+ switch (typeof overrideIdFn) {
255
+ case 'string':
256
+ if (!msg.id) {
257
+ msg.id = (0, interpolate_name_1.interpolateName)({ resourcePath: sf.fileName }, overrideIdFn, {
258
+ content: msg.description
259
+ ? `${msg.defaultMessage}#${typeof msg.description === 'string'
260
+ ? msg.description
261
+ : (0, json_stable_stringify_1.default)(msg.description)}`
262
+ : msg.defaultMessage,
263
+ });
264
+ }
265
+ break;
266
+ case 'function':
267
+ msg.id = overrideIdFn(msg.id, msg.defaultMessage, msg.description, sf.fileName);
268
+ break;
269
+ }
270
+ }
271
+ if (extractSourceLocation) {
272
+ return {
273
+ ...msg,
274
+ file: sf.fileName,
275
+ start: node.pos,
276
+ end: node.end,
277
+ };
278
+ }
279
+ return msg;
280
+ }
281
+ /**
282
+ * Check if node is `foo.bar.formatMessage` node
283
+ * @param node
284
+ * @param sf
285
+ */
286
+ function isMemberMethodFormatMessageCall(ts, node, additionalFunctionNames) {
287
+ const fnNames = new Set([
288
+ 'formatMessage',
289
+ '$formatMessage',
290
+ ...additionalFunctionNames,
291
+ ]);
292
+ const method = node.expression;
293
+ // Handle foo.formatMessage()
294
+ if (ts.isPropertyAccessExpression(method)) {
295
+ return fnNames.has(method.name.text);
296
+ }
297
+ // Handle formatMessage()
298
+ return ts.isIdentifier(method) && fnNames.has(method.text);
299
+ }
300
+ function extractMessageFromJsxComponent(ts, factory, node, opts, sf) {
301
+ const { onMsgExtracted } = opts;
302
+ if (!isSingularMessageDecl(ts, node, opts.additionalComponentNames || [])) {
303
+ return node;
304
+ }
305
+ const msg = extractMessageDescriptor(ts, node, opts, sf);
306
+ if (!msg) {
307
+ return node;
308
+ }
309
+ if (typeof onMsgExtracted === 'function') {
310
+ onMsgExtracted(sf.fileName, [msg]);
311
+ }
312
+ const newProps = generateNewProperties(ts, factory, node.attributes, {
313
+ defaultMessage: opts.removeDefaultMessage
314
+ ? undefined
315
+ : msg.defaultMessage,
316
+ id: msg.id,
317
+ }, opts.ast);
318
+ if (ts.isJsxOpeningElement(node)) {
319
+ return factory.updateJsxOpeningElement(node, node.tagName, node.typeArguments, factory.createJsxAttributes(newProps));
320
+ }
321
+ return factory.updateJsxSelfClosingElement(node, node.tagName, node.typeArguments, factory.createJsxAttributes(newProps));
322
+ }
323
+ function setAttributesInObject(ts, factory, node, msg, ast) {
324
+ const newProps = [
325
+ factory.createPropertyAssignment('id', factory.createStringLiteral(msg.id)),
326
+ ...(msg.defaultMessage
327
+ ? [
328
+ factory.createPropertyAssignment('defaultMessage', ast
329
+ ? messageASTToTSNode(factory, (0, icu_messageformat_parser_1.parse)(msg.defaultMessage))
330
+ : factory.createStringLiteral(msg.defaultMessage)),
331
+ ]
332
+ : []),
333
+ ];
334
+ for (const prop of node.properties) {
335
+ if (ts.isPropertyAssignment(prop) &&
336
+ ts.isIdentifier(prop.name) &&
337
+ MESSAGE_DESC_KEYS.includes(prop.name.text)) {
338
+ continue;
339
+ }
340
+ if (ts.isPropertyAssignment(prop)) {
341
+ newProps.push(prop);
342
+ }
343
+ }
344
+ return factory.createObjectLiteralExpression(factory.createNodeArray(newProps));
345
+ }
346
+ function generateNewProperties(ts, factory, node, msg, ast) {
347
+ const newProps = [
348
+ factory.createJsxAttribute(factory.createIdentifier('id'), factory.createStringLiteral(msg.id)),
349
+ ...(msg.defaultMessage
350
+ ? [
351
+ factory.createJsxAttribute(factory.createIdentifier('defaultMessage'), ast
352
+ ? factory.createJsxExpression(undefined, messageASTToTSNode(factory, (0, icu_messageformat_parser_1.parse)(msg.defaultMessage)))
353
+ : factory.createStringLiteral(msg.defaultMessage)),
354
+ ]
355
+ : []),
356
+ ];
357
+ for (const prop of node.properties) {
358
+ if (ts.isJsxAttribute(prop) &&
359
+ ts.isIdentifier(prop.name) &&
360
+ MESSAGE_DESC_KEYS.includes(prop.name.text)) {
361
+ continue;
362
+ }
363
+ if (ts.isJsxAttribute(prop)) {
364
+ newProps.push(prop);
365
+ }
366
+ }
367
+ return newProps;
368
+ }
369
+ function extractMessagesFromCallExpression(ts, factory, node, opts, sf) {
370
+ const { onMsgExtracted, additionalFunctionNames } = opts;
371
+ if (isMultipleMessageDecl(ts, node)) {
372
+ const [arg, ...restArgs] = node.arguments;
373
+ let descriptorsObj;
374
+ if (ts.isObjectLiteralExpression(arg)) {
375
+ descriptorsObj = arg;
376
+ }
377
+ else if (ts.isAsExpression(arg) &&
378
+ ts.isObjectLiteralExpression(arg.expression)) {
379
+ descriptorsObj = arg.expression;
380
+ }
381
+ if (descriptorsObj) {
382
+ const properties = descriptorsObj.properties;
383
+ const msgs = properties
384
+ .filter((prop) => ts.isPropertyAssignment(prop))
385
+ .map(prop => ts.isObjectLiteralExpression(prop.initializer) &&
386
+ extractMessageDescriptor(ts, prop.initializer, opts, sf))
387
+ .filter((msg) => !!msg);
388
+ if (!msgs.length) {
389
+ return node;
390
+ }
391
+ (0, console_utils_1.debug)('Multiple messages extracted from "%s": %s', sf.fileName, msgs);
392
+ if (typeof onMsgExtracted === 'function') {
393
+ onMsgExtracted(sf.fileName, msgs);
394
+ }
395
+ const clonedProperties = factory.createNodeArray(properties.map((prop, i) => {
396
+ if (!ts.isPropertyAssignment(prop) ||
397
+ !ts.isObjectLiteralExpression(prop.initializer)) {
398
+ return prop;
399
+ }
400
+ return factory.createPropertyAssignment(prop.name, setAttributesInObject(ts, factory, prop.initializer, {
401
+ defaultMessage: opts.removeDefaultMessage
402
+ ? undefined
403
+ : msgs[i].defaultMessage,
404
+ id: msgs[i] ? msgs[i].id : '',
405
+ }, opts.ast));
406
+ }));
407
+ const clonedDescriptorsObj = factory.createObjectLiteralExpression(clonedProperties);
408
+ return factory.updateCallExpression(node, node.expression, node.typeArguments, [clonedDescriptorsObj, ...restArgs]);
409
+ }
410
+ }
411
+ else if (isSingularMessageDecl(ts, node, opts.additionalComponentNames || []) ||
412
+ isMemberMethodFormatMessageCall(ts, node, additionalFunctionNames || [])) {
413
+ const [descriptorsObj, ...restArgs] = node.arguments;
414
+ if (ts.isObjectLiteralExpression(descriptorsObj)) {
415
+ const msg = extractMessageDescriptor(ts, descriptorsObj, opts, sf);
416
+ if (!msg) {
417
+ return node;
418
+ }
419
+ (0, console_utils_1.debug)('Message extracted from "%s": %s', sf.fileName, msg);
420
+ if (typeof onMsgExtracted === 'function') {
421
+ onMsgExtracted(sf.fileName, [msg]);
422
+ }
423
+ return factory.updateCallExpression(node, node.expression, node.typeArguments, [
424
+ setAttributesInObject(ts, factory, descriptorsObj, {
425
+ defaultMessage: opts.removeDefaultMessage
426
+ ? undefined
427
+ : msg.defaultMessage,
428
+ id: msg.id,
429
+ }, opts.ast),
430
+ ...restArgs,
431
+ ]);
432
+ }
433
+ }
434
+ return node;
435
+ }
436
+ const PRAGMA_REGEX = /^\/\/ @([^\s]*) (.*)$/m;
437
+ function getVisitor(ts, ctx, sf, opts) {
438
+ const visitor = (node) => {
439
+ const newNode = ts.isCallExpression(node)
440
+ ? extractMessagesFromCallExpression(ts, ctx.factory, node, opts, sf)
441
+ : ts.isJsxOpeningElement(node) || ts.isJsxSelfClosingElement(node)
442
+ ? extractMessageFromJsxComponent(ts, ctx.factory, node, opts, sf)
443
+ : node;
444
+ return ts.visitEachChild(newNode, visitor, ctx);
445
+ };
446
+ return visitor;
447
+ }
448
+ function transformWithTs(ts, opts) {
449
+ opts = { ...DEFAULT_OPTS, ...opts };
450
+ (0, console_utils_1.debug)('Transforming options', opts);
451
+ const transformFn = ctx => {
452
+ return (sf) => {
453
+ const pragmaResult = PRAGMA_REGEX.exec(sf.text);
454
+ if (pragmaResult) {
455
+ (0, console_utils_1.debug)('Pragma found', pragmaResult);
456
+ const [, pragma, kvString] = pragmaResult;
457
+ if (pragma === opts.pragma) {
458
+ const kvs = kvString.split(' ');
459
+ const result = {};
460
+ for (const kv of kvs) {
461
+ const [k, v] = kv.split(':');
462
+ result[k] = v;
463
+ }
464
+ (0, console_utils_1.debug)('Pragma extracted', result);
465
+ if (typeof opts.onMetaExtracted === 'function') {
466
+ opts.onMetaExtracted(sf.fileName, result);
467
+ }
468
+ }
469
+ }
470
+ return ts.visitNode(sf, getVisitor(ts, ctx, sf, opts));
471
+ };
472
+ };
473
+ return transformFn;
474
+ }
475
+ exports.transformWithTs = transformWithTs;
476
+ function transform(opts) {
477
+ return transformWithTs(typescript, opts);
478
+ }
479
+ exports.transform = transform;
package/src/types.d.ts ADDED
@@ -0,0 +1,12 @@
1
+ export interface MessageDescriptor {
2
+ id: string;
3
+ description?: string | object;
4
+ defaultMessage?: string;
5
+ file?: string;
6
+ start?: number;
7
+ end?: number;
8
+ }
9
+ export interface Messages {
10
+ [key: string]: MessageDescriptor;
11
+ }
12
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,iBAAiB;IAChC,EAAE,EAAE,MAAM,CAAA;IACV,WAAW,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;IAC7B,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,GAAG,CAAC,EAAE,MAAM,CAAA;CACb;AAED,MAAM,WAAW,QAAQ;IACvB,CAAC,GAAG,EAAE,MAAM,GAAG,iBAAiB,CAAA;CACjC"}
package/src/types.js ADDED
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,6 @@
1
+ import { Opts } from '.';
2
+ import type { TsCompilerInstance } from 'ts-jest';
3
+ export declare const name = "@formatjs/ts-transformer";
4
+ export declare const version = "2.10.1";
5
+ export declare function factory(compilerInstance: TsCompilerInstance, opts: Opts): import("typescript").TransformerFactory<import("typescript").SourceFile>;
6
+ //# sourceMappingURL=ts-jest-integration.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ts-jest-integration.d.ts","sourceRoot":"","sources":["ts-jest-integration.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,IAAI,EAAC,MAAM,GAAG,CAAA;AACvC,OAAO,KAAK,EAAC,kBAAkB,EAAC,MAAM,SAAS,CAAA;AAE/C,eAAO,MAAM,IAAI,6BAA6B,CAAA;AAC9C,eAAO,MAAM,OAAO,WAAW,CAAA;AAE/B,wBAAgB,OAAO,CAAC,gBAAgB,EAAE,kBAAkB,EAAE,IAAI,EAAE,IAAI,4EAEvE"}
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.factory = exports.version = exports.name = void 0;
4
+ const _1 = require(".");
5
+ exports.name = '@formatjs/ts-transformer';
6
+ exports.version = '2.10.1';
7
+ function factory(compilerInstance, opts) {
8
+ return (0, _1.transformWithTs)(compilerInstance.configSet.compilerModule, opts);
9
+ }
10
+ exports.factory = factory;
package/BUILD DELETED
@@ -1,82 +0,0 @@
1
- load("@aspect_bazel_lib//lib:write_source_files.bzl", "write_source_files")
2
- load("@aspect_rules_js//npm/private:npm_package.bzl", "npm_package")
3
- load("@npm//:defs.bzl", "npm_link_all_packages")
4
- load("//tools:index.bzl", "check_format", "package_json_test", "ts_compile_node")
5
- load("//tools:jest.bzl", "jest_test")
6
-
7
- npm_link_all_packages(name = "node_modules")
8
-
9
- exports_files([
10
- "package.json",
11
- ])
12
-
13
- PACKAGE_NAME = "ts-transformer"
14
-
15
- npm_package(
16
- name = PACKAGE_NAME,
17
- srcs = [
18
- "LICENSE.md",
19
- "README.md",
20
- "package.json",
21
- ":dist",
22
- ],
23
- package = "@formatjs/%s" % PACKAGE_NAME,
24
- visibility = ["//visibility:public"],
25
- )
26
-
27
- SRCS = glob([
28
- "src/*.ts",
29
- "*.ts",
30
- ])
31
-
32
- SRC_DEPS = [
33
- "//:node_modules/@types/node",
34
- "//:node_modules/typescript",
35
- "//:node_modules/chalk",
36
- "//:node_modules/json-stable-stringify",
37
- "//:node_modules/@types/json-stable-stringify",
38
- ":node_modules/@formatjs/icu-messageformat-parser",
39
- ]
40
-
41
- ts_compile_node(
42
- name = "dist",
43
- srcs = SRCS,
44
- deps = SRC_DEPS + [
45
- "//:node_modules/@types/jest",
46
- "//:node_modules/ts-jest",
47
- "//:node_modules/@jest/types",
48
- ],
49
- )
50
-
51
- jest_test(
52
- name = "unit",
53
- srcs = SRCS + glob([
54
- "tests/*.ts*",
55
- "tests/fixtures/*.ts*",
56
- "tests/__snapshots__/*.snap",
57
- ]),
58
- deps = SRC_DEPS,
59
- )
60
-
61
- write_source_files(
62
- name = "tsconfig_json",
63
- files = {"tsconfig.json": "//tools:tsconfig.golden.json"},
64
- )
65
-
66
- check_format(
67
- name = "prettier",
68
- srcs = glob(
69
- [
70
- "**/*",
71
- ],
72
- exclude = [
73
- "CHANGELOG.md",
74
- "tests/__snapshots__/*",
75
- ],
76
- ),
77
- )
78
-
79
- package_json_test(
80
- name = "package_json_test",
81
- deps = SRC_DEPS,
82
- )