-
-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
5,053 additions
and
2,570 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import chalk from 'chalk' | ||
import { linkSync, mkdirSync } from 'node:fs' | ||
import { dirname } from 'node:path' | ||
import { relative, resolve } from 'node:path/posix' | ||
import config from './config.js' | ||
import * as console from './console.js' | ||
import ifExist from './if-exist.js' | ||
import polyfills from './polyfills.js' | ||
import setFolderDialect from './set-folder-dialect.js' | ||
import sources from './sources.js' | ||
import './tsconfig.js' | ||
|
||
const { commonjsDialects = [] } = config | ||
|
||
// don't actually do a build, just link files into places. | ||
export const buildLiveCommonJS = () => { | ||
for (const d of ['commonjs', ...commonjsDialects]) { | ||
const pf = polyfills.get(d === 'commonjs' ? 'cjs' : d) | ||
console.debug(chalk.cyan.dim('linking ' + d)) | ||
for (const s of sources) { | ||
const source = s.substring('./src/'.length) | ||
const target = resolve(`.tshy-build/${d}/${source}`) | ||
mkdirSync(dirname(target), { recursive: true }) | ||
linkSync(s, target) | ||
} | ||
setFolderDialect('.tshy-build/' + d, 'commonjs') | ||
for (const [override, orig] of pf?.map.entries() ?? []) { | ||
const stemFrom = resolve( | ||
`.tshy-build/${d}`, | ||
relative(resolve('src'), resolve(override)) | ||
).replace(/\.cts$/, '') | ||
const stemTo = resolve( | ||
`.tshy-build/${d}`, | ||
relative(resolve('src'), resolve(orig)) | ||
).replace(/\.tsx?$/, '') | ||
ifExist.unlink(`${stemTo}.js.map`) | ||
ifExist.unlink(`${stemTo}.d.ts.map`) | ||
ifExist.rename(`${stemFrom}.cjs`, `${stemTo}.js`) | ||
ifExist.rename(`${stemFrom}.d.cts`, `${stemTo}.d.ts`) | ||
} | ||
console.error(chalk.cyan.bold('linked commonjs')) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import chalk from 'chalk' | ||
import { linkSync, mkdirSync } from 'node:fs' | ||
import { dirname, relative, resolve } from 'node:path' | ||
import config from './config.js' | ||
import * as console from './console.js' | ||
import ifExist from './if-exist.js' | ||
import polyfills from './polyfills.js' | ||
import setFolderDialect from './set-folder-dialect.js' | ||
import sources from './sources.js' | ||
import './tsconfig.js' | ||
|
||
const { esmDialects = [] } = config | ||
|
||
export const buildLiveESM = () => { | ||
for (const d of ['esm', ...esmDialects]) { | ||
const pf = polyfills.get(d) | ||
console.debug(chalk.cyan.dim('linking ' + d)) | ||
for (const s of sources) { | ||
const source = s.substring('./src/'.length) | ||
const target = resolve(`.tshy-build/${d}/${source}`) | ||
mkdirSync(dirname(target), { recursive: true }) | ||
linkSync(s, target) | ||
} | ||
setFolderDialect('.tshy-build/' + d, 'esm') | ||
for (const [override, orig] of pf?.map.entries() ?? []) { | ||
const stemFrom = resolve( | ||
`.tshy-build/${d}`, | ||
relative(resolve('src'), resolve(override)) | ||
).replace(/\.mts$/, '') | ||
const stemTo = resolve( | ||
`.tshy-build/${d}`, | ||
relative(resolve('src'), resolve(orig)) | ||
).replace(/\.tsx?$/, '') | ||
ifExist.unlink(`${stemTo}.js.map`) | ||
ifExist.unlink(`${stemTo}.d.ts.map`) | ||
ifExist.rename(`${stemFrom}.mjs`, `${stemTo}.js`) | ||
ifExist.rename(`${stemFrom}.d.mts`, `${stemTo}.d.ts`) | ||
} | ||
console.error(chalk.cyan.bold('linked ' + d)) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { existsSync, renameSync, unlinkSync } from 'fs' | ||
|
||
const unlink = (f: string) => existsSync(f) && unlinkSync(f) | ||
const rename = (f: string, to: string) => | ||
existsSync(f) && renameSync(f, to) | ||
|
||
export default { | ||
unlink, | ||
rename, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.