-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
582 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# `@refina/basic-components` | ||
|
||
[![npm](https://img.shields.io/npm/v/%40refina%2Fbasic-components?color=green)](https://www.npmjs.com/package/@refina/basic-components) | ||
|
||
The bundled version of Refina libs. | ||
|
||
To know more about Refina, please visit: | ||
|
||
- [Documentation](https://refina.vercel.app). | ||
- [Getting Started](https://refina.vercel.app/guide/introduction.html) | ||
- [GitHub Repository](https://github.com/refinajs/refina). | ||
- [Examples](https://gallery.refina.vercel.app). | ||
|
||
## Usage | ||
|
||
### Via CDN | ||
|
||
```html | ||
<script src="https://unpkg.com/@refina/bundles/<lib-name>"></script> | ||
``` | ||
|
||
**Note:** Replace `<lib-name>` with the name of the lib you want to use. | ||
|
||
Available libs: | ||
|
||
- `basic-components` | ||
- `core` | ||
- `mdui` | ||
- `transformer` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import * as fsWalk from "@nodelib/fs.walk"; | ||
import { RefinaTransformer } from "@refina/transformer"; | ||
import { consola } from "consola"; | ||
import { execSync } from "node:child_process"; | ||
import { mkdirSync, readFileSync, writeFileSync } from "node:fs"; | ||
import { dirname, join, resolve } from "node:path"; | ||
import { fileURLToPath } from "node:url"; | ||
import { rimrafSync } from "rimraf"; | ||
|
||
consola.start("Starting bundle Refina libs..."); | ||
|
||
const libs = ["basic-components", "core", "mdui", "transformer"]; | ||
const __dirname = dirname(fileURLToPath(import.meta.url)); | ||
const tempDir = join(__dirname, "temp"); | ||
|
||
const transformer = new RefinaTransformer(); | ||
|
||
for (const lib of libs) { | ||
try { | ||
const sourceDir = join(__dirname, "..", lib, "src"); | ||
const tempDir = join(__dirname, "..", lib, "dist"); | ||
|
||
rimrafSync(tempDir); | ||
|
||
const entries = fsWalk.walkSync(sourceDir, { | ||
basePath: ".", | ||
}); | ||
|
||
for (const entry of entries) { | ||
if (entry.dirent.isFile()) { | ||
const sourcePath = resolve(sourceDir, entry.path); | ||
const tempPath = resolve(tempDir, entry.path); | ||
|
||
const source = readFileSync(sourcePath, "utf-8"); | ||
const transformed = | ||
transformer.transformFile(entry.name, source, true)?.code ?? source; | ||
|
||
mkdirSync(dirname(tempPath), { recursive: true }); | ||
writeFileSync(tempPath, transformed); | ||
} | ||
} | ||
} catch (e) { | ||
consola.error(e); | ||
throw e; | ||
} | ||
|
||
consola.success(`Transformed ${lib}!`); | ||
} | ||
|
||
const command = [ | ||
`pnpm exec tsup`, | ||
...libs.map(lib => `--entry.${lib} ../${lib}/dist/index.ts`), | ||
`--clean --format esm -d ./dist --no-splitting --minify terser --sourcemap`, | ||
].join(" "); | ||
|
||
execSync(command, { | ||
stdio: "inherit", | ||
cwd: __dirname, | ||
}); | ||
|
||
consola.success("Bundling complete!"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
{ | ||
"name": "@refina/bundles", | ||
"version": "0.0.1", | ||
"description": "The bundled version of Refina libs.", | ||
"keywords": [ | ||
"refina", | ||
"bundle" | ||
], | ||
"files": [ | ||
"dist", | ||
"README.md" | ||
], | ||
"type": "module", | ||
"exports": { | ||
"./*": "./dist/*" | ||
}, | ||
"scripts": { | ||
"build": "tsx ./bundle.ts", | ||
"check": "tsc --noEmit", | ||
"prepublishOnly": "npm run build" | ||
}, | ||
"author": "_Kerman", | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/KermanX/refina" | ||
}, | ||
"readme": "https://github.com/KermanX/refina#readme", | ||
"bugs": "https://github.com/KermanX/refina/issues", | ||
"license": "MIT", | ||
"devDependencies": { | ||
"@nodelib/fs.walk": "^2.0.0", | ||
"@refina/transformer": "workspace:^", | ||
"@types/node": "^20.6.5", | ||
"consola": "^3.2.3", | ||
"rimraf": "^5.0.5", | ||
"terser": "^5.26.0", | ||
"tsup": "^7.2.0", | ||
"tsx": "^4.7.0", | ||
"typescript": "^5.2.2" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"include": ["./bundle.ts"], | ||
"exclude": ["./dist"], | ||
"compilerOptions": { | ||
"strict": true, | ||
"moduleResolution": "NodeNext", | ||
"module": "NodeNext", | ||
"target": "ESNext", | ||
"lib": ["ESNext"] | ||
} | ||
} |
Oops, something went wrong.
a409130
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
refina-gallery – ./
gallery.refina.vercel.app
refina-gallery-git-main-refina.vercel.app
refina-gallery-refina.vercel.app