-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Can't import node builtins in a route module #114
Comments
esbuild issue: evanw/esbuild#705 |
Is there some setting to resolve to the npm version if it's a dependency? |
When I use a package that transitively depends on
I guess somehow it tries to import the builtin still? |
@mjackson are you able to fix this? You currently can't use any module which uses the 'events' in the browser in remix. https://github.com/remix-run/remix/blob/main/packages/remix-dev/compiler.ts#L310 |
For anyone who needs a temporary workaround while this is fixed, here's my hack: add this patch to patches/ : https://gist.github.com/jtsiskin/9f661fc35d5c4d1e91239f9b319693e0 Inside my root.tsx, within my , I then added After than I had no more dependency issues |
* docs: create remix example * docs: add dotenv to remix example * docs: copy components into remix example * docs: attach process to the window to prevent errors * docs: re-enable walletConnect and walletLinkConnector * docs: update components in remix example * docs: remove global assignment * docs: working metamask example * docs: add patch to expose node global modules remix-run/remix#114 * docs: working WalletConnect implementation * docs: add safe-event-emitter patch * docs: working walletlink example
@jtsiskin thank you! I'll update your gist for remix 1.1.3 |
New workaround patch: diff --git a/node_modules/@remix-run/dev/compiler.js b/node_modules/@remix-run/dev/compiler.js
index d36818e..5f6a45b 100644
--- a/node_modules/@remix-run/dev/compiler.js
+++ b/node_modules/@remix-run/dev/compiler.js
@@ -19,6 +19,7 @@ var fse = require('fs-extra');
var debounce = require('lodash.debounce');
var chokidar = require('chokidar');
var nodeModulesPolyfill = require('@esbuild-plugins/node-modules-polyfill');
+var nodeGlobalsPolyfill = require('@esbuild-plugins/node-globals-polyfill');
var build$1 = require('./build.js');
var config = require('./config.js');
var warnings = require('./warnings.js');
@@ -329,7 +330,7 @@ async function createBrowserBuild(config, options) {
"process.env.NODE_ENV": JSON.stringify(options.mode),
"process.env.REMIX_DEV_SERVER_WS_PORT": JSON.stringify(config.devServerPort)
},
- plugins: [mdx.mdxPlugin(config), browserRouteModulesPlugin.browserRouteModulesPlugin(config, /\?browser$/), emptyModulesPlugin.emptyModulesPlugin(config, /\.server(\.[jt]sx?)?$/), nodeModulesPolyfill.NodeModulesPolyfillPlugin()]
+ plugins: [mdx.mdxPlugin(config), browserRouteModulesPlugin.browserRouteModulesPlugin(config, /\?browser$/), emptyModulesPlugin.emptyModulesPlugin(config, /\.server(\.[jt]sx?)?$/), nodeModulesPolyfill.NodeModulesPolyfillPlugin(), nodeGlobalsPolyfill.NodeGlobalsPolyfillPlugin()]
});
} |
@afk-mario thank you ser |
* docs: create remix example * docs: add dotenv to remix example * docs: copy components into remix example * docs: attach process to the window to prevent errors * docs: re-enable walletConnect and walletLinkConnector * docs: update components in remix example * docs: remove global assignment * docs: working metamask example * docs: add patch to expose node global modules remix-run/remix#114 * docs: working WalletConnect implementation * docs: add safe-event-emitter patch * docs: working walletlink example
* docs: create remix example * docs: add dotenv to remix example * docs: copy components into remix example * docs: attach process to the window to prevent errors * docs: re-enable walletConnect and walletLinkConnector * docs: update components in remix example * docs: remove global assignment * docs: working metamask example * docs: add patch to expose node global modules remix-run/remix#114 * docs: working WalletConnect implementation * docs: add safe-event-emitter patch * docs: working walletlink example
I tried with crypto/fs, both broken. You have to move it to a different file and import from there.
https://discord.com/channels/770287896669978684/771068344320786452/828673055777095720
The text was updated successfully, but these errors were encountered: