diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 852bb6bd97..85717546a1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -60,6 +60,22 @@ jobs: name: coverage path: coverage + babel-plugin-windows: + name: Babel plugin (Windows) + runs-on: windows-latest + steps: + - name: Configure line endings + run: git config --global core.autocrlf input + + - name: Checkout + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + + - name: Setup + uses: ./.github/actions/setup + + - name: Run babel plugin tests + run: yarn jest src/babel + build-package: name: Build package runs-on: ubuntu-latest diff --git a/scripts/generate-mappings.ts b/scripts/generate-mappings.ts index b6a172e7c6..088273a643 100644 --- a/scripts/generate-mappings.ts +++ b/scripts/generate-mappings.ts @@ -2,7 +2,13 @@ import { parse } from '@babel/parser'; import * as types from '@babel/types'; import type { Identifier, StringLiteral } from '@babel/types'; import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs'; -import { dirname, join, relative as relativePath, resolve } from 'node:path'; +import { + dirname, + join, + relative as relativePath, + resolve, + sep, +} from 'node:path'; import { fileURLToPath } from 'node:url'; type PackageJson = { @@ -49,8 +55,12 @@ const ast = parse(source, { }); const index = packageJson.main; +// The result ends up in an import specifier, which always uses forward slashes, +// so normalise the platform separator that `relative` returns on Windows. const relative = (value: string) => - relativePath(root, resolve(root, dirname(index), value)); + relativePath(root, resolve(root, dirname(index), value)) + .split(sep) + .join('/'); const mappings = ast.program.body.reduce<{ [key: string]: Mapping }>( (acc, declaration, _index, self) => {