Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/joshamaju/mpa
Browse files Browse the repository at this point in the history
  • Loading branch information
joshamaju committed Dec 16, 2024
2 parents d390e87 + e5dd2fe commit a4afe7b
Show file tree
Hide file tree
Showing 16 changed files with 1,292 additions and 4,491 deletions.
5 changes: 0 additions & 5 deletions .changeset/unlucky-experts-shout.md

This file was deleted.

14 changes: 14 additions & 0 deletions integrations/express/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
# @stack54/express

## 1.0.3

### Patch Changes

- Updated dependencies [d945998]
- [email protected]

## 1.0.2

### Patch Changes

- Updated dependencies [af66f61]
- [email protected]

## 1.0.1

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion integrations/express/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@stack54/express",
"version": "1.0.1",
"version": "1.0.3",
"description": "",
"type": "module",
"homepage": "https://github.com/joshamaju/stack54/blob/main/integrations/express/README.md",
Expand Down
14 changes: 14 additions & 0 deletions integrations/hono/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
# @stack54/hono

## 0.0.8

### Patch Changes

- Updated dependencies [d945998]
- [email protected]

## 0.0.7

### Patch Changes

- Updated dependencies [af66f61]
- [email protected]

## 0.0.6

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion integrations/hono/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@stack54/hono",
"version": "0.0.6",
"version": "0.0.8",
"description": "",
"type": "module",
"homepage": "https://github.com/joshamaju/stack54/blob/main/integrations/hono/README.md",
Expand Down
14 changes: 14 additions & 0 deletions integrations/island/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
# @stack54/island

## 0.3.2

### Patch Changes

- Updated dependencies [d945998]
- [email protected]

## 0.3.1

### Patch Changes

- Updated dependencies [af66f61]
- [email protected]

## 0.3.0

### Minor Changes
Expand Down
2 changes: 1 addition & 1 deletion integrations/island/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@stack54/island",
"version": "0.3.0",
"version": "0.3.2",
"description": "",
"type": "module",
"homepage": "https://github.com/joshamaju/stack54/blob/main/integrations/island/README.md",
Expand Down
12 changes: 12 additions & 0 deletions packages/core/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# mpa

## 0.9.0

### Minor Changes

- d945998: Refactors from effect to effection, in addition with proper error reporting to the console

## 0.8.1

### Patch Changes

- af66f61: Fixes views build failure caused by when no view found in project directory

## 0.8.0

### Minor Changes
Expand Down
4 changes: 3 additions & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "stack54",
"version": "0.8.0",
"version": "0.9.0",
"description": "The fun Javascript stack",
"type": "module",
"publishConfig": {
Expand Down Expand Up @@ -57,7 +57,9 @@
"@tsconfig/svelte": "^5.0.2",
"devalue": "^4.3.2",
"effect": "^3.5.7",
"effection": "^3.0.3",
"es-module-lexer": "^1.5.4",
"fp-ts": "^2.16.9",
"fs-extra": "^11.2.0",
"glob": "^10.3.10",
"kleur": "^4.1.5",
Expand Down
83 changes: 40 additions & 43 deletions packages/core/src/core/build/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,80 +2,77 @@ import * as path from "node:path";

import fs from "fs-extra";

import { Effect } from "effect";
import { call, all } from "effection";
import color from "kleur";

import * as Config from "../config/index.js";
import { defineServerEnv, load, partition } from "../env.js";
import { makeVite } from "../utils/vite.js";
import { buildServer } from "./server.js";
import { buildViews } from "./view.js";
import { makeViteLogger } from "../logger.js";
import {
runBuildEnd,
runBuildStart,
runConfigResolved,
runConfigSetup,
} from "../integrations/hooks.js";
import { makeViteLogger, useLogger } from "../logger.js";
import { makeVite } from "../utils/vite.js";
import { buildServer } from "./server.js";
import { buildViews } from "./view.js";

export function* build() {
const start = process.hrtime.bigint();

const cwd = process.cwd();
const cwd = process.cwd();

export function build() {
return Effect.gen(function* () {
const inline_config = yield* Effect.tryPromise(() => Config.load(cwd));
const logger = useLogger();

const user_config = yield* Config.parse(inline_config);
const inline_config = yield* call(Config.load(cwd));

let merged_config = yield* Effect.promise(() => {
return runConfigSetup(user_config, { command: "build" });
});
const user_config = Config.parse(inline_config);

const resolved_config = yield* Effect.tryPromise(() => {
return Config.preprocess(merged_config, { cwd });
});
let merged_config = yield* call(
runConfigSetup(user_config, { command: "build" })
);

const logger = yield* makeViteLogger();
const resolved_config = yield* call(
Config.preprocess(merged_config, { cwd })
);

const shared_vite_config = makeVite(resolved_config, {
logger,
mode: "build",
});
const vite_logger = makeViteLogger();

const config = { ...resolved_config, vite: shared_vite_config };
const shared_vite_config = makeVite(resolved_config, {
logger: vite_logger,
mode: "build",
});

yield* Effect.tryPromise(() => runConfigResolved(config));
const config = { ...resolved_config, vite: shared_vite_config };

const outDir = path.join(cwd, config.build.outDir);
yield* call(runConfigResolved(config));

const mode = process.env.NODE_ENV ?? "production";
const outDir = path.join(cwd, config.build.outDir);

const env = load(config.env.dir ?? cwd, mode);
const { public: public_ } = partition(env, config.env.publicPrefix);
yield* all([call(fs.remove(outDir)), call(runBuildStart(config))]);

yield* Effect.tryPromise(() => fs.remove(outDir));
const mode = process.env.NODE_ENV ?? "production";

yield* Effect.promise(() => runBuildStart(config));
const env = load(config.env.dir ?? cwd, mode);
const { public: public_ } = partition(env, config.env.publicPrefix);

yield* Effect.log("building views...");
const opts = { cwd, outDir, config: config, env: public_ };

const opts = { cwd, outDir, config: config, env: public_ };
// logger.info("building views...");

const start = performance.now();
const views = yield* buildViews(opts);
const time = performance.now() - start;
const views = yield* buildViews(opts);

yield* Effect.log(`built views in ${Math.round(time)} ${color.dim("ms")}`);
// logger.info("building server...");

yield* Effect.log("building server...");
defineServerEnv(env);

defineServerEnv(env);
yield* call(buildServer(views, { env, outDir, config }));

yield* Effect.promise(() => {
return buildServer(views, { env, outDir, config });
});
yield* call(runBuildEnd(config));

yield* Effect.promise(() => runBuildEnd(config));
const end = process.hrtime.bigint();
const time = Number(end - start) / 1e6;

yield* Effect.log("✔︎ build done");
});
logger.info(`✔︎ build done in ${Math.round(time)} ${color.dim("ms")}`);
}
Loading

0 comments on commit a4afe7b

Please sign in to comment.