-
-
Notifications
You must be signed in to change notification settings - Fork 125
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
Support running Insect with Node 10 #333
Conversation
Thank you. I managed to run Insect on Ubuntu 20.04 using this branch. It looks like I still need the Users with node versions < 12 can use the following FROM node:18
WORKDIR /usr/src/insect
COPY . .
RUN npm install -g purescript --unsafe-perm && \
npm install -g spago && \
npm install && \
npm run build
ENV XDG_DATA_HOME /tmp
CMD ["node", "index.min.cjs"] After creating the image ( docker create sharkdp/insect:latest
# copy SHA (e.g. 71f0797703e8)
docker cp 71f0797703e8:/usr/src/insect/index.min.cjs .
docker cp -r 71f0797703e8:/usr/src/insect/node_modules . This workflow can also almost certainly be improved 😄 To directly run docker run -it --rm sharkdp/insect:latest |
Correct, that is intentional, as I don't use Docker, but your work looks neat. Maybe we can include it somewhere in the documentation? |
By the way, I think the manual installation of PureScript and Spago in the Dockerfile isn't necessary, is it? Both are in |
Ah. I saw a lot of warnings concerning esbuild and assumed that the
Correct. I played around in the docker container interactively before and somehow needed that. Confirming that the following also works: FROM node:18
WORKDIR /usr/src/insect
COPY . .
RUN npm install && \
npm run build
CMD ["node", "index.min.cjs"] I also removed the docker run -it --rm -v "$HOME"/.local/share/insect-history:/root/.local/share/insect-history sharkdp/insect:latest Does it make sense to share that Dockerfile in the repo? Or maybe even upload the docker image to Docker hub? |
Does this PR have any influence on the startup time? This is what I'm getting on node 10
Seems to be quite a bit worse than what we had here #322, but obviously that's two different machines (and node versions!). |
4b482c2
to
81c16f0
Compare
Ah, I forgot about that, thanks for reminding me about that.
That's because the benchmarks run Using the modified benchmark script with this PR, here are the results on my machine (with Node 18.7.0):
On
This PR is a little faster, which makes sense, given that with |
6504ca1
to
8366cd0
Compare
8366cd0
to
567ed89
Compare
What are your thoughts about testing the various supported Node.js versions in CI? If you like the idea, how do you think we should go about it? |
I think we shouldn't put too much burden on us. Sure, a matrix build sounds great, but I'd be completely fine with testing the lowest supported version for now. Or do we expect the PureScript compiler to output code that would break in newer versions of node? |
The issue here isn't testing multiple Node versions, the issue is testing with Node 10, as it is unable to build Insect, only run it.
I don't think we can expect the compiler to, no, but I do believe that our build system might cause breakage. |
Oh, right. Of course. So for that case, we should probably install both Node 10 and a newer version within a single container?
Ok. |
Any ideas how we can do that? |
To be honest, I don't know. Maybe |
Frankly, I don't feel like working on Node 10 testing in the CI (at least for the time being). I still think it's a good idea though, so anybody can feel free to work on it. For now, I'm marking this PR as ready for review; if it looks good to you, please feel free to merge it (please also check out my review comments above). |
I think that's a good idea. Where do you suggest we put it and document it? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Frankly, I don't feel like working on Node 10 testing in the CI (at least for the time being). I still think it's a good idea though, so anybody can feel free to work on it. For now, I'm marking this PR as ready for review; if it looks good to you, please feel free to merge it (please also check out my review comments above).
Of course. Let's support it on a "best effort" basis for now and skip the CI setup.
Does it make sense to share that Dockerfile in the repo?
I think that's a good idea. Where do you suggest we put it and document it?
I would put that at the bottom of the Development section.
200df7b
to
4128348
Compare
This should be ready. Please take a last look at my changes and then merge if everything looks good. |
Fixes sharkdp#306. I was unable to get Node 10 to run ESM files, so I made `index.cjs` a CommonJS file to work around the problem. I also had to downgrade `clipboardy` and `xdg-basedir` to versions that support CommonJS imports. Additional, the benchmark script was modified to benchmark `index.cjs` instead of `index.js`, as that is what would actually be run by those who install Insect. As a result of consolidating what was previously `index.js` and `insect.js` into one bundled and minified file `index.cjs`, the startup time was also slightly improved. Using the modified benchmark script with this commit, here are the results on my machine (with Node 18.7.0): | Command | Mean [ms] | Min [ms] | Max [ms] | Relative | |:---|---:|---:|---:|---:| | `Startup time (insect '1+1')` | 161.4 ± 1.8 | 157.7 | 164.5 | 1.00 | | Command | Mean [ms] | Min [ms] | Max [ms] | Relative | |:---|---:|---:|---:|---:| | `Startup time, stdin mode (insect < computations-1.ins)` | 180.5 ± 7.5 | 176.3 | 206.1 | 1.00 | | Command | Mean [ms] | Min [ms] | Max [ms] | Relative | |:---|---:|---:|---:|---:| | `Evaluation speed (insect < computations-160.ins)` | 1047.8 ± 15.0 | 1028.2 | 1072.1 | 1.00 | On current `master`: | Command | Mean [ms] | Min [ms] | Max [ms] | Relative | |:---|---:|---:|---:|---:| | `Startup time (insect '1+1')` | 179.9 ± 1.3 | 178.2 | 183.4 | 1.00 | | Command | Mean [ms] | Min [ms] | Max [ms] | Relative | |:---|---:|---:|---:|---:| | `Startup time, stdin mode (insect < computations-1.ins)` | 199.9 ± 2.0 | 196.9 | 202.5 | 1.00 | | Command | Mean [ms] | Min [ms] | Max [ms] | Relative | |:---|---:|---:|---:|---:| | `Evaluation speed (insect < computations-160.ins)` | 1079.1 ± 25.9 | 1044.4 | 1124.0 | 1.00 |
4128348
to
04198cc
Compare
Thank you very much! Final question: does this change anything with the release process to NPM ( |
To be honest, I do not know what the previous release process for NPM is, so I cannot comment on that part. However, I believe that with this PR, you don't need to do anything more than
Of course, it would probably be a good idea to test this first, perhaps by making a clean clone then running |
Thank you. The test worked great. |
I just learned that there is also another command that I forgot to mention: I considered running
Thoughts? |
I think we should do both 😄. And the documentation should simply be sth like this To publish a new version of Insect:
|
Hmm, sounds good, I'll see if I can open a PR for this. |
TODO:
Test different Node versions in CI? (given that this PR only makes Insect run, not build, with Node 10, and that Spago only supports Node 12+, this may or may not prove somewhat troublesome)