Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 12 additions & 2 deletions scripts/generate-mappings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down Expand Up @@ -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) => {
Expand Down