-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
require.resolve
is undefined in compiled code
#6925
Comments
As a note, both whatwg and Node.js have been working on Parcel may want to deal with this API as well. |
Workaround: re-create your require object with the import { createRequire } from 'module';
const req = createRequire(__dirname);
req.resolve('whatever'); |
Would really like to see this properly resolved :) |
Same |
ran into this today. The code in question is in a 3rd party package. I'm going to attempt to patch it using the above workaround |
Any plans on working on that? It makes me want to ditch parcel, as this is kinda basic functionality IMO. AFAIK webpack provides |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 14 days if no further activity occurs. |
🐛 bug report
In code that contains
require.resolve
, the function is replaced withundefined
🎛 Configuration (.babelrc, package.json, cli command)
The source:
🤔 Expected Behavior
Line 4 is compiled to
const pad = require.resolve("left-pad");
😯 Current Behavior
It is compiled to
const pad = undefined("left-pad");
💁 Possible Solution
🔦 Context
I am writing a build plugin for Netlify and need to find the path to a dependency in the user's site.
💻 Code Sample
Repo: https://github.com/ascorbic/parcel-bug/
Compiled output:
🌍 Your Environment
The text was updated successfully, but these errors were encountered: