Skip to content

Commit

Permalink
fix vite on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
patricklx committed Dec 15, 2023
1 parent 5747458 commit b00cd4f
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 10 deletions.
8 changes: 4 additions & 4 deletions packages/shared-internals/src/package-cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import Package from './package';
import { existsSync, realpathSync } from 'fs';
import { getOrCreate } from './get-or-create';
import resolvePackagePath from 'resolve-package-path';
import { dirname, sep } from 'path';
import { dirname, posix } from 'path';

const realpathSyncCache = new Map<string, string>();

Expand Down Expand Up @@ -67,7 +67,7 @@ export default class PackageCache {
}

ownerOfFile(filename: string): Package | undefined {
let segments = filename.split(sep);
let segments = filename.replace(/\\/g, '/').split(posix.sep);

// first we look through our cached packages for any that are rooted right
// at or above the file.
Expand All @@ -79,11 +79,11 @@ export default class PackageCache {
}

let usedSegments = segments.slice(0, length);
let candidate = usedSegments.join(sep);
let candidate = usedSegments.join(posix.sep);
if (this.rootCache.has(candidate)) {
return this.rootCache.get(candidate);
}
if (getCachedExists([...usedSegments, 'package.json'].join(sep))) {
if (getCachedExists([...usedSegments, 'package.json'].join(posix.sep))) {
return this.get(candidate);
}
}
Expand Down
10 changes: 7 additions & 3 deletions packages/vite/src/bin/run-tests.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,13 @@ async function run() {

await /** @type {Promise<void>} */ (
new Promise(fulfill => {
const runvite = child.spawn(resolve(__root, 'node_modules', '.bin', 'vite'), ['--port', '60173', '--no-open'], {
stdio: 'pipe',
});
const runvite = child.fork(
resolve(__root, 'node_modules', 'vite', 'bin', 'vite.js'),
['--port', '60173', '--no-open'],
{
stdio: 'pipe',
}
);

process.on('exit', () => runvite.kill());

Expand Down
2 changes: 0 additions & 2 deletions packages/vite/src/esbuild-request.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import { type ModuleRequest, cleanUrl } from '@embroider/core';

export const virtualNamespace = 'embroider';

export class EsBuildModuleRequest implements ModuleRequest {
static from(
source: string,
Expand Down
1 change: 1 addition & 0 deletions tests/vite-app/app/components/fancy.gts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
<template>Yay for gts!</template>

2 changes: 1 addition & 1 deletion tests/vite-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"lint:js": "eslint . --cache",
"lint:js:fix": "eslint . --fix",
"start:prebuild": "ember build --watch",
"start:dev": "pnpm start:prebuild & vite --force",
"start:dev": "vite",
"start:test": "vite --open /tests/",
"test": "concurrently \"npm:lint\" \"npm:test:*\" --names \"lint,test:\"",
"test:ember": "node ./node_modules/@embroider/vite/src/bin/run-tests.mjs"
Expand Down

0 comments on commit b00cd4f

Please sign in to comment.