Skip to content

Commit

Permalink
Don't fail if sourcemaps are not generated
Browse files Browse the repository at this point in the history
Fix: #56
Close: #57
  • Loading branch information
isaacs committed Apr 14, 2024
1 parent 8e848e8 commit 6ceb2a8
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/build-esm.ts
@@ -1,6 +1,6 @@
import chalk from 'chalk'
import { spawnSync } from 'node:child_process'
import { renameSync, unlinkSync } from 'node:fs'
import { existsSync, renameSync, unlinkSync } from 'node:fs'
import { relative, resolve } from 'node:path'
import buildFail from './build-fail.js'
import config from './config.js'
Expand All @@ -10,6 +10,10 @@ import setFolderDialect from './set-folder-dialect.js'
import './tsconfig.js'
import tsc from './which-tsc.js'

const unlinkIfExist = (f: string) => existsSync(f) && unlinkSync(f)
const renameIfExist = (f: string, to: string) =>
existsSync(f) && renameSync(f, to)

const node = process.execPath
const { esmDialects = [] } = config

Expand All @@ -35,10 +39,10 @@ export const buildESM = () => {
`.tshy-build/${d}`,
relative(resolve('src'), resolve(orig))
).replace(/\.tsx?$/, '')
unlinkSync(`${stemTo}.js.map`)
unlinkSync(`${stemTo}.d.ts.map`)
renameSync(`${stemFrom}.mjs`, `${stemTo}.js`)
renameSync(`${stemFrom}.d.mts`, `${stemTo}.d.ts`)
unlinkIfExist(`${stemTo}.js.map`)
unlinkIfExist(`${stemTo}.d.ts.map`)
renameIfExist(`${stemFrom}.mjs`, `${stemTo}.js`)
renameIfExist(`${stemFrom}.d.mts`, `${stemTo}.d.ts`)
}
console.error(chalk.cyan.bold('built ' + d))
}
Expand Down

0 comments on commit 6ceb2a8

Please sign in to comment.