Skip to content

Commit

Permalink
fix: plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
lensbart committed Jun 28, 2022
1 parent 066d1ae commit 413c9f9
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 13 deletions.
13 changes: 9 additions & 4 deletions packages/remix-dev/compiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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 }
Expand Down Expand Up @@ -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(),
];

Expand Down Expand Up @@ -420,7 +425,7 @@ function createServerBuild(
serverEntryModulePlugin(config),
serverAssetsManifestPlugin(assetsManifestPromiseRef),
serverBareModulesPlugin(config, options.onWarning),
yarnPnpPlugin(),
yarnPnpCompatibilityPlugin,
];

if (config.serverPlatform !== "node") {
Expand Down
2 changes: 1 addition & 1 deletion packages/remix-dev/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
24 changes: 16 additions & 8 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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==
Expand Down

0 comments on commit 413c9f9

Please sign in to comment.