@workday/canvas-kit-styling-transform 10.0.0-alpha.553-next.0 → 10.0.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.
@@ -1 +1 @@
1
- {"version":3,"file":"styleTransform.d.ts","sourceRoot":"","sources":["../../../lib/styleTransform.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,YAAY,CAAC;AAe5B,oBAAY,iBAAiB,GAAG;IAAC,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,iBAAiB,CAAA;CAAC,CAAC;AAmZ5E,MAAM,WAAW,uBAAuB;IACtC,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAClC,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;CAC1B;AAED,MAAM,CAAC,OAAO,UAAU,gBAAgB,CACtC,OAAO,EAAE,EAAE,CAAC,OAAO,EACnB,EAAC,MAAc,EAAE,SAAc,EAAE,aAAa,EAAC,GAAE,OAAO,CAAC,uBAAuB,CAG/E,GACA,EAAE,CAAC,kBAAkB,CAAC,EAAE,CAAC,UAAU,CAAC,CAgJtC;AAGD,wBAAgB,SAAS,CACvB,OAAO,EAAE,EAAE,CAAC,OAAO,EACnB,QAAQ,EAAE,MAAM,EAChB,OAAO,CAAC,EAAE,OAAO,CAAC,uBAAuB,CAAC,UAY3C"}
1
+ {"version":3,"file":"styleTransform.d.ts","sourceRoot":"","sources":["../../../lib/styleTransform.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,YAAY,CAAC;AAe5B,oBAAY,iBAAiB,GAAG;IAAC,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,iBAAiB,CAAA;CAAC,CAAC;AAmZ5E,MAAM,WAAW,uBAAuB;IACtC,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAClC,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;CAC1B;AAED,MAAM,CAAC,OAAO,UAAU,gBAAgB,CACtC,OAAO,EAAE,EAAE,CAAC,OAAO,EACnB,EAAC,MAAc,EAAE,SAAc,EAAE,aAAa,EAAC,GAAE,OAAO,CAAC,uBAAuB,CAG/E,GACA,EAAE,CAAC,kBAAkB,CAAC,EAAE,CAAC,UAAU,CAAC,CAgLtC;AAGD,wBAAgB,SAAS,CACvB,OAAO,EAAE,EAAE,CAAC,OAAO,EACnB,QAAQ,EAAE,MAAM,EAChB,OAAO,CAAC,EAAE,OAAO,CAAC,uBAAuB,CAAC,UAY3C"}
@@ -405,7 +405,41 @@ function styleTransformer(program, { prefix = 'css', variables = {}, fallbackFil
405
405
  }
406
406
  return arg;
407
407
  });
408
- return typescript_1.default.factory.createCallExpression(typescript_1.default.factory.createIdentifier(styleExpressionName), [], newArguments);
408
+ newArguments.forEach(argument => {
409
+ // TypeScript isn't expecting us to mutate arguments arguments and when emitting will
410
+ // try to do something where it checks the `parent` node of the argument. Using
411
+ // `ts.factory.create*`, the `parent` is `undefined` and this check will throw an error.
412
+ // In order to get past this error, we manually update the `parent` node of each
413
+ // argument to reference the existing call expression. This allows TypeScript to fully
414
+ // type check and/or emit.
415
+ argument.parent = node;
416
+ });
417
+ /**
418
+ * We're not supposed to mutate arguments since it is supposed to be read-only. But, if I
419
+ * return a new callExpression, there is no parent and it is no longer linked to the
420
+ * import module. This causes incorrect code when the module export type is `commonjs`.
421
+ * For example:
422
+ *
423
+ * ```ts
424
+ * // with new callExpression
425
+ * const canvas_kit_styling_1 = require(...)
426
+ *
427
+ * createStyles({...})
428
+ *
429
+ * // if we instead mutate arguments
430
+ * const canvas_kit_styling_1 = require(...)
431
+ *
432
+ * canvas_kit_styling_1.createStyles({...})
433
+ * ```
434
+ *
435
+ * My best guess as to why it fails when creating a new callExpression is the node's
436
+ * symbol declaration link gets lost. TypeScript then has no idea `createStyles` comes
437
+ * from an `ImportDeclaration` declaration node and when emitting `commonjs`, it doesn't
438
+ * prefix with the `canvas_kit_styling_1`. This is hacky, but the only thing that works
439
+ * correctly.
440
+ */
441
+ node.arguments = newArguments;
442
+ return node;
409
443
  }
410
444
  }
411
445
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"styleTransform.d.ts","sourceRoot":"","sources":["../../../lib/styleTransform.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,YAAY,CAAC;AAe5B,oBAAY,iBAAiB,GAAG;IAAC,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,iBAAiB,CAAA;CAAC,CAAC;AAmZ5E,MAAM,WAAW,uBAAuB;IACtC,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAClC,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;CAC1B;AAED,MAAM,CAAC,OAAO,UAAU,gBAAgB,CACtC,OAAO,EAAE,EAAE,CAAC,OAAO,EACnB,EAAC,MAAc,EAAE,SAAc,EAAE,aAAa,EAAC,GAAE,OAAO,CAAC,uBAAuB,CAG/E,GACA,EAAE,CAAC,kBAAkB,CAAC,EAAE,CAAC,UAAU,CAAC,CAgJtC;AAGD,wBAAgB,SAAS,CACvB,OAAO,EAAE,EAAE,CAAC,OAAO,EACnB,QAAQ,EAAE,MAAM,EAChB,OAAO,CAAC,EAAE,OAAO,CAAC,uBAAuB,CAAC,UAY3C"}
1
+ {"version":3,"file":"styleTransform.d.ts","sourceRoot":"","sources":["../../../lib/styleTransform.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,YAAY,CAAC;AAe5B,oBAAY,iBAAiB,GAAG;IAAC,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,iBAAiB,CAAA;CAAC,CAAC;AAmZ5E,MAAM,WAAW,uBAAuB;IACtC,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAClC,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;CAC1B;AAED,MAAM,CAAC,OAAO,UAAU,gBAAgB,CACtC,OAAO,EAAE,EAAE,CAAC,OAAO,EACnB,EAAC,MAAc,EAAE,SAAc,EAAE,aAAa,EAAC,GAAE,OAAO,CAAC,uBAAuB,CAG/E,GACA,EAAE,CAAC,kBAAkB,CAAC,EAAE,CAAC,UAAU,CAAC,CAgLtC;AAGD,wBAAgB,SAAS,CACvB,OAAO,EAAE,EAAE,CAAC,OAAO,EACnB,QAAQ,EAAE,MAAM,EAChB,OAAO,CAAC,EAAE,OAAO,CAAC,uBAAuB,CAAC,UAY3C"}
@@ -399,7 +399,41 @@ export default function styleTransformer(program, { prefix = 'css', variables =
399
399
  }
400
400
  return arg;
401
401
  });
402
- return ts.factory.createCallExpression(ts.factory.createIdentifier(styleExpressionName), [], newArguments);
402
+ newArguments.forEach(argument => {
403
+ // TypeScript isn't expecting us to mutate arguments arguments and when emitting will
404
+ // try to do something where it checks the `parent` node of the argument. Using
405
+ // `ts.factory.create*`, the `parent` is `undefined` and this check will throw an error.
406
+ // In order to get past this error, we manually update the `parent` node of each
407
+ // argument to reference the existing call expression. This allows TypeScript to fully
408
+ // type check and/or emit.
409
+ argument.parent = node;
410
+ });
411
+ /**
412
+ * We're not supposed to mutate arguments since it is supposed to be read-only. But, if I
413
+ * return a new callExpression, there is no parent and it is no longer linked to the
414
+ * import module. This causes incorrect code when the module export type is `commonjs`.
415
+ * For example:
416
+ *
417
+ * ```ts
418
+ * // with new callExpression
419
+ * const canvas_kit_styling_1 = require(...)
420
+ *
421
+ * createStyles({...})
422
+ *
423
+ * // if we instead mutate arguments
424
+ * const canvas_kit_styling_1 = require(...)
425
+ *
426
+ * canvas_kit_styling_1.createStyles({...})
427
+ * ```
428
+ *
429
+ * My best guess as to why it fails when creating a new callExpression is the node's
430
+ * symbol declaration link gets lost. TypeScript then has no idea `createStyles` comes
431
+ * from an `ImportDeclaration` declaration node and when emitting `commonjs`, it doesn't
432
+ * prefix with the `canvas_kit_styling_1`. This is hacky, but the only thing that works
433
+ * correctly.
434
+ */
435
+ node.arguments = newArguments;
436
+ return node;
403
437
  }
404
438
  }
405
439
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@workday/canvas-kit-styling-transform",
3
- "version": "10.0.0-alpha.553-next.0",
3
+ "version": "10.0.0",
4
4
  "description": "The custom CSS in JS solution that takes JS styles and turns them into static CSS",
5
5
  "author": "Workday, Inc. (https://www.workday.com)",
6
6
  "license": "Apache-2.0",
@@ -41,10 +41,10 @@
41
41
  ],
42
42
  "dependencies": {
43
43
  "@emotion/serialize": "^1.0.2",
44
- "@workday/canvas-kit-styling": "^10.0.0-alpha.553-next.0",
44
+ "@workday/canvas-kit-styling": "^10.0.0",
45
45
  "@workday/canvas-tokens-web": "0.1.6",
46
46
  "stylis": "4.0.13",
47
47
  "typescript": "4.2"
48
48
  },
49
- "gitHead": "3b30b5d170238acce838e1b74da0a65e82810de3"
49
+ "gitHead": "ee481cf099e6562aacabb6b75aefe93608dfb0b3"
50
50
  }