I'm using tailwind.macro in a React library with Storybook built with tsdx. On tsdx 0.12.0, everything was working as expected as babel macros are supported out of the box.
However, when updating to 0.12.1, my builds stopped working properly with tailwind.macro.
I created a repository with the two versions and a simple component including styled-components and tailwind.macro: https://github.com/fknop/tsdx-tailwind.macro-bug.
I also included the two dist folders from the two versions:
0.12.0: https://github.com/fknop/tsdx-tailwind.macro-bug/blob/master/tsdx-0.12.0/library/dist/library.esm.js
0.12.1: https://github.com/fknop/tsdx-tailwind.macro-bug/blob/master/tsdx-0.12.1/library/dist/library.esm.js
As we can see, tw is not imported anywhere in the 0.12.1 version. This makes any code importing this build failing with the function tw being undefined.
Tested on both MacOS and Windows 10.
Might be related to https://github.com/jaredpalmer/tsdx/pull/130#issuecomment-569375532 , but not sure.
Only other big thing that changed was the fix for getter/setter treeshaking optimization in #371 , which I don't think is related, but I was concerned about it breaking things per the PR. Success/Failure Hooks & TranspileOnly were added in a patch release as well
Interesting!
I just tried to set the target of the reproduction repository to esnext, and the tailwind import seems to be back.
This is the output of the build with 0.12.1 and target: esnext
import _styled from 'styled-components';
import _tailwindUtils from 'tailwind.macro/utils.umd.js';
var _tailwindConfig2 = {};
var _tailwindConfig =
/*#__PURE__*/
_tailwindUtils.resolveConfig(_tailwindConfig2);
// Delete me
var Comp =
/*#__PURE__*/
_styled.div.withConfig({
displayName: "src__Comp",
componentId: "sc-19dskac-0"
})(["", ""],
/*#__PURE__*/
Object.assign(
/*#__PURE__*/
_tailwindUtils.resolveStyle(_tailwindConfig, [{
"prop": "color",
"config": "textColor"
}, {
"prop": "fontSize",
"config": "fontSize"
}], "xs")));
export { Comp };
//# sourceMappingURL=library.esm.js.map
What need to be changed?
Seems like that confirms my fears in https://github.com/jaredpalmer/tsdx/pull/130#issuecomment-569375532. Great reproduction @fknop !
The importing of tslib in 0.12.1 vs. insertion of babel helpers in 0.12 and prior is also a notable difference, related to #412
@jaredpalmer I reverted the extraneous changes of #130 in #415
Thank you for the quick fix!
@all-contributors please add @fknop for bug
@agilgur5
I've put up a pull request to add @fknop! :tada: