diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d6bc6c7f6..45a632776 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 diff --git a/packages/astro/src/vite-plugin-astro/index.ts b/packages/astro/src/vite-plugin-astro/index.ts index d22b1caf1..8e68d9504 100644 --- a/packages/astro/src/vite-plugin-astro/index.ts +++ b/packages/astro/src/vite-plugin-astro/index.ts @@ -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 });