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: use esbuild-plugins-node-modules-polyfill #2

Merged
merged 3 commits into from
Aug 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,14 +155,13 @@ Check the `build-server.mjs` function and make sure you're defining each environ

Other node packages that Remix uses must be polyfilled to work on Cloudflare.

If you get an error that says something like `Could not resolve "https" (use "platform: 'node'" when building for node)`, make sure you're importing the `@esbuild-plugins/node-modules-polyfill` plugin in your `build-server.mjs`
If you get an error that says something like `Could not resolve "https" (use "platform: 'node'" when building for node)`, make sure you're importing the `esbuild-plugins-node-modules-polyfill` plugin in your `build-server.mjs`

```js
import NodeModulesPolyfill from "@esbuild-plugins/node-modules-polyfill"
const { NodeModulesPolyfillPlugin } = NodeModulesPolyfill
import { nodeModulesPolyfillPlugin } from "esbuild-plugins-node-modules-polyfill"

esbuild.build({
plugins: [NodeModulesPolyfillPlugin()],
plugins: [nodeModulesPolyfillPlugin()],
})
```

Expand Down
5 changes: 2 additions & 3 deletions build-server.mjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import esbuild from "esbuild"

import NodeModulesPolyfill from "@esbuild-plugins/node-modules-polyfill"
const { NodeModulesPolyfillPlugin } = NodeModulesPolyfill
import { nodeModulesPolyfillPlugin } from "esbuild-plugins-node-modules-polyfill"

import alias from "esbuild-plugin-alias"

Expand Down Expand Up @@ -60,7 +59,7 @@ async function build() {
},
outfile,
plugins: [
NodeModulesPolyfillPlugin(),
nodeModulesPolyfillPlugin(),
alias({
"@prisma/client": require.resolve("@prisma/client"),
}),
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
"update:typescript-eslint": "npm i --save-dev @typescript-eslint/eslint-plugin @typescript-eslint/parser"
},
"dependencies": {
"@esbuild-plugins/node-modules-polyfill": "^0.1.4",
"@prisma/client": "^3.7.0",
"@prisma/generator-helper": "^3.7.0",
"@remix-run/cloudflare-pages": "^1.1.1",
Expand All @@ -28,6 +27,7 @@
"@tailwindcss/forms": "^0.4.0",
"cross-env": "^7.0.3",
"esbuild": "^0.14.10",
"esbuild-plugins-node-modules-polyfill": "^1.5.0",
"esbuild-plugin-alias": "^0.2.1",
"esbuild-register": "^3.3.1",
"mongo-uri-builder": "^4.0.0",
Expand Down