Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(dev): simplify compiler #4410

Merged
merged 17 commits into from
Oct 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
218 changes: 0 additions & 218 deletions packages/remix-dev/__tests__/build-test.ts

This file was deleted.

4 changes: 2 additions & 2 deletions packages/remix-dev/__tests__/cli-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ afterAll(async () => {

async function execRemix(
args: Array<string>,
options: Parameters<typeof execFile>[2] = {}
options: Exclude<Parameters<typeof execFile>[2], null | undefined> = {}
) {
if (process.platform === "win32") {
let cp = childProcess.spawnSync(
Expand Down Expand Up @@ -275,7 +275,7 @@ function defer() {
return rej(reason);
};
});
return { promise, resolve, reject, state };
return { promise, resolve: resolve!, reject: reject!, state };
}

async function interactWithShell(
Expand Down
2 changes: 1 addition & 1 deletion packages/remix-dev/__tests__/routesConvention-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { createRoutePath } from "../config/routesConvention";

describe("createRoutePath", () => {
describe("creates proper route paths", () => {
let tests = [
let tests: [string, string | undefined][] = [
["routes/$", "routes/*"],
["routes/sub/$", "routes/sub/*"],
["routes.sub/$", "routes/sub/*"],
Expand Down
33 changes: 0 additions & 33 deletions packages/remix-dev/build.ts

This file was deleted.

15 changes: 7 additions & 8 deletions packages/remix-dev/cli/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import type { createApp as createAppType } from "@remix-run/serve";
import getPort, { makeRange } from "get-port";
import * as esbuild from "esbuild";

import { BuildMode, isBuildMode } from "../build";
import * as colors from "../colors";
import * as compiler from "../compiler";
import type { RemixConfig } from "../config";
Expand Down Expand Up @@ -148,11 +147,11 @@ export async function build(
modeArg?: string,
sourcemap: boolean = false
): Promise<void> {
let mode = isBuildMode(modeArg) ? modeArg : BuildMode.Production;
let mode = compiler.parseMode(modeArg ?? "", "production");

log(`Building Remix app in ${mode} mode...`);

if (modeArg === BuildMode.Production && sourcemap) {
if (modeArg === "production" && sourcemap) {
console.warn(
"\n⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️"
);
Expand All @@ -171,10 +170,10 @@ export async function build(
let config = await readConfig(remixRoot);
fse.emptyDirSync(config.assetsBuildDirectory);
await compiler.build(config, {
mode: mode,
mode,
sourcemap,
onBuildFailure: (failure: compiler.BuildError) => {
compiler.formatBuildFailure(failure);
onCompileFailure: (failure) => {
compiler.logCompileFailure(failure);
throw Error();
},
});
Expand All @@ -193,7 +192,7 @@ export async function watch(
callbacks?: WatchCallbacks
): Promise<void> {
let { onInitialBuild, onRebuildStart } = callbacks || {};
let mode = isBuildMode(modeArg) ? modeArg : BuildMode.Development;
let mode = compiler.parseMode(modeArg ?? "", "development");
console.log(`Watching Remix app in ${mode} mode...`);

let start = Date.now();
Expand Down Expand Up @@ -278,7 +277,7 @@ export async function dev(
}

let config = await readConfig(remixRoot);
let mode = isBuildMode(modeArg) ? modeArg : BuildMode.Development;
let mode = compiler.parseMode(modeArg ?? "", "development");

await loadEnv(config.rootDirectory);

Expand Down
Loading