Skip to content

Commit

Permalink
update bundles
Browse files Browse the repository at this point in the history
  • Loading branch information
KermanX committed Jan 6, 2024
1 parent a409130 commit c1ec492
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 9 deletions.
37 changes: 29 additions & 8 deletions packages/bundles/bundle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ 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 { mkdirSync, readFileSync, renameSync, writeFileSync } from "node:fs";
import { dirname, join, resolve } from "node:path";
import { fileURLToPath } from "node:url";
import { rimrafSync } from "rimraf";
Expand All @@ -11,7 +11,7 @@ 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 distDir = join(__dirname, "dist");

const transformer = new RefinaTransformer();

Expand Down Expand Up @@ -47,15 +47,36 @@ for (const lib of libs) {
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(" ");
const command = (minify: boolean) =>
[
`pnpm exec tsup`,
...libs.map(
lib => `--entry.${lib}${minify ? "_min" : ""} ../${lib}/dist/index.ts`,
),
`--format esm -d ./dist --no-splitting --sourcemap`,
`--define.import.meta.env.DEV false`,
minify ? `--minify terser` : `--clean`,
].join(" ");

execSync(command, {
execSync(command(false), {
stdio: "inherit",
cwd: __dirname,
});

execSync(command(true), {
stdio: "inherit",
cwd: __dirname,
});

const distEntries = fsWalk.walkSync(distDir, { basePath: "." });
for (const entry of distEntries) {
if (entry.dirent.isFile()) {
if (!entry.name.includes("_min")) continue;
renameSync(
resolve(distDir, entry.path),
resolve(distDir, entry.path.replace(/_min/, ".min")),
);
}
}

consola.success("Bundling complete!");
2 changes: 1 addition & 1 deletion packages/bundles/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@refina/bundles",
"version": "0.0.1",
"version": "0.0.2",
"description": "The bundled version of Refina libs.",
"keywords": [
"refina",
Expand Down

1 comment on commit c1ec492

@vercel
Copy link

@vercel vercel bot commented on c1ec492 Jan 6, 2024

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 – ./

refina-gallery-git-main-refina.vercel.app
refina-gallery-refina.vercel.app
gallery.refina.vercel.app

Please sign in to comment.