-
-
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
Critical dependency: the request of a dependency is an expression #2883
Comments
First of all: Parcel doesn't support that file: #2110 Haven't looked further into your issue, could you please provide some code sample/repo/gist to speed this up? |
Hi @mischnic, thanks for the prompt reply. To clarify, my library doesn't have a As mentioned, my repository is here: https://github.com/mattrothenberg/vue-storybook/tree/v2 The bundled files live in |
I can confirm, I'm running into the same warning. To provide context, I have a private npm module which uses
Which is pointing to the source at below condition and
I'm not sure if this is due to the way parcel is bundling the code or some bad config for webpack is causing this warning. |
Interesting, this happens because webpack provides it's own var nodeRequire = typeof require === 'function' && require;
// ...
// Try the node require function if it exists.
if (nodeRequire && typeof name === 'string') {
return nodeRequire(name);
} |
@mattrothenberg Do these warnings happen for you when your library is then consumed by Webpack? This is a warning by Webpack (not Parcel). That error formatting seemed familiar... |
@mischnic I'm not sure I understand your question. If my library is bundled with Parcel, and consumed in a project that uses Webpack, I get the warning. |
You did understand 😄 :
|
I've had the same issue for a bit now, in my webpack project I'm doing this to hide the warning: // @giphy/js-brand uses parcel-bundler which has require statements
new webpack.ContextReplacementPlugin(/\/@giphy\/js-brand\//, data => {
delete data.dependencies[0].critical
return data
}), However, I'm the author of the dependency and I'd rather not have to have people do this in their webpack projects |
As already said in #2883 (comment), this happens because the bundle emitted by Parcel falls back to a global @DeMoorJasper Is this part needed for parcel/packages/core/parcel-bundler/src/builtins/prelude.js Lines 8 to 35 in 7ddb838
Reproduction: https://github.com/jooohn/reproduce-contentful-ui-extensions-error |
@mischnic I don't think so. As long as we don't overwrite the global require it should be fine. |
Also seeing this for libs bundled with Parcel when used in a Wepback project. Kind of bad, would appreciate a fix. |
It's a real issue in our project where global require() is overwritten by RequireJS. So nodeRequire fails loading modules with no exceptions thrown. We cannot remove RequireJS because it's the vital part of system architecture. |
Im facing the same problem. I bundled a lib with Parcel and Im importing it in Nuxt Js, which uses Webpack, and it shows this warning :/ |
So,What's the best resolution with this proplem ? I think I need help,I'm facing the same situation |
As parcel lead to issues with webpack, we now also use webpack as bundler. For more information look at parcel-bundler/parcel#2883
I think this shouldn't be an issue with Parcel 2. Parcel 1 wasn't really meant for building libraries, but Parcel 2 is. It will output native ESM or CommonJS that can be consumed by another bundler such as webpack rather than code meant to run directly in a browser. |
Here's a workaround for anyone still depending on a Parcel 1 project using Webpack After you install a library that is bundled with Parcel 1, there's a line at the top defining function If you change |
At the end I switched to Webpack and everything worked as expected. Now that Parcel 2 has a RC version I will try it again. |
🐛 bug report
Howdy! I'm the author of
vue-storybook
, a library that allows Vue developers to add<story>
blocks to their Vue single-file components and have them automatically translated into Storybook stories.Parcel is my go-to bundler, though I'm experiencing some strange behavior when bundling/publishing my library code and subsequently using it in a freshly scaffolded Vue CLI project. Without fail, when running the Vue development server, I'm getting the following warning:
I'm confused, because I don't see this message when I bundle my library code with Webpack or Rollup. I'm doubly confused because I'm not using any special configuration with Parcel, just a good ole'
build
command. It's just a warning, so I'm not too concerned. But I've gotten user feedback that this is distracting. I'd like the warning to go away.🎛 Configuration (.babelrc, package.json, cli command)
There's no Babel configuration for
vue-storybook
, though freshly scaffolded Vue CLI projects have the followingbabel.config.js
🤔 Expected Behavior
When using
vue-storybook
with a freshly scaffolded Vue CLI project, there should be no such warning aboutthe request of a dependency is an expression
😯 Current Behavior
When using
vue-storybook
with a freshly scaffolded Vue CLI project, there is a warning aboutthe request of a dependency is an expression
💁 Possible Solution
No ideas. I'm fairly certain this is user error somewhere on my part.
🔦 Context
I'm trying to publish a new version of my library (bundled with Parcel), and I'd like consumers not to see this warning message when using it.
🌍 Your Environment
The text was updated successfully, but these errors were encountered: