Skip to content

Commit

Permalink
fix: use file protocol for esm package imports (#25)
Browse files Browse the repository at this point in the history
Co-authored-by: Eugen Podaru <eugen.podaru@knab.nl>
  • Loading branch information
eugenpodaru and eugenpodaru committed May 22, 2023
1 parent 80c100b commit 9242270
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/commands/compile/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import type { StateMachine } from '../../types/index.js'
import type { Argv } from 'yargs'

import path from 'node:path'
import { pathToFileURL } from 'node:url'

export function builder(yargs: Argv): Argv<StateMachineCompileInput> {
return yargs
Expand All @@ -27,7 +28,7 @@ export async function handler(argv: ReturnType<typeof builder>['argv']): Promise
// If the path is not an absolute path, attempt to resolve it relative to the working directory
file = path.join(process.cwd(), file)
}
file = file.replace(/\.ts$/, '.js')
file = pathToFileURL(file.replace(/\.ts$/, '.js')).href

// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
const { [input.export]: definition } = await import(file)
Expand Down

0 comments on commit 9242270

Please sign in to comment.