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

Checks don't work for modules #20

Open
olebedev opened this issue May 10, 2023 · 1 comment
Open

Checks don't work for modules #20

olebedev opened this issue May 10, 2023 · 1 comment

Comments

@olebedev
Copy link
Collaborator

Some of the NPM modules utilise new feature of Node.js that is called modules, that is declared as:

{
  ...
  "type": "module,
  ...
}

in package.json file. And the current implementation of checks, like:

node -e 'require("/nix/store/4dj4m2yanj5z1182ji9y47vir6w723bk-formdata-polyfill-4.0.10/lib")

doesn't work with that new module type.

I found that for the packages of the module type, this check would work:

node --input-type=module -e 'import  "/nix/store/4dj4m2yanj5z1182ji9y47vir6w723bk-formdata-polyfill-4.0.10/lib/formdata.min.js"'

that is, the check needs to add --input-type=module option and specify the file explicitly.

@olebedev
Copy link
Collaborator Author

olebedev commented May 10, 2023

As a workaround for the projects that face this check issue:

let
  env = pkgs.js2nix {
    package-json = ./package.json;
    yarn-lock = ./yarn.lock;
    overlays = [
      (self: super: {
        # TODO: remove once this https://github.com/canva-public/js2nix/issues/20 is resolved
        buildNodeModule = pkgs.lib.makeOverridable
          (args: (super.buildNodeModule args).override { doCheck = false; });
      })
    ];
  };
in env.nodeModules

It disables checks for the whole dependency closure.

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

1 participant