-
-
Save cmd-johnson/d20d686c14fdb74941a26fffe73220a0 to your computer and use it in GitHub Desktop.
@remix-run/dev compiler.ts changes to get it to work with yarn 2's PnP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/packages/remix-dev/compiler.ts b/packages/remix-dev/compiler.ts | |
index a9005652..ae70ed4f 100644 | |
--- a/packages/remix-dev/compiler.ts | |
+++ b/packages/remix-dev/compiler.ts | |
@@ -17,10 +17,17 @@ import { mdxPlugin } from "./compiler/plugins/mdx"; | |
import { getRouteModuleExportsCached } from "./compiler/routes"; | |
import { writeFileSafe } from "./compiler/utils/fs"; | |
-// When we build Remix, this shim file is copied directly into the output | |
-// directory in the same place relative to this file. It is eventually injected | |
-// as a source file when building the app. | |
-const reactShim = path.resolve(__dirname, "compiler/shims/react.ts"); | |
+async function extractReactShim(): Promise<string> { | |
+ const tmpShim = path.join(require.main?.path ?? __dirname, ".cache/tmp", "compiler/shims/react.ts"); | |
+ await fsp.mkdir(path.dirname(tmpShim), { recursive: true }); | |
+ | |
+ const reactShim = path.resolve(__dirname, "compiler/shims/react.ts"); | |
+ const shimBody = await fsp.readFile(reactShim); | |
+ | |
+ await fsp.writeFile(tmpShim, shimBody); | |
+ | |
+ return tmpShim; | |
+} | |
interface BuildConfig { | |
mode: BuildMode; | |
@@ -308,7 +315,7 @@ async function createBrowserBuild( | |
platform: "browser", | |
format: "esm", | |
external: externals, | |
- inject: [reactShim], | |
+ inject: [await extractReactShim()], | |
loader: loaders, | |
bundle: true, | |
logLevel: "silent", | |
@@ -351,7 +358,7 @@ async function createServerBuild( | |
? ["module", "main"] | |
: ["main", "module"], | |
target: options.target, | |
- inject: [reactShim], | |
+ inject: [await extractReactShim()], | |
loader: loaders, | |
bundle: true, | |
logLevel: "silent", |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment