Skip to content

Commit

Permalink
refactor: switch to remix vite (#3120)
Browse files Browse the repository at this point in the history
  • Loading branch information
TrySound authored Apr 9, 2024
1 parent c596da6 commit 4007fc3
Show file tree
Hide file tree
Showing 20 changed files with 65 additions and 160 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,5 @@ jobs:

- run: pnpm eslint . --ext .ts,.tsx --max-warnings 0 --cache --cache-strategy=content --cache-location=node_modules/.cache/eslint/.eslint-cache

- run: pnpm turbo run size-test build checks
- run: pnpm turbo run build
- run: pnpm turbo run size-test checks
4 changes: 2 additions & 2 deletions apps/builder/app/builder/builder.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ import {
} from "./features/sidebar-left";
import { Inspector } from "./features/inspector";
import { Topbar } from "./features/topbar";
import builderStyles from "./builder.css";
import builderStyles from "./builder.css?url";
// eslint-disable-next-line import/no-internal-modules
import prismStyles from "prismjs/themes/prism-solarizedlight.min.css";
import prismStyles from "prismjs/themes/prism-solarizedlight.min.css?url";
import { Footer } from "./features/footer";
import {
CanvasIframe,
Expand Down
2 changes: 1 addition & 1 deletion apps/builder/app/builder/features/ai/ai-command-bar.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-disable import/no-internal-modules */
import formatDistance from "date-fns/formatDistance";
import { formatDistance } from "date-fns/formatDistance";
import {
AutogrowTextArea,
Box,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
import { createRegularStyleSheet } from "@webstudio-is/css-engine";
import { CollapsibleSection } from "~/builder/shared/collapsible-section";
import { useMemo } from "react";
import * as Prism from "prismjs";
import Prism from "prismjs";
import type { Style, StyleProperty } from "@webstudio-is/css-engine";
import { captureError } from "@webstudio-is/error-utils";

Expand Down
2 changes: 1 addition & 1 deletion apps/builder/app/builder/features/topbar/domains.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import { CollapsibleDomainSection } from "./collapsible-domain-section";
import { useCallback, useEffect, useState } from "react";
import type { PublishStatus } from "@webstudio-is/prisma-client";
// eslint-disable-next-line import/no-internal-modules
import formatDistance from "date-fns/formatDistance";
import { formatDistance } from "date-fns/formatDistance";
import { Entri } from "./entri";
import { trpcClient } from "~/shared/trpc/trpc-client";
import { useStore } from "@nanostores/react";
Expand Down
8 changes: 4 additions & 4 deletions apps/builder/app/routes/vercel-deploy-workaround.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import type { LinksFunction } from "@remix-run/server-runtime";

import { Root } from "~/shared/remix/root";
import interFont from "@fontsource-variable/inter/index.css";
import manropeVariableFont from "@fontsource-variable/manrope/index.css";
import robotoMonoFont from "@fontsource/roboto-mono/index.css";
import interFont from "@fontsource-variable/inter/index.css?url";
import manropeVariableFont from "@fontsource-variable/manrope/index.css?url";
import robotoMonoFont from "@fontsource/roboto-mono/index.css?url";
// eslint-disable-next-line import/no-internal-modules
import appCss from "../shared/app.css";
import appCss from "../shared/app.css?url";

/**
* For unknown reason vercel don't upload css assets if they are not exported from route path
Expand Down
9 changes: 1 addition & 8 deletions apps/builder/app/shared/remix/root.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
import {
Links,
LiveReload,
Meta,
Outlet as RemixOutlet,
Scripts,
} from "@remix-run/react";
import { Links, Meta, Outlet as RemixOutlet, Scripts } from "@remix-run/react";
import { createHead } from "remix-island";

export const Head = createHead(() => (
Expand All @@ -20,7 +14,6 @@ export const Root = ({ Outlet = RemixOutlet }) => {
<Head />
<Outlet />
<Scripts />
{process.env.NODE_ENV === "development" && <LiveReload />}
</>
);
};
65 changes: 0 additions & 65 deletions apps/builder/env-check.js

This file was deleted.

2 changes: 2 additions & 0 deletions apps/builder/env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/// <reference types="vite/client" />
/// <reference types="@remix-run/node" />
4 changes: 2 additions & 2 deletions apps/builder/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// eslint-disable-next-line @typescript-eslint/no-var-requires
const baseConfig = require("@webstudio-is/jest-config");
import baseConfig from "@webstudio-is/jest-config";

/**
* @type {import('@jest/types').Config.InitialOptions}
*/
module.exports = {
export default {
...baseConfig,
testMatch: ["<rootDir>/app/**/*.test.ts"],
moduleNameMapper: {
Expand Down
2 changes: 1 addition & 1 deletion apps/builder/middleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ app.use("*", async (ctx, next) => {
ctx.set(
"skipRateLimit",
url.pathname.startsWith("/asset/") ||
url.pathname.startsWith("/build/") ||
url.pathname.startsWith("/assets/") ||
url.pathname.endsWith(".ico")
);
return next();
Expand Down
14 changes: 8 additions & 6 deletions apps/builder/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@
"version": "0.144.0",
"private": true,
"description": "Webstudio Builder UI as a service",
"type": "module",
"scripts": {
"generate-metas": "pnpm tsx scripts/generate-metas.mts",
"prebuild": "which remix",
"build": "pnpm generate-metas && remix build",
"start": "remix-serve build/index.js",
"start-local": "NODE_OPTIONS='-r dotenv/config' remix-serve build",
"dev": "pnpm generate-metas && remix dev",
"build": "pnpm generate-metas && remix vite:build",
"start": "remix-serve build/server/index.js",
"start-local": "NODE_OPTIONS='-r dotenv/config' remix-serve build/server/index.js",
"dev": "pnpm generate-metas && remix vite:dev",
"typecheck": "tsc --noEmit --emitDeclarationOnly false",
"test": "NODE_OPTIONS=--experimental-vm-modules jest",
"checks": "pnpm typecheck && pnpm test",
Expand Down Expand Up @@ -79,7 +80,7 @@
"change-case": "^5.0.2",
"colord": "^2.9.3",
"cookie": "^0.6.0",
"date-fns": "^2.30.0",
"date-fns": "^3.6.0",
"detect-font": "^0.1.5",
"downshift": "^6.1.7",
"fast-deep-equal": "^3.1.3",
Expand Down Expand Up @@ -140,7 +141,8 @@
"html-tags": "^3.3.1",
"react-test-renderer": "^18.2.0",
"type-fest": "^4.3.1",
"typescript": "5.2.2"
"typescript": "5.2.2",
"vite": "^5.2.8"
},
"sideEffects": false,
"license": "AGPL-3.0-or-later"
Expand Down
52 changes: 0 additions & 52 deletions apps/builder/remix.config.js

This file was deleted.

2 changes: 0 additions & 2 deletions apps/builder/remix.env.d.ts

This file was deleted.

2 changes: 1 addition & 1 deletion apps/builder/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"extends": "@webstudio-is/tsconfig/base.json",
"include": [
"env.d.ts",
"app",
"remix.env.d.ts",
"**/*.ts",
"**/*.tsx",
"../../@types/**/*.d.ts",
Expand Down
21 changes: 21 additions & 0 deletions apps/builder/vite.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { resolve } from "node:path";
import { defineConfig } from "vite";
import { vitePlugin as remix } from "@remix-run/dev";

const isStorybook = process.argv[1]?.includes("storybook") ?? false;

export default defineConfig({
plugins: [isStorybook === false && remix()],
resolve: {
conditions: ["webstudio", "import", "module", "browser", "default"],
alias: [
{
find: "~",
replacement: resolve("app"),
},
],
},
ssr: {
external: ["@webstudio-is/prisma-client"],
},
});
4 changes: 2 additions & 2 deletions packages/design-system/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export * from "./stitches.config";
export * from "./components/storybook";
export * from "./utilities";
export * from "@radix-ui/react-slot";
export { type SlotProps, Slot } from "@radix-ui/react-slot";
// Aligned with Figma

export * from "./components/text";
Expand Down Expand Up @@ -67,7 +67,7 @@ export * from "./components/pro-badge";

// No need to align

export * from "@radix-ui/react-id";
export { useId } from "@radix-ui/react-id";
export * as Portal from "@radix-ui/react-portal";
export { Box } from "./components/box";
export { Flex } from "./components/flex";
Expand Down
7 changes: 3 additions & 4 deletions packages/prisma-client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"typecheck": "tsc",
"checks": "pnpm typecheck",
"dev": "pnpm build",
"build": "prisma format && prisma generate && esbuild src/prisma.ts --outdir=lib --format=cjs && cp src/cjs/package.json lib && cp -r src/__generated__ lib/__generated__",
"build": "prisma format && prisma generate && esbuild src/prisma.ts --outdir=lib --format=cjs && cp src/cjs/package.json lib && cp -r src/__generated__ lib/__generated__ && pnpm dts",
"dts": "tsc --declarationDir lib",
"migrations": "./migrations-cli/cli.ts"
},
Expand All @@ -27,10 +27,9 @@
"zod": "^3.22.4"
},
"exports": {
"webstudio": "./src/prisma.ts",
"types": "./lib/prisma.d.ts",
"import": "./lib/prisma.js",
"require": "./lib/prisma.js"
"import": "./prisma.mjs",
"require": "./prisma.cjs"
},
"license": "AGPL-3.0-or-later",
"private": true,
Expand Down
6 changes: 6 additions & 0 deletions packages/prisma-client/prisma.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
const pkg = require("./lib/prisma.js");

exports.prisma = pkg.prisma;
exports.Prisma = pkg.Prisma;
exports.PrismaClientKnownRequestError = pkg.PrismaClientKnownRequestError;
exports.Decimal = pkg.Decimal;
14 changes: 7 additions & 7 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 4007fc3

Please sign in to comment.