solid-start icon indicating copy to clipboard operation
solid-start copied to clipboard

fix unstable islands on windows

Open orenelbaum opened this issue 1 year ago • 5 comments

I replaced the backslashes in the windows path with forward slashes

orenelbaum avatar Dec 02 '22 09:12 orenelbaum

I have to ask.. is doing path conversions like this our best option?

ryansolid avatar Dec 03 '22 07:12 ryansolid

There's no native path conversion in node, unfortunately.

atk avatar Dec 03 '22 09:12 atk

I don't know if that's how it's supposed to be done, but it seems to work on both Windows and Linux

orenelbaum avatar Dec 03 '22 09:12 orenelbaum

I implemented a similar fix in the movies branch. Using the vite normalizePath function. https://github.com/solidjs/solid-start/blob/movies/packages/start/islands/vite-plugin.js

dev-rb avatar Dec 03 '22 18:12 dev-rb

I don't know if that's how it's supposed to be done

Going by the node documentation I'd assume something like this:

// file: index.mjs
import { parse, posix, sep} from 'node:path';

const toPosix = (original) => 
  original.split(sep).join(posix.sep);

const full = process.argv[1];
const { root, dir } = parse(full);
const noRoot = dir.slice(root.length);

console.log(toPosix(full));
console.log(toPosix(dir));
console.log(toPosix(noRoot));

That said Vite's regex replace seems to be the fastest on V8.

peerreynders avatar Dec 04 '22 15:12 peerreynders