Skip to content
Merged
16 changes: 12 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ on:

jobs:
get-matrix:
name: Configure Node LTS environment matrix
runs-on: ubuntu-latest

outputs:
latest: ${{ steps.set-matrix.outputs.requireds }}
steps:
Expand All @@ -39,6 +41,8 @@ jobs:
preset: ">= 22" # glob is not backported below 22.x

lint-and-types:
name: Lint & types

if: ${{ github.event_name != 'pull_request' || !github.event.pull_request.draft }}

runs-on: ubuntu-latest
Expand All @@ -51,18 +55,21 @@ jobs:
- name: Set up Node.js LTS
uses: actions/setup-node@v4
with:
node-version-file: ".nvmrc"
cache: "npm"
check-latest: true
node-version-file: ".nvmrc"
- run: npm ci
- run: node --run lint
- run: node --run type-check

tests:
needs: [get-matrix]
runs-on: ${{ matrix.os }}
name: Unit, e2e, coverage

if: ${{ github.event_name != 'pull_request' || !github.event.pull_request.draft }}

needs: [get-matrix]
runs-on: ${{ matrix.os }}

strategy:
fail-fast: false
matrix:
Expand All @@ -80,8 +87,9 @@ jobs:
- name: Set up Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: "npm"
check-latest: true
node-version: ${{ matrix.node-version }}
- run: npm ci
- name: Run recipe tests
run: >-
Expand Down
18 changes: 18 additions & 0 deletions recipes/correct-ts-specifiers/src/nodejs.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// TODO: Delete this file once https://github.com/DefinitelyTyped/DefinitelyTyped/pull/72122
// is released in @types/node@22.15.x

import type { ResolveHook, LoadHook } from 'node:module';

declare module "module" {
namespace Module {
function registerHooks(hooks: {
resolve?: ResolveHook,
load?: LoadHook,
}): ModuleHooks;

class ModuleHooks {
constructor(resolve?: ResolveHook, load?: LoadHook);
deregister(): void;
}
}
}
4 changes: 3 additions & 1 deletion recipes/correct-ts-specifiers/src/workflow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ import type { Helpers } from '@codemod.com/workflow/dist/jsFam.d.ts';
import { mapImports } from './map-imports.ts';
import type { FSAbsolutePath } from './index.d.ts';

module.register('@nodejs-loaders/alias', import.meta.url);
import * as aliasLoader from '@nodejs-loaders/alias/alias.loader.mjs';

module.registerHooks(aliasLoader);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
module.registerHooks(aliasLoader);
// Registering sync hooks to resolve ts path alias
module.registerHooks(aliasLoader);


export async function workflow({ contexts, files }: Api) {
await files(globPattern).jsFam(processModule);
Expand Down