Enable Windows tests

This commit is contained in:
Drew Powers 2021-10-28 16:29:57 -06:00
parent a7e62ded69
commit 69d85d6988
7 changed files with 39 additions and 30 deletions

View file

@ -18,16 +18,15 @@ jobs:
matrix:
os: [ubuntu-latest]
node_version: [12, 14, 16]
# TODO: uncomment this (Vite has trouble resolving imports on Windows)
# include:
# - os: windows-latest
# node_version: 14
include:
- os: windows-latest
node_version: 16
fail-fast: false
env:
LANG: en-us
name: 'Test: node-${{ matrix.node_version }}, ${{ matrix.os }}'
steps:
- name: Checkout
- name: Check out
uses: actions/checkout@v2
- name: Set node version to ${{ matrix.node_version }}
@ -50,16 +49,16 @@ jobs:
lint:
runs-on: ubuntu-latest
name: 'Lint: node-14, ubuntu-latest'
name: 'Lint: node-16, ubuntu-latest'
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Set node version to 14
- name: Set node version to 16
uses: actions/setup-node@v2
with:
node-version: 14
node-version: 16
cache: 'yarn'
- name: Debug
@ -77,16 +76,16 @@ jobs:
# NOTE: temporarily disabled until `next` branch can build docs again
# smoke:
# runs-on: ubuntu-latest
# name: 'Smoke: node-14, ubuntu-latest'
# name: 'Smoke: node-16, ubuntu-latest'
# steps:
# - uses: actions/checkout@v2
# with:
# fetch-depth: 0
# - name: Set node version to 14
# - name: Set node version to 16
# uses: actions/setup-node@v2
# with:
# node-version: 14
# node-version: 16
# cache: 'yarn'
# - name: Debug

View file

@ -6,7 +6,7 @@ on:
- main
env:
node_version: 14
node_version: 16
jobs:
format:

View file

@ -6,19 +6,19 @@ on:
- cron: '0 12 * * *'
env:
node_version: 14
node_version: 16
jobs:
stat:
if: github.repository == 'snowpackjs/astro'
runs-on: ubuntu-latest
steps:
# Check out code using git
- uses: actions/checkout@v2
# Install Node 14
- uses: actions/setup-node@v1
- name: Check out
uses: actions/checkout@v2
- name: Set up Node.js 16.x
uses: actions/setup-node@v1
with:
version: 14
version: 16
- run: yarn install --frozen-lockfile --ignore-engines --ignore-scripts
- run: node scripts/stats/index.js
env:

View file

@ -67,7 +67,7 @@
"astring": "^1.7.5",
"ci-info": "^3.2.0",
"connect": "^3.7.0",
"es-module-lexer": "^0.7.1",
"es-module-lexer": "^0.9.3",
"esbuild": "^0.13.6",
"estree-util-value-to-estree": "^1.2.0",
"fast-xml-parser": "^3.19.0",

View file

@ -5,6 +5,7 @@ import type { TopLevelAstro } from '../../@types/astro-runtime';
import { valueToEstree } from 'estree-util-value-to-estree';
import * as astring from 'astring';
import shorthash from 'shorthash';
import { fileURLToPath } from 'url';
export { createMetadata } from './metadata.js';
const { generate, GENERATOR } = astring;
@ -117,7 +118,11 @@ function extractDirectives(inputProps: Record<string | number, any>): ExtractedP
}
switch (key) {
case 'client:component-path': {
try {
extracted.hydration.componentUrl = fileURLToPath(new URL(`file://${value}`));
} catch {
extracted.hydration.componentUrl = value;
}
break;
}
case 'client:component-export': {
@ -365,13 +370,17 @@ export async function renderToString(result: SSRResult, componentFactory: AstroC
const uniqueElements = (item: any, index: number, all: any[]) => {
const props = JSON.stringify(item.props);
const children = item.children;
return index === all.findIndex(i => JSON.stringify(i.props) === props && i.children == children)
}
return index === all.findIndex((i) => JSON.stringify(i.props) === props && i.children == children);
};
export async function renderPage(result: SSRResult, Component: AstroComponentFactory, props: any, children: any) {
const template = await renderToString(result, Component, props, children);
const styles = Array.from(result.styles).filter(uniqueElements).map((style) => renderElement('style', style));
const scripts = Array.from(result.scripts).filter(uniqueElements).map((script) => renderElement('script', script));
const styles = Array.from(result.styles)
.filter(uniqueElements)
.map((style) => renderElement('style', style));
const scripts = Array.from(result.scripts)
.filter(uniqueElements)
.map((script) => renderElement('script', script));
return template.replace('</head>', styles.join('\n') + scripts.join('\n') + '</head>');
}

View file

@ -46,7 +46,8 @@ export default function astro({ config, devServer }: AstroPluginOptions): vite.P
}
// pages and layouts should be transformed as full documents (implicit <head> <body> etc)
// everything else is treated as a fragment
const isPage = id.startsWith(fileURLToPath(config.pages)) || id.startsWith(fileURLToPath(config.layouts));
const normalizedID = fileURLToPath(new URL(`file://${id}`));
const isPage = normalizedID.startsWith(fileURLToPath(config.pages)) || id.startsWith(fileURLToPath(config.layouts));
let source = await fs.promises.readFile(id, 'utf8');
let tsResult: TransformResult | undefined;

View file

@ -4074,10 +4074,10 @@ es-abstract@^1.18.0-next.2, es-abstract@^1.18.5:
string.prototype.trimstart "^1.0.4"
unbox-primitive "^1.0.1"
es-module-lexer@^0.7.1:
version "0.7.1"
resolved "https://registry.yarnpkg.com/es-module-lexer/-/es-module-lexer-0.7.1.tgz#c2c8e0f46f2df06274cdaf0dd3f3b33e0a0b267d"
integrity sha512-MgtWFl5No+4S3TmhDmCz2ObFGm6lEpTnzbQi+Dd+pw4mlTIZTmM2iAs5gRlmx5zS9luzobCSBSI90JM/1/JgOw==
es-module-lexer@^0.9.3:
version "0.9.3"
resolved "https://registry.yarnpkg.com/es-module-lexer/-/es-module-lexer-0.9.3.tgz#6f13db00cc38417137daf74366f535c8eb438f19"
integrity sha512-1HQ2M2sPtxwnvOvT1ZClHyQDiggdNjURWpY2we6aMKCQiUVxTmVs2UYPLIrD84sS+kMdUwfBSylbJPwNnBrnHQ==
es-to-primitive@^1.2.1:
version "1.2.1"