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

Critical dependencies error #205

Closed
gunta opened this issue Mar 17, 2014 · 6 comments
Closed

Critical dependencies error #205

gunta opened this issue Mar 17, 2014 · 6 comments

Comments

@gunta
Copy link

gunta commented Mar 17, 2014

Hi!
I get a 'Critical dependencies' error when trying to use the Promise library Bluebird.

I'm not exactly sure what does this means.

WARNING in ./res/bower_components/bluebird/js/browser/bluebird.js
Critical dependencies.
 @ ./res/bower_components/bluebird/js/browser/bluebird.js 27:376-383

WARNING in ./res/bower_components/bluebird/js/browser/bluebird.js
Critical dependencies.
 @ ./res/bower_components/bluebird/js/browser/bluebird.js 27:642-649

Thank you!

@sokra
Copy link
Member

sokra commented Mar 17, 2014

Don't use the prebuild version. Just install from npm and require it.

$ npm install bluebird
npm http GET https://registry.npmjs.org/bluebird
npm http 200 https://registry.npmjs.org/bluebird
npm http GET https://registry.npmjs.org/bluebird/-/bluebird-1.1.0.tgz
npm http 200 https://registry.npmjs.org/bluebird/-/bluebird-1.1.0.tgz
bluebird@1.1.0 node_modules\bluebird

$ webpack bluebird bundle.js
Hash: f7c7a911ab1613c8d119
Version: webpack 1.1.0-beta8
...
# compiles fine

@gunta
Copy link
Author

gunta commented Mar 18, 2014

Hi! Yes, that's what I'm doing currently, but it's a workaround.

I don't really want to build the library every time (because it takes time even with caching/watch).
I was thinking this is a WebPack issue, and I'm not sure what 'Critical dependencies' means, nor how to prevent it if I make a library similar to bluebird.

I think WebPack should be able to at least work with the bluebird build from bower (not only npm one), what do you think?

@dashed
Copy link
Contributor

dashed commented Mar 18, 2014

@gunta maybe this? #196 (comment)

@sokra
Copy link
Member

sokra commented Mar 18, 2014

webpack 1.1 contains a little explaination for the Critical dependencies warning.

The browser version of bluebird is built with browserify. I'll check if webpack can detect browserify. You should be able to fix it with imports?require=>undefined!bluebird

@altano
Copy link

altano commented Jan 5, 2015

I was having trouble getting the above methods to work with knockout 3.2. I tried just using noParse but the resulting module export was an empty object. Looking at the knockout code, if require and define were not present, it would export a global variable and not export it.

So there were two options: use script-loader (and lose minification or switch to the .min.js flavor) or, since knockout is never actually going to call require in my code base, export a require function that just throws an exception if ever called. I opted for the latter.

var errorFn = function() { throw new Error("knockout attempting to require"); }

var config = {
    ...
    module: {
        loaders: [
            { test: /knockout.build.output.knockout-latest(\.debug)?\.js$/, loader: "imports?require=>" + errorFn.toString() }

Why is it so hard for people to just use UMD. =\

@jhnns
Copy link
Member

jhnns commented Jan 5, 2015

Why don't you just export the global variable?

Why is it so hard for people to just use UMD. =\

No one knows ^^

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants