Skip to content

Commit 9c3dc98

Browse files
feat(compiler): shadcn/ui components support (#67)
* fix(compiler): include processing of ts/js files besides jsx/tsx * chore(demo): add shadcn project demo * fix(compiler): fix safeTrim algo * test(compiler): fix helper fn * fix(compiler): avoid replacing var/fn/expr placeholders with intl chunks * chore(demo): add variable usage * feat(compiler): split metadata inference into phases * chore(compiler): output AST for both pre/post phases, while in `debug` * feat(compiler): preserve nbsp during i18n compilation * chore: cleanup * chore: add changeset * chore: noop * fix(compiler): fix logic error in trimSafely
1 parent b4f0a40 commit 9c3dc98

30 files changed

Lines changed: 969 additions & 97 deletions

.changeset/young-chicken-sort.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"@replexica/compiler": patch
3+
---
4+
5+
6+
Improved support for shadcn/ui components, fixed inline variables handling, improved   support.

demo/next-app-shadcnui/.gitignore

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2+
3+
# dependencies
4+
/node_modules
5+
/.pnp
6+
.pnp.js
7+
.yarn/install-state.gz
8+
9+
# testing
10+
/coverage
11+
12+
# next.js
13+
/.next/
14+
/out/
15+
16+
# production
17+
/build
18+
19+
# misc
20+
.DS_Store
21+
*.pem
22+
23+
# debug
24+
npm-debug.log*
25+
yarn-debug.log*
26+
yarn-error.log*
27+
28+
# local env files
29+
.env*.local
30+
31+
# vercel
32+
.vercel
33+
34+
# typescript
35+
*.tsbuildinfo
36+
next-env.d.ts
37+
38+
.debug
39+
output.txt

demo/next-app-shadcnui/README.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
This is a [Next.js](https://nextjs.org/) project bootstrapped with [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app).
2+
3+
## Getting Started
4+
5+
First, run the development server:
6+
7+
```bash
8+
npm run dev
9+
# or
10+
yarn dev
11+
# or
12+
pnpm dev
13+
# or
14+
bun dev
15+
```
16+
17+
Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.
18+
19+
You can start editing the page by modifying `app/page.tsx`. The page auto-updates as you edit the file.
20+
21+
This project uses [`next/font`](https://nextjs.org/docs/basic-features/font-optimization) to automatically optimize and load Inter, a custom Google Font.
22+
23+
## Learn More
24+
25+
To learn more about Next.js, take a look at the following resources:
26+
27+
- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
28+
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.
29+
30+
You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js/) - your feedback and contributions are welcome!
31+
32+
## Deploy on Vercel
33+
34+
The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js.
35+
36+
Check out our [Next.js deployment documentation](https://nextjs.org/docs/deployment) for more details.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"$schema": "https://ui.shadcn.com/schema.json",
3+
"style": "default",
4+
"rsc": true,
5+
"tsx": true,
6+
"tailwind": {
7+
"config": "tailwind.config.ts",
8+
"css": "src/app/globals.css",
9+
"baseColor": "slate",
10+
"cssVariables": true,
11+
"prefix": ""
12+
},
13+
"aliases": {
14+
"components": "@/components",
15+
"utils": "@/lib/utils"
16+
}
17+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import compiler from '@replexica/compiler';
2+
3+
/** @type {import('next').NextConfig} */
4+
const nextConfig = {};
5+
6+
/** @type {import('@replexica/compiler').ReplexicaConfig} */
7+
const replexicaConfig = {
8+
locale: {
9+
source: 'en',
10+
targets: ['es'],
11+
},
12+
debug: true,
13+
};
14+
15+
export default compiler.next(
16+
replexicaConfig,
17+
nextConfig,
18+
);
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
{
2+
"name": "@replexica/demo/next-app-shadcnui",
3+
"version": "0.1.0",
4+
"private": true,
5+
"scripts": {
6+
"dev": "next dev",
7+
"build": "next build",
8+
"i18n": "replexica i18n",
9+
"start": "next start",
10+
"lint": "next lint"
11+
},
12+
"dependencies": {
13+
"@radix-ui/react-avatar": "^1.0.4",
14+
"@replexica/react": "workspace:*",
15+
"class-variance-authority": "^0.7.0",
16+
"clsx": "^2.1.1",
17+
"lucide-react": "^0.373.0",
18+
"next": "14.2.1",
19+
"react": "^18",
20+
"react-dom": "^18",
21+
"tailwind-merge": "^2.3.0",
22+
"tailwindcss-animate": "^1.0.7"
23+
},
24+
"devDependencies": {
25+
"@replexica/compiler": "workspace:*",
26+
"@types/node": "^20",
27+
"@types/react": "^18",
28+
"@types/react-dom": "^18",
29+
"autoprefixer": "^10.0.1",
30+
"postcss": "^8",
31+
"replexica": "workspace:*",
32+
"tailwindcss": "^3.4.3",
33+
"typescript": "^5"
34+
}
35+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
module.exports = {
2+
plugins: {
3+
tailwindcss: {},
4+
autoprefixer: {},
5+
},
6+
};
Lines changed: 1 addition & 0 deletions
Loading
Lines changed: 1 addition & 0 deletions
Loading
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
'use client';
2+
3+
export default function ClientContent() {
4+
return (
5+
<div>
6+
Hello world!
7+
</div>
8+
);
9+
}

0 commit comments

Comments
 (0)