Skip to content
This repository has been archived by the owner on Jul 19, 2024. It is now read-only.

fix: require is not a function #65

Merged
merged 3 commits into from
Jan 23, 2018

Conversation

puhoy
Copy link
Contributor

@puhoy puhoy commented Jan 19, 2018

I stumbled upon a solution for #21 here.
This change seems to fix the problem, but i am not sure if this has other implications..?

@christopheranderson
Copy link
Contributor

christopheranderson commented Jan 22, 2018

Thanks for the PR! Let me look into the side effects of that plugin. I'm about to roll a 1.0 version, so if this is slightly breaking, I can still take it.

@christopheranderson christopheranderson self-assigned this Jan 22, 2018
@christopheranderson christopheranderson added this to the Sprint 15 milestone Jan 22, 2018
@christopheranderson
Copy link
Contributor

So, looking into this. This is a specific issue with folks that use Gently as their stubbing library which interferes with webpack doing its thing. This isn't a catch all fix for #21, but rather a very specific use case.

In this particular case, it looks like node-formiddable (used by Superagent) has some Gently stubbing code. Setting GENTLY to false disables the code path that WebPack doesn't play nicely with.

I'm not sure I want to take this PR since it's a very specific use case that might have side effects. But I do think I've seen enough cases here where folks want to customize the WebPack config that it's probably time to address that.

So my proposal is to offer the option to specify a .js file which will export a method which will be passed the WebPack config. It can then modify it to its liking (including breaking it, so BEWARE).

Then you could provide your customize option via:

// $root/webpack.config.js

module.exports = function(config) {
    config.plugins.push(new webpack.DefinePlugin({ "global.GENTLY": false }));
    return config;
}

Then when you call pack via the cli, you can specify it in the config file or the cli by giving the direct path name.

This allows folks to customize the config however they'd like.

Does this sound good, @puhoy?

@edyau
Copy link

edyau commented Jan 23, 2018

Sounds good we are also being affected by this issue, but we are not using the superagent library, so this is potentially quite a widespread problem.

@dnfclas
Copy link

dnfclas commented Jan 23, 2018

CLA assistant check
All CLA requirements met.

@puhoy
Copy link
Contributor Author

puhoy commented Jan 23, 2018

sounds good.
i added a --editConfig option to specify the path relative to the project root and updated the readme, including a small example snippet.

@christopheranderson
Copy link
Contributor

@edyau, my point was only that this type of thing can help fix these issues, but it isn't a blanket fix. The libraries themselves need to be compliant. Gently is a pretty popular library, so this should help fix a number of these types of issues. Since it doesn't change WebPack's behavior (which operates by design), you'll still need to figure out, for a given library, why there is require errors. This feature (with @puhoy's updates) is a really powerful tool, though, and should help a lot.

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

Successfully merging this pull request may close these issues.

5 participants