diff --git a/packages/remix-dev/compiler.ts b/packages/remix-dev/compiler.ts index 39209f2bc3e..057ab397ea7 100644 --- a/packages/remix-dev/compiler.ts +++ b/packages/remix-dev/compiler.ts @@ -5,7 +5,7 @@ import * as fse from "fs-extra"; import debounce from "lodash.debounce"; import chokidar from "chokidar"; import { NodeModulesPolyfillPlugin } from "@esbuild-plugins/node-modules-polyfill"; -import { pnpPlugin as yarnPnpPlugin } from "@yarnpkg/esbuild-plugin-pnp"; +import { NodeResolvePlugin } from "@esbuild-plugins/node-resolve"; import { BuildMode, BuildTarget } from "./build"; import type { RemixConfig } from "./config"; @@ -316,6 +316,12 @@ async function buildEverything( } } +const yarnPnpCompatibilityPlugin = NodeResolvePlugin({ + extensions: [".ts", ".js"], + onResolved: (resolved) => + resolved.includes("node_modules") ? { external: true } : resolved, +}); + async function createBrowserBuild( config: RemixConfig, options: BuildOptions & { incremental?: boolean } @@ -353,8 +359,7 @@ async function createBrowserBuild( mdxPlugin(config), browserRouteModulesPlugin(config, /\?browser$/), emptyModulesPlugin(config, /\.server(\.[jt]sx?)?$/), - // Must be placed before NodeModulesPolyfillPlugin, so yarn can resolve polyfills correctly - yarnPnpPlugin(), + yarnPnpCompatibilityPlugin, // before `NodeModulesPolyfillPlugin` NodeModulesPolyfillPlugin(), ]; @@ -420,7 +425,7 @@ function createServerBuild( serverEntryModulePlugin(config), serverAssetsManifestPlugin(assetsManifestPromiseRef), serverBareModulesPlugin(config, options.onWarning), - yarnPnpPlugin(), + yarnPnpCompatibilityPlugin, ]; if (config.serverPlatform !== "node") { diff --git a/packages/remix-dev/package.json b/packages/remix-dev/package.json index d8df1931262..0ef782a7aa1 100644 --- a/packages/remix-dev/package.json +++ b/packages/remix-dev/package.json @@ -23,9 +23,9 @@ "@babel/preset-env": "^7.18.2", "@babel/preset-typescript": "^7.17.12", "@esbuild-plugins/node-modules-polyfill": "^0.1.4", + "@esbuild-plugins/node-resolve": "^0.1.4", "@npmcli/package-json": "^2.0.0", "@remix-run/server-runtime": "1.6.1", - "@yarnpkg/esbuild-plugin-pnp": "^2.0.0", "cacache": "^15.0.5", "chalk": "^4.1.2", "chokidar": "^3.5.1", diff --git a/yarn.lock b/yarn.lock index 47ad47d6ce0..08b7a67bcec 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1217,6 +1217,16 @@ escape-string-regexp "^4.0.0" rollup-plugin-node-polyfills "^0.2.1" +"@esbuild-plugins/node-resolve@^0.1.4": + version "0.1.4" + resolved "https://registry.yarnpkg.com/@esbuild-plugins/node-resolve/-/node-resolve-0.1.4.tgz#2257ef3b233c9cb3acd2ebde7d5a3d6874046d38" + integrity sha512-haFQ0qhxEpqtWWY0kx1Y5oE3sMyO1PcoSiWEPrAw6tm/ZOOLXjSs6Q+v1v9eyuVF0nNt50YEvrcrvENmyoMv5g== + dependencies: + "@types/resolve" "^1.17.1" + debug "^4.3.1" + escape-string-regexp "^4.0.0" + resolve "^1.19.0" + "@eslint/eslintrc@^1.0.3": version "1.0.3" resolved "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-1.0.3.tgz" @@ -2334,6 +2344,11 @@ dependencies: "@types/node" "*" +"@types/resolve@^1.17.1": + version "1.20.2" + resolved "https://registry.yarnpkg.com/@types/resolve/-/resolve-1.20.2.tgz#97d26e00cd4a0423b4af620abecf3e6f442b7975" + integrity sha512-60BCwRFOZCQhDncwQdxxeOEEkbc5dIMccYLwbxsS4TUNeVECQ/pBJ0j09mrHOl/JJvpRPGwO9SvE4nR2Nb/a4Q== + "@types/responselike@*", "@types/responselike@^1.0.0": version "1.0.0" resolved "https://registry.npmjs.org/@types/responselike/-/responselike-1.0.0.tgz" @@ -2582,13 +2597,6 @@ resolved "https://registry.npmjs.org/@xmldom/xmldom/-/xmldom-0.7.5.tgz" integrity sha512-V3BIhmY36fXZ1OtVcI9W+FxQqxVLsPKcNjWigIaa81dLC9IolJl5Mt4Cvhmr0flUnjSpTdrbMTSbXqYqV5dT6A== -"@yarnpkg/esbuild-plugin-pnp@^2.0.0": - version "2.0.1" - resolved "https://registry.yarnpkg.com/@yarnpkg/esbuild-plugin-pnp/-/esbuild-plugin-pnp-2.0.1.tgz#120faad903d40e8f000ed3c9db9f9055c9612800" - integrity sha512-M8nYJr8S0riwy4Jgm3ja88m5ZfW6zZSV8fgLtO1mXpwTg0tD9ki1ShPOSm9DEbicc350TVf+k/jVNh6v1xApCw== - dependencies: - tslib "^1.13.0" - "@zxing/text-encoding@0.9.0": version "0.9.0" resolved "https://registry.npmjs.org/@zxing/text-encoding/-/text-encoding-0.9.0.tgz" @@ -10703,7 +10711,7 @@ tsconfig-paths@^4.0.0: minimist "^1.2.6" strip-bom "^3.0.0" -tslib@^1.13.0, tslib@^1.8.1, tslib@^1.9.0: +tslib@^1.8.1, tslib@^1.9.0: version "1.14.1" resolved "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz" integrity sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==