Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CommonJS Exports #87

Closed
finkef opened this issue Nov 18, 2021 · 3 comments
Closed

CommonJS Exports #87

finkef opened this issue Nov 18, 2021 · 3 comments

Comments

@finkef
Copy link
Contributor

finkef commented Nov 18, 2021

Hey, I'm currently writing a babel plugin using babel-plugin-macros for statically extracting and converting the tailwind styles for React Native and React Native Web, including support for SSR with media queries. (Working on some finishing touches, adding docs, etc. before publishing in the coming days 🤞)
Before, I was using tailwind-rn to convert the styles, but had no way of using the tailwind.config.js during Babel runtime. Thankfully, I found your amazing v2 rewrite and just migrated to using your lib under the hood. Unfortunately, babel-plugin-macros doesn't support ESM, so I get errors when running metro.

Would be awesome if you could add a CommonJS target to the compilation. Since I'm running a very similar setup, here's how I tackled cjs output in addition to ESM:


// tsconfig.cjs.json
{
  "extends": "./tsconfig.json",
  "compilerOptions": {
    "module": "CommonJS",
    "outDir": "./dist/cjs",
    "declaration": false
  }
}
// package.json
{
  // ...
  "main": "dist/cjs",
  "module": "dist",
  // ...
  "scripts": {
    "compile": "fldev ts:compile && fldev ts:compile -p tsconfig.cjs.json",
  }
}
@jaredh159
Copy link
Owner

hey, thanks for the issue. yup, i'm up for adding support for this, and I've opened up a PR: #91. I'm not super familiar with this stuff, wondering if you could maybe review the PR for me, and maybe try it out in your project -- I published the code in the PR as a beta version which you can install with npm install twrnc@next.

I tried it out locally in a RN app, and I lost typescript types until i put the "types": field in package.json, but after that it seemed to be working fine.

I'd like it if someone who was using RN-web could test it as well. maybe @smlarkin or @oste would be willing to check that out.

@finkef
Copy link
Contributor Author

finkef commented Nov 18, 2021

#93 implements the reorganization on top of PR #91 adding CommonJS compilation.
I have a RNW + Expo + Next.js project setup locally that I can test against once we get a new release.

@finkef
Copy link
Contributor Author

finkef commented Nov 30, 2021

Closed by #93.

@finkef finkef closed this as completed Nov 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants