Enable macOS tests (#1774)

* Enable macOS tests

* Fix macOS tests
This commit is contained in:
Drew Powers 2021-11-11 10:24:48 -07:00 committed by GitHub
parent b67779d1dd
commit 5e0cb796a6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 0 deletions

View file

@ -21,6 +21,8 @@ jobs:
include:
- os: windows-latest
node_version: 16
- os: macos-latest
node_version: 16
fail-fast: false
env:
LANG: en-us

View file

@ -6,6 +6,7 @@ import type { AstroConfig } from '../@types/astro-core';
import esbuild from 'esbuild';
import fs from 'fs';
import { fileURLToPath } from 'url';
import os from 'os';
import { transform } from '@astrojs/compiler';
import { decode } from 'sourcemap-codec';
import { AstroDevServer } from '../core/dev/index.js';
@ -79,6 +80,12 @@ export default function astro({ config, devServer }: AstroPluginOptions): vite.P
return { code: result.code, map };
},
});
// macOS fix: remove null chars generated by compiler
if (os.platform() === 'darwin') {
tsResult.code = tsResult.code.replace(/\x00/g, '');
}
// Compile `.ts` to `.js`
const { code, map } = await esbuild.transform(tsResult.code, { loader: 'ts', sourcemap: 'external', sourcefile: id });