ai / autoprefixer-rails

Autoprefixer for Ruby and Ruby on Rails

Home Page:https://twitter.com/autoprefixer

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Autoprefixer version detection broken with latest execjs

aleksclark opened this issue · comments

With the following versions:

autoprefixer-rails (9.6.0)
GIT
  remote: https://github.com/rails/execjs.git
  revision: f6dc08c58ab4e1a467f64d471ee6e0127c2f14de
  ref: f6dc08c
  specs:
    execjs (2.7.0)

Autoprefixer seems to be using an invalid way of detecting node versions:

        if ExecJS.runtime == ExecJS::Runtimes::Node
          version = ExecJS.runtime.eval("process.version")
          first = version.match(/^v(\d+)/)[1].to_i
          if first < 6
            raise "Autoprefixer doesn’t support Node #{version}. Update it."
          end
        end

This code throws a TypeError, because process is null. If I comment out the check, autoprefixer seems to be functioning correctly.

What ExecJS runtime so you use?

Node, the vanilla one.

What Node.js version?

Oh sorry, v10.16.0. I think it also happens for node 8, but as part of my troubleshooting I've standardized on node 10 and it's tough to go back and test.

Hm. process is not null on Node.js 10. Maybe ExecJS uses different engine because of some issue?

User can pass custom node path to ExecJS

We have a different question here. process should be always available on Node since it is part of Node’s stdlib.

I completely agree! I've created a minimal test case, can you try it? https://github.com/aleksclark/autoprefixer-bug-repro

Also, here's the version that does work:
https://github.com/aleksclark/autoprefixer-bug-repro/tree/working

As you can see, the difference is in using the latest version of execjs. The problem is that the latest release of execjs is quite old, and does not prefer node over nodejs

Do we need to fix the problem if it is related with old ExecJS and could be a bug, which they fixed?

I afraid that without stdlib I can garantee that other autoprefixer.js will work. It should have process calls in polyfills.

I am closing this issue, since I have no idea how to fix it.