diff --git a/src/jiti.ts b/src/jiti.ts index 678dcfae..0299e8a1 100644 --- a/src/jiti.ts +++ b/src/jiti.ts @@ -133,12 +133,18 @@ export default function createJITI (_filename: string = process.cwd(), opts: JIT } function transform (filename: string, source: string, transformOptions: any) { - return getCache(filename, source, () => opts.transform!({ + let transfortmed = getCache(filename, source, () => opts.transform!({ source, filename, legacy: opts.legacy, ...transformOptions })) + + if (transfortmed.startsWith('#!')) { + transfortmed = '// ' + transfortmed + } + + return transfortmed } function jiti (id: string) { diff --git a/test/fixtures/hashbang/index.ts b/test/fixtures/hashbang/index.ts new file mode 100644 index 00000000..8503be30 --- /dev/null +++ b/test/fixtures/hashbang/index.ts @@ -0,0 +1,4 @@ +#!/usr/bin/env node +// in the Script Goal +'use strict' +console.log(1)