Skip to content

Commit

Permalink
refactor(dev): rename BuildOptions to CompileOptions and move int…
Browse files Browse the repository at this point in the history
…o `compiler/` directory
  • Loading branch information
pcattori committed Oct 25, 2022
1 parent f7ae415 commit 9867975
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion packages/remix-dev/cli/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import type { createApp as createAppType } from "@remix-run/serve";
import getPort, { makeRange } from "get-port";
import * as esbuild from "esbuild";

import { parseMode } from "../build";
import { parseMode } from "../compiler/options";
import * as colors from "../colors";
import * as compiler from "../compiler";
import type { RemixConfig } from "../config";
Expand Down
4 changes: 2 additions & 2 deletions packages/remix-dev/compiler/build.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { type BuildOptions } from "../build";
import { type RemixConfig } from "../config";
import { warnOnce } from "./warnings";
import { logCompileFailure } from "./on-compile-failure";
import { type CompileOptions } from "./options";
import { compile, createRemixCompiler } from "./remix-compiler";

export async function build(
Expand All @@ -12,7 +12,7 @@ export async function build(
sourcemap = false,
onWarning = warnOnce,
onBuildFailure = logCompileFailure,
}: Partial<BuildOptions> = {}
}: Partial<CompileOptions> = {}
): Promise<void> {
let compiler = createRemixCompiler(config, {
mode,
Expand Down
6 changes: 3 additions & 3 deletions packages/remix-dev/compiler/compile-browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import * as esbuild from "esbuild";
import { NodeModulesPolyfillPlugin } from "@esbuild-plugins/node-modules-polyfill";
import { pnpPlugin as yarnPnpPlugin } from "@yarnpkg/esbuild-plugin-pnp";

import { type BuildOptions } from "../build";
import { type RemixConfig } from "../config";
import { createAssetsManifest, type AssetsManifest } from "./assets";
import { getAppDependencies } from "./dependencies";
import { loaders } from "./loaders";
import { type CompileOptions } from "./options";
import { browserRouteModulesPlugin } from "./plugins/browserRouteModulesPlugin";
import { cssFilePlugin } from "./plugins/cssFilePlugin";
import { emptyModulesPlugin } from "./plugins/emptyModulesPlugin";
Expand Down Expand Up @@ -58,7 +58,7 @@ const writeAssetsManifest = async (

const createEsbuildConfig = (
config: RemixConfig,
options: BuildOptions
options: CompileOptions
): esbuild.BuildOptions | esbuild.BuildIncremental => {
let entryPoints: esbuild.BuildOptions["entryPoints"] = {
"entry.client": path.resolve(config.appDirectory, config.entryClientFile),
Expand Down Expand Up @@ -116,7 +116,7 @@ const createEsbuildConfig = (

export const createBrowserCompiler = (
remixConfig: RemixConfig,
options: BuildOptions
options: CompileOptions
): BrowserCompiler => {
let compiler: esbuild.BuildIncremental;
let esbuildConfig = createEsbuildConfig(remixConfig, options);
Expand Down
6 changes: 3 additions & 3 deletions packages/remix-dev/compiler/compile-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import * as fse from "fs-extra";
import { NodeModulesPolyfillPlugin } from "@esbuild-plugins/node-modules-polyfill";
import { pnpPlugin as yarnPnpPlugin } from "@yarnpkg/esbuild-plugin-pnp";

import { type BuildOptions } from "../build";
import { type RemixConfig } from "../config";
import { type AssetsManifest } from "./assets";
import { loaders } from "./loaders";
import { type CompileOptions } from "./options";
import { cssFilePlugin } from "./plugins/cssFilePlugin";
import { emptyModulesPlugin } from "./plugins/emptyModulesPlugin";
import { mdxPlugin } from "./plugins/mdx";
Expand All @@ -27,7 +27,7 @@ export type ServerCompiler = {
const createEsbuildConfig = (
config: RemixConfig,
assetsManifestChannel: ReadChannel<AssetsManifest>,
options: BuildOptions
options: CompileOptions
): esbuild.BuildOptions => {
let stdin: esbuild.StdinOptions | undefined;
let entryPoints: string[] | undefined;
Expand Down Expand Up @@ -148,7 +148,7 @@ async function writeServerBuildResult(

export const createServerCompiler = (
remixConfig: RemixConfig,
options: BuildOptions
options: CompileOptions
): ServerCompiler => {
let compile = async (manifestChannel: ReadChannel<AssetsManifest>) => {
console.log("started server build");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ type Target =
| "cloudflare-workers"
| "node14";

export type BuildOptions = {
export type CompileOptions = {
mode: Mode;
target: Target;
sourcemap: boolean;
Expand Down
4 changes: 2 additions & 2 deletions packages/remix-dev/compiler/plugins/cssFilePlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import * as path from "path";
import * as fse from "fs-extra";
import esbuild from "esbuild";

import type { BuildOptions } from "../../build";
import invariant from "../../invariant";
import { type CompileOptions } from "../options";

const isExtendedLengthPath = /^\\\\\?\\/;

Expand All @@ -16,7 +16,7 @@ function normalizePathSlashes(p: string) {
* and exports the url of the css file as its default export.
*/
export function cssFilePlugin(options: {
mode: BuildOptions["mode"];
mode: CompileOptions["mode"];
}): esbuild.Plugin {
return {
name: "css-file",
Expand Down
4 changes: 2 additions & 2 deletions packages/remix-dev/compiler/remix-compiler.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { type BuildOptions } from "../build";
import { type RemixConfig } from "../config";
import { type AssetsManifest } from "./assets";
import { type BrowserCompiler, createBrowserCompiler } from "./compile-browser";
import { type ServerCompiler, createServerCompiler } from "./compile-server";
import { type OnCompileFailure } from "./on-compile-failure";
import { type CompileOptions } from "./options";
import { createChannel } from "./utils/channel";

type RemixCompiler = {
Expand All @@ -13,7 +13,7 @@ type RemixCompiler = {

export const createRemixCompiler = (
remixConfig: RemixConfig,
options: BuildOptions
options: CompileOptions
): RemixCompiler => {
return {
browser: createBrowserCompiler(remixConfig, options),
Expand Down

0 comments on commit 9867975

Please sign in to comment.