Skip to content

Commit

Permalink
fix(stub): use file:// protocol for windows compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
pi0 committed Apr 12, 2022
1 parent 746e02d commit 12a99c1
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/builder/rollup.ts
@@ -1,5 +1,6 @@
import { writeFile, mkdir } from 'fs/promises'
import { promises as fsp } from 'fs'
import { pathToFileURL } from 'url'
import type { RollupOptions, OutputOptions, OutputChunk } from 'rollup'
import { rollup } from 'rollup'
import commonjs from '@rollup/plugin-commonjs'
Expand Down Expand Up @@ -36,7 +37,8 @@ export async function rollupBuild (ctx: BuildContext) {
if (ctx.options.rollup.emitCJS) {
await writeFile(output + '.cjs', `${shebang}module.exports = require(${JSON.stringify(jitiPath)})(null, { interopDefault: true })('${entry.input}')`)
}
await writeFile(output + '.mjs', `${shebang}import jiti from ${JSON.stringify(jitiPath)};\nexport default jiti(null, { interopDefault: true })('${entry.input}');`)
// Use file:// protocol for windows compatibility
await writeFile(output + '.mjs', `${shebang}import jiti from ${JSON.stringify(pathToFileURL(jitiPath).href)};\nexport default jiti(null, { interopDefault: true })('${entry.input}');`)
await writeFile(output + '.d.ts', `export * from '${entry.input}';\nexport { default } from '${entry.input}';`)

if (shebang) {
Expand Down

0 comments on commit 12a99c1

Please sign in to comment.