rsms / estrella

Lightweight and versatile build tool based on the esbuild compiler

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Windows support (i.e. directly via cmd.exe or powershell, not WSL)

benmerckx opened this issue · comments

commented

Having a tsconfig.json results in:

...\build.js: ReferenceError: prog is not defined
    at ...\node_modules\estrella\dist\estrella.js:2:12202
    at new Promise (<anonymous>)
    at V (...\node_modules\estrella\dist\estrella.js:2:11825)
    at n (...\node_modules\estrella\dist\estrella.js:2:6134)
    at Aa (...\node_modules\estrella\dist\estrella.js:25:4614)
    at ...\node_modules\estrella\dist\estrella.js:25:1271
    at new Promise (<anonymous>)
    at da (...\node_modules\estrella\dist\estrella.js:25:1228)
    at build (...\node_modules\estrella\dist\estrella.js:26:801)
    at Object.<anonymous> (...\build.js:3:1)

Which I assume might actually be a bug in esbuilds minification. The distributed estrella.js does not define prog (I'm thinking the name was minified but this reference was not).
Edit: it is actually never defined in the source

The actual error it was trying to print refers to "tsc" not being found in path. I actually see a windows check here but it's not used further down in the function. As a note, I installed typescript through yarn locally which actually creates a ./node_modules/.bin/tsc.cmd file (not exe).

const testExeExtToo = process.platform.startsWith("win") && !/\.exe$/i.test(executableName)

Messing around to see the message also led me to find this (a + was forgotten here since we get a runtime TypeError: "." is not a function):

estrella/src/tslint.js

Lines 89 to 90 in 6d54414

Path.relative(process.cwd(), dirname(tsconfigFile)) + `.`
` Set tslint options.tsc="off" or pass -no-diag on the command line.`

commented

One more Windows issue: X_OK flag will not be available. Here's what works for me:
benmerckx@6f62e60
Not sure if I can PR this since: prog probably came from the estrella module before a refactor but importing would create circular imports so I just removed it. And I'm very unsure what should happen in a PATH lookup on Windows regarding extensions.

Thanks! Windows is not currently supported but I'd like to add support for it.
Estrella works in WLS though, so you could use that or Cygwin.

For Windows support there is also the src/exec and src/run modules which may need adjustments.

I've tested Estrella on Windows 10 (2004) and everything works except for -run which somehow doesn't manage to forward stdout and stderr.

For Windows, please use release 1.2.6 or later. (1.2.6 was just released when I posted this comment.)

Okay, 1.2.7 includes a fix for -run on Windows. Now everything works. Thanks!
Screen Shot 2020-09-29 at 19 19 47

commented

A few notes on trying the latest version. Building a project results in:

Unhandled exception: Error: spawn ...\node_modules\.bin\tsc ENOENT
    at Process.ChildProcess._handle.onexit (internal/child_process.js:267:19)
    at onErrorNT (internal/child_process.js:469:16)
    at processTicksAndRejections (internal/process/task_queues.js:84:21)

Pulling in the latest git changes proved a little difficult. Apparently windows does not allow files named aux regardless the extension (https://stackoverflow.com/a/61616948).

Building estrella gave me the same error as above. Fiddling in the minified code a little gave me this insight:

let tscprog = findTSC(options.cwd /* ok if undefined */)

tsprog here is the string: "C:\projects\estrella\node_modules.bin\tsc"

Seems that path came from here:

return Path.join(npmPath.substr(0, i + find.length - Path.sep.length), ".bin", "tsc")

When I add the (.cmd) extension there as well all works as expected.