dream2nix
dream2nix copied to clipboard
React "unexpected token", missing loader?
I'm trying to build a piece of software called Filestash which uses webpack in the buildPhase, in the following flake nix build .#js -L
will let you build it and see the same error https://github.com/matthewcroughan/filestash/tree/mc/nixify
filestash> assets/vendor/pdfjs/2.6.347/es5/build/pdf.worker.min.js.br 201 kB [emitted]
filestash> [0] ./client/index.js 386 bytes {0} [built] [failed] [1 error]
filestash> ERROR in ./client/index.js
filestash> Module parse failed: /nix/store/pbqdxakfhbzjkssxwmiya1w30dn3a1g1-filestash-0.0.0/lib/node_modules/filestash/client/index.js Unexpected token (19:12)
filestash> You may need an appropriate loader to handle this file type.
filestash> | function render() {
filestash> | ReactDOM.render(
filestash> | <Router/>,
filestash> | document.querySelector("div[role='main']"),
filestash> | );
filestash> Child html-webpack-plugin for "index.html":
filestash> [0] ./~/html-webpack-plugin/lib/loader.js!./client/index.html 12.8 kB {0} [built]
This issue seems to be the same kind as in
- https://github.com/nix-community/dream2nix/issues/237
- https://github.com/nix-community/dream2nix/issues/120
This issue has been mentioned on NixOS Discourse. There might be relevant details there:
https://discourse.nixos.org/t/go-derivation-for-filestash-not-playing-ball/11725/13
Just tested, and https://github.com/nix-community/dream2nix/pull/337 fixes this issue as well
@DavHau Looks like the fix breaks the workarounds. https://github.com/MatthewCroughan/filestash-nix/actions/runs/3330493891/jobs/5509054078#step:7:3637
@MatthewCroughan that's because it was based off of this fix: https://github.com/MatthewCroughan/filestash-nix/blob/master/pkgs/filestash/default.nix#L17-L26 You can remove that now.
@DavHau Looks like the fix breaks the workarounds.
This is a natural thing to happen if you keep your workarounds for yourself and never upstream them :P The more fixes you keep downstream, the likelier breakages happen, whenever upstream progresses. see also: https://www.haskellforall.com/2020/07/the-golden-rule-of-software-quality.html