Skip to content

Commit 01f43c1

Browse files
authored
ci: setup windows ci for compiler and SSR tests (#8143)
1 parent 29da504 commit 01f43c1

File tree

3 files changed

+50
-13
lines changed

3 files changed

+50
-13
lines changed

.github/workflows/ci.yml

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,40 @@ jobs:
2626
node-version: 18
2727
cache: 'pnpm'
2828

29-
- run: PUPPETEER_SKIP_DOWNLOAD=1 pnpm install
29+
- name: Skip Puppeteer download
30+
run: echo "PUPPETEER_SKIP_DOWNLOAD=1" >> $GITHUB_ENV
31+
32+
- run: pnpm install
3033

3134
- name: Run unit tests
3235
run: pnpm run test-unit
3336

37+
unit-test-windows:
38+
runs-on: windows-latest
39+
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository
40+
steps:
41+
- uses: actions/checkout@v3
42+
43+
- name: Install pnpm
44+
uses: pnpm/action-setup@v2
45+
46+
- name: Set node version to 18
47+
uses: actions/setup-node@v3
48+
with:
49+
node-version: 18
50+
cache: 'pnpm'
51+
52+
- name: Skip Puppeteer download
53+
run: echo "PUPPETEER_SKIP_DOWNLOAD=1" >> $env:GITHUB_ENV
54+
55+
- run: pnpm install
56+
57+
- name: Run compiler unit tests
58+
run: pnpm run test-unit compiler
59+
60+
- name: Run ssr unit tests
61+
run: pnpm run test-unit server-renderer
62+
3463
e2e-test:
3564
runs-on: ubuntu-latest
3665
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository
@@ -72,7 +101,10 @@ jobs:
72101
node-version: 18
73102
cache: 'pnpm'
74103

75-
- run: PUPPETEER_SKIP_DOWNLOAD=1 pnpm install
104+
- name: Skip Puppeteer download
105+
run: echo "PUPPETEER_SKIP_DOWNLOAD=1" >> $GITHUB_ENV
106+
107+
- run: pnpm install
76108

77109
- name: Run eslint
78110
run: pnpm run lint

packages/compiler-sfc/src/script/resolveType.ts

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ import {
2929
createGetCanonicalFileName,
3030
getId,
3131
getImportedName,
32-
normalizePath
32+
normalizePath,
33+
joinPaths
3334
} from './utils'
3435
import { ScriptCompileContext, resolveParserPlugins } from './context'
3536
import { ImportBinding, SFCScriptCompileOptions } from '../compileScript'
@@ -38,7 +39,7 @@ import { parse as babelParse } from '@babel/parser'
3839
import { parse } from '../parse'
3940
import { createCache } from '../cache'
4041
import type TS from 'typescript'
41-
import path from 'path'
42+
import { extname, dirname } from 'path'
4243

4344
/**
4445
* TypeResolveContext is compatible with ScriptCompileContext
@@ -718,7 +719,7 @@ function importSourceToScope(
718719
let resolved
719720
if (source.startsWith('.')) {
720721
// relative import - fast path
721-
const filename = normalizePath(path.join(scope.filename, '..', source))
722+
const filename = joinPaths(scope.filename, '..', source)
722723
resolved = resolveExt(filename, fs)
723724
} else {
724725
// module or aliased import - use full TS resolution, only supported in Node
@@ -741,9 +742,10 @@ function importSourceToScope(
741742
resolved = resolveWithTS(scope.filename, source, fs)
742743
}
743744
if (resolved) {
745+
resolved = normalizePath(resolved)
744746
// (hmr) register dependency file on ctx
745747
;(ctx.deps || (ctx.deps = new Set())).add(resolved)
746-
return fileToScope(ctx, normalizePath(resolved))
748+
return fileToScope(ctx, resolved)
747749
} else {
748750
return ctx.error(
749751
`Failed to resolve import source ${JSON.stringify(source)}.`,
@@ -761,8 +763,8 @@ function resolveExt(filename: string, fs: FS) {
761763
tryResolve(filename) ||
762764
tryResolve(filename + `.ts`) ||
763765
tryResolve(filename + `.d.ts`) ||
764-
tryResolve(filename + `/index.ts`) ||
765-
tryResolve(filename + `/index.d.ts`)
766+
tryResolve(joinPaths(filename, `index.ts`)) ||
767+
tryResolve(joinPaths(filename, `index.d.ts`))
766768
)
767769
}
768770

@@ -800,7 +802,7 @@ function resolveWithTS(
800802
const parsed = ts.parseJsonConfigFileContent(
801803
ts.readConfigFile(configPath, fs.readFile).config,
802804
parseConfigHost,
803-
path.dirname(configPath),
805+
dirname(configPath),
804806
undefined,
805807
configPath
806808
)
@@ -870,7 +872,7 @@ function parseFile(
870872
content: string,
871873
parserPlugins?: SFCScriptCompileOptions['babelParserPlugins']
872874
): Statement[] {
873-
const ext = path.extname(filename)
875+
const ext = extname(filename)
874876
if (ext === '.ts' || ext === '.tsx') {
875877
return babelParse(content, {
876878
plugins: resolveParserPlugins(ext.slice(1), parserPlugins),

packages/compiler-sfc/src/script/utils.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,12 @@ export function createGetCanonicalFileName(useCaseSensitiveFileNames: boolean) {
9999
return useCaseSensitiveFileNames ? identity : toFileNameLowerCase
100100
}
101101

102+
// in the browser build, the polyfill doesn't expose posix, but defaults to
103+
// posix behavior.
104+
const normalize = (path.posix || path).normalize
102105
const windowsSlashRE = /\\/g
103106
export function normalizePath(p: string) {
104-
// in the browser build, the polyfill doesn't expose posix, but defaults to
105-
// posix behavior.
106-
return (path.posix || path).normalize(p.replace(windowsSlashRE, '/'))
107+
return normalize(p.replace(windowsSlashRE, '/'))
107108
}
109+
110+
export const joinPaths = (path.posix || path).join

0 commit comments

Comments
 (0)