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

webpack doesn't find transitive dependencies #58

Open
MagicRB opened this issue Mar 6, 2021 · 4 comments
Open

webpack doesn't find transitive dependencies #58

MagicRB opened this issue Mar 6, 2021 · 4 comments

Comments

@MagicRB
Copy link

MagicRB commented Mar 6, 2021

Hi, I'm trying to build ConcourseCI with Nix, specifically the frontend, which is written in Node and packages with Webpack. I'm currently struggling with actually using webpack to build the thing,

prev.stdenv.mkDerivation {
   pname = "concourse-static";
   version = concourse.version;

   src = node_modules;
   nativeBuildInputs = [ prev.yarn prev.nodejs ];

   buildPhase = ''
    yarn run webpack-cli --mode production 
  '';
};

I think that's what I need but, webpack can't find the global-modules package, the other yarn2nix over on nix-community does, i think, include it automatically, but I don't know why. I'm not a Node dev, so I'm just trying to force Concourse to build. Oh and if someone decides to try to build ConcourseCI, you'll need this patch. Am I doing something wrong, or should the global_modules be either included automatically by yarn2nix or should it be in concourse's repo. Thanks in advance!

@sternenseemann
Copy link
Collaborator

I'm not too familiar with global_modules or global-modules, but why would one expect a package to be built by yarn2nix if it is neither listed in package.json nor in yarn.lock? Can you point me to the nix-community/yarn2nix bit which includes that automatically? Maybe they explain it. To me this package seems like yet another normal module 😕 .

@MagicRB
Copy link
Author

MagicRB commented Mar 6, 2021

Webpack somewhere in its dep tree, tries to require global-modules, and yet it's not specified anywhere. And I am actually wrong, https://github.com/neoclide/coc-json/blob/1.3.2/yarn.lock#L1535 does specify it, so it's a mistake on the side of Concourse? But then how does it build normally... The Node ecosystem will always remain a mystery to me

@sternenseemann
Copy link
Collaborator

Oh, sorry, I missed it in yarn.lock. I am pretty sure this issue is related to #54, probably webpack uses some variant of require or import which expects everything to be located in the root node_modules directory, but yarn2nix currently only links the direct and not all transitive dependencies into that folder.

I hope I'll find the time soon to implement this feature, as it is really holding yarn2nix back for all things frontend since basically every bundler implements some custom mechanism for requiring dependencies which has some assumption that is incompatible with yarn2nix.

For now, I'd recommend to try to get your use case to work with nix-community/yarn2nix or node2nix possibly.

@sternenseemann sternenseemann changed the title global_modules npm package missing webpack doesn't find transitive dependencies Mar 6, 2021
@MagicRB
Copy link
Author

MagicRB commented Mar 6, 2021

Ah, ok, for now I'll just use the prebuilt docker containers (I wanted to package Concourse for Nix, so that I could build a container image from it, but I really need to get this CI/CD system working soon). I'll come back to this later. Thanks for the help! :)

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

2 participants