🚀 Socket Launch Week Day 5:Introducing Repository Access Permissions and Custom Roles.Learn more
Sign In

tshy

Package Overview
Dependencies
Maintainers
1
Versions
54
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tshy - npm Package Compare versions

Comparing version
4.0.0
to
4.1.0
+1
-1
dist/esm/build-commonjs.d.ts.map

@@ -1,1 +0,1 @@

{"version":3,"file":"build-commonjs.d.ts","sourceRoot":"","sources":["../../src/build-commonjs.ts"],"names":[],"mappings":"AASA,OAAO,eAAe,CAAA;AAMtB,eAAO,MAAM,aAAa,iBAgCzB,CAAA","sourcesContent":["import chalk from 'chalk'\nimport { spawnSync } from 'node:child_process'\nimport { relative, resolve } from 'node:path/posix'\nimport buildFail from './build-fail.js'\nimport config from './config.js'\nimport * as console from './console.js'\nimport ifExist from './if-exist.js'\nimport polyfills from './polyfills.js'\nimport setFolderDialect from './set-folder-dialect.js'\nimport './tsconfig.js'\nimport tsc from './which-tsc.js'\n\nconst node = process.execPath\nconst { commonjsDialects = [] } = config\n\nexport const buildCommonJS = () => {\n setFolderDialect('src', 'commonjs')\n for (const d of ['commonjs', ...commonjsDialects]) {\n const pf = polyfills.get(d === 'commonjs' ? 'cjs' : d)\n console.debug(chalk.cyan.dim('building ' + d))\n const res = spawnSync(node, [tsc, '-p', `.tshy/${d}.json`], {\n stdio: 'inherit',\n })\n if (res.status || res.signal) {\n setFolderDialect('src')\n return buildFail(res)\n }\n setFolderDialect('.tshy-build/' + d, 'commonjs')\n for (const [override, orig] of pf?.map.entries() ?? []) {\n const stemFrom = resolve(\n `.tshy-build/${d}`,\n relative(resolve('src'), resolve(override)),\n ).replace(/\\.cts$/, '')\n const stemTo = resolve(\n `.tshy-build/${d}`,\n relative(resolve('src'), resolve(orig)),\n ).replace(/\\.tsx?$/, '')\n const stemToPath = `${stemTo}.js.map`\n const stemToDtsPath = `${stemTo}.d.ts.map`\n ifExist.unlink(stemToPath)\n ifExist.unlink(stemToDtsPath)\n ifExist.rename(`${stemFrom}.cjs`, `${stemTo}.js`)\n ifExist.rename(`${stemFrom}.d.cts`, `${stemTo}.d.ts`)\n }\n console.error(chalk.cyan.bold('built commonjs'))\n }\n setFolderDialect('src')\n}\n"]}
{"version":3,"file":"build-commonjs.d.ts","sourceRoot":"","sources":["../../src/build-commonjs.ts"],"names":[],"mappings":"AASA,OAAO,eAAe,CAAA;AAOtB,eAAO,MAAM,aAAa,iBA0CzB,CAAA","sourcesContent":["import chalk from 'chalk'\nimport { spawnSync } from 'node:child_process'\nimport { relative, resolve } from 'node:path/posix'\nimport buildFail from './build-fail.js'\nimport config from './config.js'\nimport * as console from './console.js'\nimport ifExist from './if-exist.js'\nimport polyfills from './polyfills.js'\nimport setFolderDialect from './set-folder-dialect.js'\nimport './tsconfig.js'\nimport tsc from './which-tsc.js'\nimport { mkdirSync } from 'node:fs'\n\nconst node = process.execPath\nconst { commonjsDialects = [] } = config\n\nexport const buildCommonJS = () => {\n setFolderDialect('src', 'commonjs')\n for (const d of ['commonjs', ...commonjsDialects]) {\n const pfn = d === 'commonjs' ? 'cjs' : `commonjs-${d}`\n const pf = polyfills.get(pfn)\n const cfg = d === 'commonjs' ? 'commonjs' : `commonjs-${d}`\n console.debug(chalk.cyan.dim('building ' + cfg), [\n node,\n [tsc, '-p', `.tshy/${cfg}.json`],\n {\n stdio: 'inherit',\n },\n ])\n const res = spawnSync(node, [tsc, '-p', `.tshy/${cfg}.json`], {\n stdio: 'inherit',\n })\n if (res.status || res.signal) {\n setFolderDialect('src')\n return buildFail(res)\n }\n const dist = d === 'commonjs' ? d : `commonjs/${d}`\n mkdirSync(`.tshy-build/${dist}`, { recursive: true })\n for (const [override, orig] of pf?.map.entries() ?? []) {\n const stemFrom = resolve(\n `.tshy-build/${dist}`,\n relative(resolve('src'), resolve(override)),\n ).replace(/\\.cts$/, '')\n const stemTo = resolve(\n `.tshy-build/${dist}`,\n relative(resolve('src'), resolve(orig)),\n ).replace(/\\.tsx?$/, '')\n const stemToPath = `${stemTo}.js.map`\n const stemToDtsPath = `${stemTo}.d.ts.map`\n ifExist.unlink(stemToPath)\n ifExist.unlink(stemToDtsPath)\n ifExist.rename(`${stemFrom}.cjs`, `${stemTo}.js`)\n ifExist.rename(`${stemFrom}.d.cts`, `${stemTo}.d.ts`)\n }\n setFolderDialect('.tshy-build/commonjs', 'commonjs')\n console.error(chalk.cyan.bold('built ' + dist))\n }\n setFolderDialect('src')\n}\n"]}

@@ -12,2 +12,3 @@ import chalk from 'chalk';

import tsc from './which-tsc.js';
import { mkdirSync } from 'node:fs';
const node = process.execPath;

@@ -18,5 +19,13 @@ const { commonjsDialects = [] } = config;

for (const d of ['commonjs', ...commonjsDialects]) {
const pf = polyfills.get(d === 'commonjs' ? 'cjs' : d);
console.debug(chalk.cyan.dim('building ' + d));
const res = spawnSync(node, [tsc, '-p', `.tshy/${d}.json`], {
const pfn = d === 'commonjs' ? 'cjs' : `commonjs-${d}`;
const pf = polyfills.get(pfn);
const cfg = d === 'commonjs' ? 'commonjs' : `commonjs-${d}`;
console.debug(chalk.cyan.dim('building ' + cfg), [
node,
[tsc, '-p', `.tshy/${cfg}.json`],
{
stdio: 'inherit',
},
]);
const res = spawnSync(node, [tsc, '-p', `.tshy/${cfg}.json`], {
stdio: 'inherit',

@@ -28,6 +37,7 @@ });

}
setFolderDialect('.tshy-build/' + d, 'commonjs');
const dist = d === 'commonjs' ? d : `commonjs/${d}`;
mkdirSync(`.tshy-build/${dist}`, { recursive: true });
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?$/, '');
const stemFrom = resolve(`.tshy-build/${dist}`, relative(resolve('src'), resolve(override))).replace(/\.cts$/, '');
const stemTo = resolve(`.tshy-build/${dist}`, relative(resolve('src'), resolve(orig))).replace(/\.tsx?$/, '');
const stemToPath = `${stemTo}.js.map`;

@@ -40,3 +50,4 @@ const stemToDtsPath = `${stemTo}.d.ts.map`;

}
console.error(chalk.cyan.bold('built commonjs'));
setFolderDialect('.tshy-build/commonjs', 'commonjs');
console.error(chalk.cyan.bold('built ' + dist));
}

@@ -43,0 +54,0 @@ setFolderDialect('src');

@@ -1,1 +0,1 @@

{"version":3,"file":"build-commonjs.js","sourceRoot":"","sources":["../../src/build-commonjs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AAC9C,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAA;AACnD,OAAO,SAAS,MAAM,iBAAiB,CAAA;AACvC,OAAO,MAAM,MAAM,aAAa,CAAA;AAChC,OAAO,KAAK,OAAO,MAAM,cAAc,CAAA;AACvC,OAAO,OAAO,MAAM,eAAe,CAAA;AACnC,OAAO,SAAS,MAAM,gBAAgB,CAAA;AACtC,OAAO,gBAAgB,MAAM,yBAAyB,CAAA;AACtD,OAAO,eAAe,CAAA;AACtB,OAAO,GAAG,MAAM,gBAAgB,CAAA;AAEhC,MAAM,IAAI,GAAG,OAAO,CAAC,QAAQ,CAAA;AAC7B,MAAM,EAAE,gBAAgB,GAAG,EAAE,EAAE,GAAG,MAAM,CAAA;AAExC,MAAM,CAAC,MAAM,aAAa,GAAG,GAAG,EAAE,CAAC;IACjC,gBAAgB,CAAC,KAAK,EAAE,UAAU,CAAC,CAAA;IACnC,KAAK,MAAM,CAAC,IAAI,CAAC,UAAU,EAAE,GAAG,gBAAgB,CAAC,EAAE,CAAC;QAClD,MAAM,EAAE,GAAG,SAAS,CAAC,GAAG,CAAC,CAAC,KAAK,UAAU,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;QACtD,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,WAAW,GA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E,GAAG,MAAM,OAAO,CAAC,CAAA;QACvD,CAAC;QACD,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC,CAAA;IAClD,CAAC;IACD,gBAAgB,CAAC,KAAK,CAAC,CAAA;AAAA,CACxB,CAAA","sourcesContent":["import chalk from 'chalk'\nimport { spawnSync } from 'node:child_process'\nimport { relative, resolve } from 'node:path/posix'\nimport buildFail from './build-fail.js'\nimport config from './config.js'\nimport * as console from './console.js'\nimport ifExist from './if-exist.js'\nimport polyfills from './polyfills.js'\nimport setFolderDialect from './set-folder-dialect.js'\nimport './tsconfig.js'\nimport tsc from './which-tsc.js'\n\nconst node = process.execPath\nconst { commonjsDialects = [] } = config\n\nexport const buildCommonJS = () => {\n setFolderDialect('src', 'commonjs')\n for (const d of ['commonjs', ...commonjsDialects]) {\n const pf = polyfills.get(d === 'commonjs' ? 'cjs' : d)\n console.debug(chalk.cyan.dim('building ' + d))\n const res = spawnSync(node, [tsc, '-p', `.tshy/${d}.json`], {\n stdio: 'inherit',\n })\n if (res.status || res.signal) {\n setFolderDialect('src')\n return buildFail(res)\n }\n setFolderDialect('.tshy-build/' + d, 'commonjs')\n for (const [override, orig] of pf?.map.entries() ?? []) {\n const stemFrom = resolve(\n `.tshy-build/${d}`,\n relative(resolve('src'), resolve(override)),\n ).replace(/\\.cts$/, '')\n const stemTo = resolve(\n `.tshy-build/${d}`,\n relative(resolve('src'), resolve(orig)),\n ).replace(/\\.tsx?$/, '')\n const stemToPath = `${stemTo}.js.map`\n const stemToDtsPath = `${stemTo}.d.ts.map`\n ifExist.unlink(stemToPath)\n ifExist.unlink(stemToDtsPath)\n ifExist.rename(`${stemFrom}.cjs`, `${stemTo}.js`)\n ifExist.rename(`${stemFrom}.d.cts`, `${stemTo}.d.ts`)\n }\n console.error(chalk.cyan.bold('built commonjs'))\n }\n setFolderDialect('src')\n}\n"]}
{"version":3,"file":"build-commonjs.js","sourceRoot":"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AAU,CAAC,CAAA;YAC1B,OAAO,CAAC,MAAM,CAAC,aAAa,CAAC,CAAA;YAC7B,OAAO,CAAC,MAAM,CAAC,GAAG,QAAQ,MAAM,EAAE,GAAG,MAAM,KAAK,CAAC,CAAA;YACjD,OAAO,CAAC,MAAM,CAAC,GAAG,QAAQ,QAAQ,EAAE,GAAG,MAAM,OAAO,CAAC,CAAA;QACvD,CAAC;QACD,gBAAgB,CAAC,sBAAsB,EAAE,UAAU,CAAC,CAAA;QACpD,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,CAAC,CAAA;IACjD,CAAC;IACD,gBAAgB,CAAC,KAAK,CAAC,CAAA;AAAA,CACxB,CAAA","sourcesContent":["import chalk from 'chalk'\nimport { spawnSync } from 'node:child_process'\nimport { relative, resolve } from 'node:path/posix'\nimport buildFail from './build-fail.js'\nimport config from './config.js'\nimport * as console from './console.js'\nimport ifExist from './if-exist.js'\nimport polyfills from './polyfills.js'\nimport setFolderDialect from './set-folder-dialect.js'\nimport './tsconfig.js'\nimport tsc from './which-tsc.js'\nimport { mkdirSync } from 'node:fs'\n\nconst node = process.execPath\nconst { commonjsDialects = [] } = config\n\nexport const buildCommonJS = () => {\n setFolderDialect('src', 'commonjs')\n for (const d of ['commonjs', ...commonjsDialects]) {\n const pfn = d === 'commonjs' ? 'cjs' : `commonjs-${d}`\n const pf = polyfills.get(pfn)\n const cfg = d === 'commonjs' ? 'commonjs' : `commonjs-${d}`\n console.debug(chalk.cyan.dim('building ' + cfg), [\n node,\n [tsc, '-p', `.tshy/${cfg}.json`],\n {\n stdio: 'inherit',\n },\n ])\n const res = spawnSync(node, [tsc, '-p', `.tshy/${cfg}.json`], {\n stdio: 'inherit',\n })\n if (res.status || res.signal) {\n setFolderDialect('src')\n return buildFail(res)\n }\n const dist = d === 'commonjs' ? d : `commonjs/${d}`\n mkdirSync(`.tshy-build/${dist}`, { recursive: true })\n for (const [override, orig] of pf?.map.entries() ?? []) {\n const stemFrom = resolve(\n `.tshy-build/${dist}`,\n relative(resolve('src'), resolve(override)),\n ).replace(/\\.cts$/, '')\n const stemTo = resolve(\n `.tshy-build/${dist}`,\n relative(resolve('src'), resolve(orig)),\n ).replace(/\\.tsx?$/, '')\n const stemToPath = `${stemTo}.js.map`\n const stemToDtsPath = `${stemTo}.d.ts.map`\n ifExist.unlink(stemToPath)\n ifExist.unlink(stemToDtsPath)\n ifExist.rename(`${stemFrom}.cjs`, `${stemTo}.js`)\n ifExist.rename(`${stemFrom}.d.cts`, `${stemTo}.d.ts`)\n }\n setFolderDialect('.tshy-build/commonjs', 'commonjs')\n console.error(chalk.cyan.bold('built ' + dist))\n }\n setFolderDialect('src')\n}\n"]}

@@ -1,1 +0,1 @@

{"version":3,"file":"build-esm.d.ts","sourceRoot":"","sources":["../../src/build-esm.ts"],"names":[],"mappings":"AASA,OAAO,eAAe,CAAA;AAMtB,eAAO,MAAM,QAAQ,iBA8BpB,CAAA","sourcesContent":["import chalk from 'chalk'\nimport { spawnSync } from 'node:child_process'\nimport { relative, resolve } from 'node:path'\nimport buildFail from './build-fail.js'\nimport config from './config.js'\nimport * as console from './console.js'\nimport ifExist from './if-exist.js'\nimport polyfills from './polyfills.js'\nimport setFolderDialect from './set-folder-dialect.js'\nimport './tsconfig.js'\nimport tsc from './which-tsc.js'\n\nconst node = process.execPath\nconst { esmDialects = [] } = config\n\nexport const buildESM = () => {\n setFolderDialect('src', 'esm')\n for (const d of ['esm', ...esmDialects]) {\n const pf = polyfills.get(d)\n console.debug(chalk.cyan.dim('building ' + d))\n const res = spawnSync(node, [tsc, '-p', `.tshy/${d}.json`], {\n stdio: 'inherit',\n })\n if (res.status || res.signal) {\n setFolderDialect('src')\n return buildFail(res)\n }\n setFolderDialect('.tshy-build/' + d, 'esm')\n for (const [override, orig] of pf?.map.entries() ?? []) {\n const stemFrom = resolve(\n `.tshy-build/${d}`,\n relative(resolve('src'), resolve(override)),\n ).replace(/\\.mts$/, '')\n const stemTo = resolve(\n `.tshy-build/${d}`,\n relative(resolve('src'), resolve(orig)),\n ).replace(/\\.tsx?$/, '')\n ifExist.unlink(`${stemTo}.js.map`)\n ifExist.unlink(`${stemTo}.d.ts.map`)\n ifExist.rename(`${stemFrom}.mjs`, `${stemTo}.js`)\n ifExist.rename(`${stemFrom}.d.mts`, `${stemTo}.d.ts`)\n }\n console.error(chalk.cyan.bold('built ' + d))\n }\n setFolderDialect('src')\n}\n"]}
{"version":3,"file":"build-esm.d.ts","sourceRoot":"","sources":["../../src/build-esm.ts"],"names":[],"mappings":"AASA,OAAO,eAAe,CAAA;AAOtB,eAAO,MAAM,QAAQ,iBAiCpB,CAAA","sourcesContent":["import chalk from 'chalk'\nimport { spawnSync } from 'node:child_process'\nimport { relative, resolve } from 'node:path'\nimport buildFail from './build-fail.js'\nimport config from './config.js'\nimport * as console from './console.js'\nimport ifExist from './if-exist.js'\nimport polyfills from './polyfills.js'\nimport setFolderDialect from './set-folder-dialect.js'\nimport './tsconfig.js'\nimport tsc from './which-tsc.js'\nimport { mkdirSync } from 'node:fs'\n\nconst node = process.execPath\nconst { esmDialects = [] } = config\n\nexport const buildESM = () => {\n setFolderDialect('src', 'esm')\n for (const d of ['esm', ...esmDialects]) {\n const pfn = d === 'esm' ? d : `esm-${d}`\n const pf = polyfills.get(pfn)\n console.debug(chalk.cyan.dim('building ' + pfn))\n const res = spawnSync(node, [tsc, '-p', `.tshy/${pfn}.json`], {\n stdio: 'inherit',\n })\n if (res.status || res.signal) {\n setFolderDialect('src')\n return buildFail(res)\n }\n const dist = d === 'esm' ? d : `esm/${d}`\n mkdirSync(`.tshy-build/${dist}`, { recursive: true })\n for (const [override, orig] of pf?.map.entries() ?? []) {\n const stemFrom = resolve(\n `.tshy-build/${dist}`,\n relative(resolve('src'), resolve(override)),\n ).replace(/\\.mts$/, '')\n const stemTo = resolve(\n `.tshy-build/${dist}`,\n relative(resolve('src'), resolve(orig)),\n ).replace(/\\.tsx?$/, '')\n ifExist.unlink(`${stemTo}.js.map`)\n ifExist.unlink(`${stemTo}.d.ts.map`)\n ifExist.rename(`${stemFrom}.mjs`, `${stemTo}.js`)\n ifExist.rename(`${stemFrom}.d.mts`, `${stemTo}.d.ts`)\n }\n setFolderDialect('.tshy-build/esm', 'esm')\n console.error(chalk.cyan.bold('built ' + dist))\n }\n setFolderDialect('src')\n}\n"]}

@@ -12,2 +12,3 @@ import chalk from 'chalk';

import tsc from './which-tsc.js';
import { mkdirSync } from 'node:fs';
const node = process.execPath;

@@ -18,5 +19,6 @@ const { esmDialects = [] } = config;

for (const d of ['esm', ...esmDialects]) {
const pf = polyfills.get(d);
console.debug(chalk.cyan.dim('building ' + d));
const res = spawnSync(node, [tsc, '-p', `.tshy/${d}.json`], {
const pfn = d === 'esm' ? d : `esm-${d}`;
const pf = polyfills.get(pfn);
console.debug(chalk.cyan.dim('building ' + pfn));
const res = spawnSync(node, [tsc, '-p', `.tshy/${pfn}.json`], {
stdio: 'inherit',

@@ -28,6 +30,7 @@ });

}
setFolderDialect('.tshy-build/' + d, 'esm');
const dist = d === 'esm' ? d : `esm/${d}`;
mkdirSync(`.tshy-build/${dist}`, { recursive: true });
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?$/, '');
const stemFrom = resolve(`.tshy-build/${dist}`, relative(resolve('src'), resolve(override))).replace(/\.mts$/, '');
const stemTo = resolve(`.tshy-build/${dist}`, relative(resolve('src'), resolve(orig))).replace(/\.tsx?$/, '');
ifExist.unlink(`${stemTo}.js.map`);

@@ -38,3 +41,4 @@ ifExist.unlink(`${stemTo}.d.ts.map`);

}
console.error(chalk.cyan.bold('built ' + d));
setFolderDialect('.tshy-build/esm', 'esm');
console.error(chalk.cyan.bold('built ' + dist));
}

@@ -41,0 +45,0 @@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C7B,gBAAgB,CAAC,KAAK,CAAC,CAAA;YACvB,OAAO,SAAS,CAAC,GAAG,CAAC,CAAA;QACvB,CAAC;QACD,gBAAgB,CAAC,cAAc,GAAG,CAAC,EAAE,KAAK,CAAC,CAAA;QAC3C,KAAK,MAAM,CAAC,QAAQ,EAAE,IAAI,CAAC,IAAI,EAAE,EAAE,GAAG,CAAC,OAAO,EAAE,IAAI,EAAE,EAAE,CAAC;YACvD,MAAM,QAAQ,GAAG,OAAO,CACtB,eAAe,CAAC,EAAE,EAClB,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC,CAC5C,CAAC,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAA;YACvB,MAAM,MAAM,GAAG,OAAO,CACpB,eAAe,CAAC,EAAE,EAClB,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC,CACxC,CAAC,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC,CAAA;YACxB,OAAO,CAAC,MAAM,CAAC,GAAG,MAAM,SAAS,CAAC,CAAA;YAClC,OAAO,CAAC,MAAM,CAAC,GAAG,MAAM,WAAW,CAAC,CAAA;YACpC,OAAO,CAAC,MAAM,CAAC,GAAG,QAAQ,MAAM,EAAE,GAAG,MAAM,KAAK,CAAC,CAAA;YACjD,OAAO,CAAC,MAAM,CAAC,GAAG,QAAQ,QAAQ,EAAE,GAAG,MAAM,OAAO,CAAC,CAAA;QACvD,CAAC;QACD,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,GAAG,CAAC,CAAC,CAAC,CAAA;IAC9C,CAAC;IACD,gBAAgB,CAAC,KAAK,CAAC,CAAA;AAAA,CACxB,CAAA","sourcesContent":["import chalk from 'chalk'\nimport { spawnSync } from 'node:child_process'\nimport { relative, resolve } from 'node:path'\nimport buildFail from './build-fail.js'\nimport config from './config.js'\nimport * as console from './console.js'\nimport ifExist from './if-exist.js'\nimport polyfills from './polyfills.js'\nimport setFolderDialect from './set-folder-dialect.js'\nimport './tsconfig.js'\nimport tsc from './which-tsc.js'\n\nconst node = process.execPath\nconst { esmDialects = [] } = config\n\nexport const buildESM = () => {\n setFolderDialect('src', 'esm')\n for (const d of ['esm', ...esmDialects]) {\n const pf = polyfills.get(d)\n console.debug(chalk.cyan.dim('building ' + d))\n const res = spawnSync(node, [tsc, '-p', `.tshy/${d}.json`], {\n stdio: 'inherit',\n })\n if (res.status || res.signal) {\n setFolderDialect('src')\n return buildFail(res)\n }\n setFolderDialect('.tshy-build/' + d, 'esm')\n for (const [override, orig] of pf?.map.entries() ?? []) {\n const stemFrom = resolve(\n `.tshy-build/${d}`,\n relative(resolve('src'), resolve(override)),\n ).replace(/\\.mts$/, '')\n const stemTo = resolve(\n `.tshy-build/${d}`,\n relative(resolve('src'), resolve(orig)),\n ).replace(/\\.tsx?$/, '')\n ifExist.unlink(`${stemTo}.js.map`)\n ifExist.unlink(`${stemTo}.d.ts.map`)\n ifExist.rename(`${stemFrom}.mjs`, `${stemTo}.js`)\n ifExist.rename(`${stemFrom}.d.mts`, `${stemTo}.d.ts`)\n }\n console.error(chalk.cyan.bold('built ' + d))\n }\n setFolderDialect('src')\n}\n"]}
{"version":3,"file":"build-esm.js","sourceRoot":"","sources":["../../src/build-esm.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AAC9C,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAC7C,OAAO,SAAS,MAAM,iBAAiB,CAAA;AACvC,OAAO,MAAM,MAAM,aAAa,CAAA;AAChC,OAAO,KAAK,OAAO,MAAM,cAAc,CAAA;AACvC,OAAO,OAAO,MAAM,eAAe,CAAA;AACnC,OAAO,SAAS,MAAM,gBAAgB,CAAA;AACtC,OAAO,gBAAgB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AC,QAAQ,EAAE,IAAI,CAAC,IAAI,EAAE,EAAE,GAAG,CAAC,OAAO,EAAE,IAAI,EAAE,EAAE,CAAC;YACvD,MAAM,QAAQ,GAAG,OAAO,CACtB,eAAe,IAAI,EAAE,EACrB,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC,CAC5C,CAAC,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAA;YACvB,MAAM,MAAM,GAAG,OAAO,CACpB,eAAe,IAAI,EAAE,EACrB,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC,CACxC,CAAC,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC,CAAA;YACxB,OAAO,CAAC,MAAM,CAAC,GAAG,MAAM,SAAS,CAAC,CAAA;YAClC,OAAO,CAAC,MAAM,CAAC,GAAG,MAAM,WAAW,CAAC,CAAA;YACpC,OAAO,CAAC,MAAM,CAAC,GAAG,QAAQ,MAAM,EAAE,GAAG,MAAM,KAAK,CAAC,CAAA;YACjD,OAAO,CAAC,MAAM,CAAC,GAAG,QAAQ,QAAQ,EAAE,GAAG,MAAM,OAAO,CAAC,CAAA;QACvD,CAAC;QACD,gBAAgB,CAAC,iBAAiB,EAAE,KAAK,CAAC,CAAA;QAC1C,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,CAAC,CAAA;IACjD,CAAC;IACD,gBAAgB,CAAC,KAAK,CAAC,CAAA;AAAA,CACxB,CAAA","sourcesContent":["import chalk from 'chalk'\nimport { spawnSync } from 'node:child_process'\nimport { relative, resolve } from 'node:path'\nimport buildFail from './build-fail.js'\nimport config from './config.js'\nimport * as console from './console.js'\nimport ifExist from './if-exist.js'\nimport polyfills from './polyfills.js'\nimport setFolderDialect from './set-folder-dialect.js'\nimport './tsconfig.js'\nimport tsc from './which-tsc.js'\nimport { mkdirSync } from 'node:fs'\n\nconst node = process.execPath\nconst { esmDialects = [] } = config\n\nexport const buildESM = () => {\n setFolderDialect('src', 'esm')\n for (const d of ['esm', ...esmDialects]) {\n const pfn = d === 'esm' ? d : `esm-${d}`\n const pf = polyfills.get(pfn)\n console.debug(chalk.cyan.dim('building ' + pfn))\n const res = spawnSync(node, [tsc, '-p', `.tshy/${pfn}.json`], {\n stdio: 'inherit',\n })\n if (res.status || res.signal) {\n setFolderDialect('src')\n return buildFail(res)\n }\n const dist = d === 'esm' ? d : `esm/${d}`\n mkdirSync(`.tshy-build/${dist}`, { recursive: true })\n for (const [override, orig] of pf?.map.entries() ?? []) {\n const stemFrom = resolve(\n `.tshy-build/${dist}`,\n relative(resolve('src'), resolve(override)),\n ).replace(/\\.mts$/, '')\n const stemTo = resolve(\n `.tshy-build/${dist}`,\n relative(resolve('src'), resolve(orig)),\n ).replace(/\\.tsx?$/, '')\n ifExist.unlink(`${stemTo}.js.map`)\n ifExist.unlink(`${stemTo}.d.ts.map`)\n ifExist.rename(`${stemFrom}.mjs`, `${stemTo}.js`)\n ifExist.rename(`${stemFrom}.d.mts`, `${stemTo}.d.ts`)\n }\n setFolderDialect('.tshy-build/esm', 'esm')\n console.error(chalk.cyan.bold('built ' + dist))\n }\n setFolderDialect('src')\n}\n"]}

@@ -1,1 +0,1 @@

{"version":3,"file":"build-live-commonjs.d.ts","sourceRoot":"","sources":["../../src/build-live-commonjs.ts"],"names":[],"mappings":"AAUA,OAAO,eAAe,CAAA;AAKtB,eAAO,MAAM,iBAAiB,YA2B7B,CAAA","sourcesContent":["import chalk from 'chalk'\nimport { linkSync, mkdirSync } from 'node:fs'\nimport { dirname } from 'node:path'\nimport { relative, resolve } from 'node:path/posix'\nimport config from './config.js'\nimport * as console from './console.js'\nimport ifExist from './if-exist.js'\nimport polyfills from './polyfills.js'\nimport setFolderDialect from './set-folder-dialect.js'\nimport sources from './sources.js'\nimport './tsconfig.js'\n\nconst { commonjsDialects = [] } = config\n\n// don't actually do a build, just link files into places.\nexport const buildLiveCommonJS = () => {\n for (const d of ['commonjs', ...commonjsDialects]) {\n const pf = polyfills.get(d === 'commonjs' ? 'cjs' : d)\n console.debug(chalk.cyan.dim('linking ' + d))\n for (const s of sources) {\n const source = s.substring('./src/'.length)\n const target = resolve(`.tshy-build/${d}/${source}`)\n mkdirSync(dirname(target), { recursive: true })\n linkSync(s, target)\n }\n setFolderDialect('.tshy-build/' + d, 'commonjs')\n for (const [override, orig] of pf?.map.entries() ?? []) {\n const stemFrom = resolve(\n `.tshy-build/${d}`,\n relative(resolve('src'), resolve(override)),\n ).replace(/\\.cts$/, '')\n const stemTo = resolve(\n `.tshy-build/${d}`,\n relative(resolve('src'), resolve(orig)),\n ).replace(/\\.tsx?$/, '')\n ifExist.unlink(`${stemTo}.js.map`)\n ifExist.unlink(`${stemTo}.d.ts.map`)\n ifExist.rename(`${stemFrom}.cjs`, `${stemTo}.js`)\n ifExist.rename(`${stemFrom}.d.cts`, `${stemTo}.d.ts`)\n }\n console.error(chalk.cyan.bold('linked commonjs'))\n }\n}\n"]}
{"version":3,"file":"build-live-commonjs.d.ts","sourceRoot":"","sources":["../../src/build-live-commonjs.ts"],"names":[],"mappings":"AAUA,OAAO,eAAe,CAAA;AAKtB,eAAO,MAAM,iBAAiB,YA6B7B,CAAA","sourcesContent":["import chalk from 'chalk'\nimport { linkSync, mkdirSync } from 'node:fs'\nimport { dirname } from 'node:path'\nimport { relative, resolve } from 'node:path/posix'\nimport config from './config.js'\nimport * as console from './console.js'\nimport ifExist from './if-exist.js'\nimport polyfills from './polyfills.js'\nimport setFolderDialect from './set-folder-dialect.js'\nimport sources from './sources.js'\nimport './tsconfig.js'\n\nconst { commonjsDialects = [] } = config\n\n// don't actually do a build, just link files into places.\nexport const buildLiveCommonJS = () => {\n for (const d of ['commonjs', ...commonjsDialects]) {\n const pfn = d === 'commonjs' ? 'cjs' : `commonjs-${d}`\n const dist = d === 'commonjs' ? 'commonjs' : `commonjs/${d}`\n const pf = polyfills.get(pfn)\n console.debug(chalk.cyan.dim('linking ' + dist))\n for (const s of sources) {\n const source = s.substring('./src/'.length)\n const target = resolve(`.tshy-build/${dist}/${source}`)\n mkdirSync(dirname(target), { recursive: true })\n linkSync(s, target)\n }\n for (const [override, orig] of pf?.map.entries() ?? []) {\n const stemFrom = resolve(\n `.tshy-build/${dist}`,\n relative(resolve('src'), resolve(override)),\n ).replace(/\\.cts$/, '')\n const stemTo = resolve(\n `.tshy-build/${dist}`,\n relative(resolve('src'), resolve(orig)),\n ).replace(/\\.tsx?$/, '')\n ifExist.unlink(`${stemTo}.js.map`)\n ifExist.unlink(`${stemTo}.d.ts.map`)\n ifExist.rename(`${stemFrom}.cjs`, `${stemTo}.js`)\n ifExist.rename(`${stemFrom}.d.cts`, `${stemTo}.d.ts`)\n }\n console.error(chalk.cyan.bold('linked commonjs'))\n }\n setFolderDialect('.tshy-build/commonjs', 'commonjs')\n}\n"]}

@@ -16,14 +16,15 @@ import chalk from 'chalk';

for (const d of ['commonjs', ...commonjsDialects]) {
const pf = polyfills.get(d === 'commonjs' ? 'cjs' : d);
console.debug(chalk.cyan.dim('linking ' + d));
const pfn = d === 'commonjs' ? 'cjs' : `commonjs-${d}`;
const dist = d === 'commonjs' ? 'commonjs' : `commonjs/${d}`;
const pf = polyfills.get(pfn);
console.debug(chalk.cyan.dim('linking ' + dist));
for (const s of sources) {
const source = s.substring('./src/'.length);
const target = resolve(`.tshy-build/${d}/${source}`);
const target = resolve(`.tshy-build/${dist}/${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?$/, '');
const stemFrom = resolve(`.tshy-build/${dist}`, relative(resolve('src'), resolve(override))).replace(/\.cts$/, '');
const stemTo = resolve(`.tshy-build/${dist}`, relative(resolve('src'), resolve(orig))).replace(/\.tsx?$/, '');
ifExist.unlink(`${stemTo}.js.map`);

@@ -36,3 +37,4 @@ ifExist.unlink(`${stemTo}.d.ts.map`);

}
setFolderDialect('.tshy-build/commonjs', 'commonjs');
};
//# sourceMappingURL=build-live-commonjs.js.map

@@ -1,1 +0,1 @@

{"version":3,"file":"build-live-commonjs.js","sourceRoot":"","sources":["../../src/build-live-commonjs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AAC7C,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAA;AACnD,OAAO,MAAM,MAAM,aAAa,CAAA;AAChC,OAAO,KAAK,OAAO,MAAM,cAAc,CAAA;AACvC,OAAO,OAAO,MAAM,eAAe,CAAA;AACnC,OAAO,SAAS,MAAM,gBAAgB,CAAA;AACtC,OAAO,gBAAgB,MAAM,yBAAyB,CAAA;AACtD,OAAO,OAAO,MAAM,cAAc,CAAA;AAClC,OAAO,eAAe,CAAA;AAEtB,MAAM,EAAE,gBAAgB,GAAG,EAAE,EAAE,GAAG,MAAM,CAAA;AAExC,0DAA0D;AAC1D,MAAM,CAAC,MAAM,iBAAiB,GAAG,GAAG,EAAE,CAAC;IACrC,KAAK,MAAM,CAAC,IAAI,CAAC,UAAU,EAAE,GAAG,gBAAgB,CAAC,EAAE,CAAC;QAClD,MAAM,EAAE,GAAG,SAAS,CAAC,GAAG,CAAC,CAAC,KAAK,UAAU,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;QACtD,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,UAAU,GAAG,CAAC,CAAC,C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;QACD,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC,CAAA;IACnD,CAAC;AAAA,CACF,CAAA","sourcesContent":["import chalk from 'chalk'\nimport { linkSync, mkdirSync } from 'node:fs'\nimport { dirname } from 'node:path'\nimport { relative, resolve } from 'node:path/posix'\nimport config from './config.js'\nimport * as console from './console.js'\nimport ifExist from './if-exist.js'\nimport polyfills from './polyfills.js'\nimport setFolderDialect from './set-folder-dialect.js'\nimport sources from './sources.js'\nimport './tsconfig.js'\n\nconst { commonjsDialects = [] } = config\n\n// don't actually do a build, just link files into places.\nexport const buildLiveCommonJS = () => {\n for (const d of ['commonjs', ...commonjsDialects]) {\n const pf = polyfills.get(d === 'commonjs' ? 'cjs' : d)\n console.debug(chalk.cyan.dim('linking ' + d))\n for (const s of sources) {\n const source = s.substring('./src/'.length)\n const target = resolve(`.tshy-build/${d}/${source}`)\n mkdirSync(dirname(target), { recursive: true })\n linkSync(s, target)\n }\n setFolderDialect('.tshy-build/' + d, 'commonjs')\n for (const [override, orig] of pf?.map.entries() ?? []) {\n const stemFrom = resolve(\n `.tshy-build/${d}`,\n relative(resolve('src'), resolve(override)),\n ).replace(/\\.cts$/, '')\n const stemTo = resolve(\n `.tshy-build/${d}`,\n relative(resolve('src'), resolve(orig)),\n ).replace(/\\.tsx?$/, '')\n ifExist.unlink(`${stemTo}.js.map`)\n ifExist.unlink(`${stemTo}.d.ts.map`)\n ifExist.rename(`${stemFrom}.cjs`, `${stemTo}.js`)\n ifExist.rename(`${stemFrom}.d.cts`, `${stemTo}.d.ts`)\n }\n console.error(chalk.cyan.bold('linked commonjs'))\n }\n}\n"]}
{"version":3,"file":"build-live-commonjs.js","sourceRoot":"","sources":["../../src/build-live-commonjs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AAC7C,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AAE,IAAI,EAAE,CAAC,CAAA;YAC/C,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC,CAAA;QACrB,CAAC;QACD,KAAK,MAAM,CAAC,QAAQ,EAAE,IAAI,CAAC,IAAI,EAAE,EAAE,GAAG,CAAC,OAAO,EAAE,IAAI,EAAE,EAAE,CAAC;YACvD,MAAM,QAAQ,GAAG,OAAO,CACtB,eAAe,IAAI,EAAE,EACrB,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC,CAC5C,CAAC,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAA;YACvB,MAAM,MAAM,GAAG,OAAO,CACpB,eAAe,IAAI,EAAE,EACrB,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC,CACxC,CAAC,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC,CAAA;YACxB,OAAO,CAAC,MAAM,CAAC,GAAG,MAAM,SAAS,CAAC,CAAA;YAClC,OAAO,CAAC,MAAM,CAAC,GAAG,MAAM,WAAW,CAAC,CAAA;YACpC,OAAO,CAAC,MAAM,CAAC,GAAG,QAAQ,MAAM,EAAE,GAAG,MAAM,KAAK,CAAC,CAAA;YACjD,OAAO,CAAC,MAAM,CAAC,GAAG,QAAQ,QAAQ,EAAE,GAAG,MAAM,OAAO,CAAC,CAAA;QACvD,CAAC;QACD,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC,CAAA;IACnD,CAAC;IACD,gBAAgB,CAAC,sBAAsB,EAAE,UAAU,CAAC,CAAA;AAAA,CACrD,CAAA","sourcesContent":["import chalk from 'chalk'\nimport { linkSync, mkdirSync } from 'node:fs'\nimport { dirname } from 'node:path'\nimport { relative, resolve } from 'node:path/posix'\nimport config from './config.js'\nimport * as console from './console.js'\nimport ifExist from './if-exist.js'\nimport polyfills from './polyfills.js'\nimport setFolderDialect from './set-folder-dialect.js'\nimport sources from './sources.js'\nimport './tsconfig.js'\n\nconst { commonjsDialects = [] } = config\n\n// don't actually do a build, just link files into places.\nexport const buildLiveCommonJS = () => {\n for (const d of ['commonjs', ...commonjsDialects]) {\n const pfn = d === 'commonjs' ? 'cjs' : `commonjs-${d}`\n const dist = d === 'commonjs' ? 'commonjs' : `commonjs/${d}`\n const pf = polyfills.get(pfn)\n console.debug(chalk.cyan.dim('linking ' + dist))\n for (const s of sources) {\n const source = s.substring('./src/'.length)\n const target = resolve(`.tshy-build/${dist}/${source}`)\n mkdirSync(dirname(target), { recursive: true })\n linkSync(s, target)\n }\n for (const [override, orig] of pf?.map.entries() ?? []) {\n const stemFrom = resolve(\n `.tshy-build/${dist}`,\n relative(resolve('src'), resolve(override)),\n ).replace(/\\.cts$/, '')\n const stemTo = resolve(\n `.tshy-build/${dist}`,\n relative(resolve('src'), resolve(orig)),\n ).replace(/\\.tsx?$/, '')\n ifExist.unlink(`${stemTo}.js.map`)\n ifExist.unlink(`${stemTo}.d.ts.map`)\n ifExist.rename(`${stemFrom}.cjs`, `${stemTo}.js`)\n ifExist.rename(`${stemFrom}.d.cts`, `${stemTo}.d.ts`)\n }\n console.error(chalk.cyan.bold('linked commonjs'))\n }\n setFolderDialect('.tshy-build/commonjs', 'commonjs')\n}\n"]}

@@ -1,1 +0,1 @@

{"version":3,"file":"build-live-esm.d.ts","sourceRoot":"","sources":["../../src/build-live-esm.ts"],"names":[],"mappings":"AASA,OAAO,eAAe,CAAA;AAItB,eAAO,MAAM,YAAY,YA2BxB,CAAA","sourcesContent":["import chalk from 'chalk'\nimport { linkSync, mkdirSync } from 'node:fs'\nimport { dirname, relative, resolve } from 'node:path'\nimport config from './config.js'\nimport * as console from './console.js'\nimport ifExist from './if-exist.js'\nimport polyfills from './polyfills.js'\nimport setFolderDialect from './set-folder-dialect.js'\nimport sources from './sources.js'\nimport './tsconfig.js'\n\nconst { esmDialects = [] } = config\n\nexport const buildLiveESM = () => {\n for (const d of ['esm', ...esmDialects]) {\n const pf = polyfills.get(d)\n console.debug(chalk.cyan.dim('linking ' + d))\n for (const s of sources) {\n const source = s.substring('./src/'.length)\n const target = resolve(`.tshy-build/${d}/${source}`)\n mkdirSync(dirname(target), { recursive: true })\n linkSync(s, target)\n }\n setFolderDialect('.tshy-build/' + d, 'esm')\n for (const [override, orig] of pf?.map.entries() ?? []) {\n const stemFrom = resolve(\n `.tshy-build/${d}`,\n relative(resolve('src'), resolve(override)),\n ).replace(/\\.mts$/, '')\n const stemTo = resolve(\n `.tshy-build/${d}`,\n relative(resolve('src'), resolve(orig)),\n ).replace(/\\.tsx?$/, '')\n ifExist.unlink(`${stemTo}.js.map`)\n ifExist.unlink(`${stemTo}.d.ts.map`)\n ifExist.rename(`${stemFrom}.mjs`, `${stemTo}.js`)\n ifExist.rename(`${stemFrom}.d.mts`, `${stemTo}.d.ts`)\n }\n console.error(chalk.cyan.bold('linked ' + d))\n }\n}\n"]}
{"version":3,"file":"build-live-esm.d.ts","sourceRoot":"","sources":["../../src/build-live-esm.ts"],"names":[],"mappings":"AASA,OAAO,eAAe,CAAA;AAItB,eAAO,MAAM,YAAY,YA6BxB,CAAA","sourcesContent":["import chalk from 'chalk'\nimport { linkSync, mkdirSync } from 'node:fs'\nimport { dirname, relative, resolve } from 'node:path'\nimport config from './config.js'\nimport * as console from './console.js'\nimport ifExist from './if-exist.js'\nimport polyfills from './polyfills.js'\nimport setFolderDialect from './set-folder-dialect.js'\nimport sources from './sources.js'\nimport './tsconfig.js'\n\nconst { esmDialects = [] } = config\n\nexport const buildLiveESM = () => {\n for (const d of ['esm', ...esmDialects]) {\n const pfn = d === 'esm' ? 'esm' : `esm-${d}`\n const dist = d === 'esm' ? 'esm' : `esm/${d}`\n const pf = polyfills.get(pfn)\n console.debug(chalk.cyan.dim('linking ' + dist))\n for (const s of sources) {\n const source = s.substring('./src/'.length)\n const target = resolve(`.tshy-build/${dist}/${source}`)\n mkdirSync(dirname(target), { recursive: true })\n linkSync(s, target)\n }\n for (const [override, orig] of pf?.map.entries() ?? []) {\n const stemFrom = resolve(\n `.tshy-build/${dist}`,\n relative(resolve('src'), resolve(override)),\n ).replace(/\\.mts$/, '')\n const stemTo = resolve(\n `.tshy-build/${dist}`,\n relative(resolve('src'), resolve(orig)),\n ).replace(/\\.tsx?$/, '')\n ifExist.unlink(`${stemTo}.js.map`)\n ifExist.unlink(`${stemTo}.d.ts.map`)\n ifExist.rename(`${stemFrom}.mjs`, `${stemTo}.js`)\n ifExist.rename(`${stemFrom}.d.mts`, `${stemTo}.d.ts`)\n }\n console.error(chalk.cyan.bold('linked ' + d))\n }\n setFolderDialect('.tshy-build/esm', 'esm')\n}\n"]}

@@ -14,14 +14,15 @@ import chalk from 'chalk';

for (const d of ['esm', ...esmDialects]) {
const pf = polyfills.get(d);
console.debug(chalk.cyan.dim('linking ' + d));
const pfn = d === 'esm' ? 'esm' : `esm-${d}`;
const dist = d === 'esm' ? 'esm' : `esm/${d}`;
const pf = polyfills.get(pfn);
console.debug(chalk.cyan.dim('linking ' + dist));
for (const s of sources) {
const source = s.substring('./src/'.length);
const target = resolve(`.tshy-build/${d}/${source}`);
const target = resolve(`.tshy-build/${dist}/${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?$/, '');
const stemFrom = resolve(`.tshy-build/${dist}`, relative(resolve('src'), resolve(override))).replace(/\.mts$/, '');
const stemTo = resolve(`.tshy-build/${dist}`, relative(resolve('src'), resolve(orig))).replace(/\.tsx?$/, '');
ifExist.unlink(`${stemTo}.js.map`);

@@ -34,3 +35,4 @@ ifExist.unlink(`${stemTo}.d.ts.map`);

}
setFolderDialect('.tshy-build/esm', 'esm');
};
//# sourceMappingURL=build-live-esm.js.map

@@ -1,1 +0,1 @@

{"version":3,"file":"build-live-esm.js","sourceRoot":"","sources":["../../src/build-live-esm.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AAC7C,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACtD,OAAO,MAAM,MAAM,aAAa,CAAA;AAChC,OAAO,KAAK,OAAO,MAAM,cAAc,CAAA;AACvC,OAAO,OAAO,MAAM,eAAe,CAAA;AACnC,OAAO,SAAS,MAAM,gBAAgB,CAAA;AACtC,OAAO,gBAAgB,MAAM,yBAAyB,CAAA;AACtD,OAAO,OAAO,MAAM,cAAc,CAAA;AAClC,OAAO,eAAe,CAAA;AAEtB,MAAM,EAAE,WAAW,GAAG,EAAE,EAAE,GAAG,MAAM,CAAA;AAEnC,MAAM,CAAC,MAAM,YAAY,GAAG,GAAG,EAAE,CAAC;IAChC,KAAK,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,GAAG,WAAW,CAAC,EAAE,CAAC;QACxC,MAAM,EAAE,GAAG,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,CAAA;QAC3B,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,UAAU,GAAG,CAAC,CAAC,CAAC,CAAA;QAC7C,KAAK,MAAM,CAAC,IAAI,OAAO,EAAE,CAAC;YACxB,MAAM,MAAM,GAAG,CAAC,CAAC,SAAS,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAA;YAC3C,MAAM,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC,IAAI,MAAM,EAAE,CAAC,CAAA;YACpD,SAAS,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAA;YAC/C,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC,CAAA;QACrB,CAAC;QACD,gBAAgB,CAAC,cAAc,GAAG,CAAC,EAAE,KAAK,CAAC,CAAA;QAC3C,KAAK,MAAM,CAAC,QAAQ,EAAE,IAAI,CAAC,IAAI,EAAE,EAAE,GAAG,CAAC,OAAO,EAAE,IAAI,EAAE,EAAE,CAAC;YACvD,MAAM,QAAQ,GAAG,OAAO,CACtB,eAAe,CAAC,EAAE,EAClB,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC,CAC5C,CAAC,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAA;YACvB,MAAM,MAAM,GAAG,OAAO,CACpB,eAAe,CAAC,EAAE,EAClB,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC,CACxC,CAAC,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC,CAAA;YACxB,OAAO,CAAC,MAAM,CAAC,GAAG,MAAM,SAAS,CAAC,CAAA;YAClC,OAAO,CAAC,MAAM,CAAC,GAAG,MAAM,WAAW,CAAC,CAAA;YACpC,OAAO,CAAC,MAAM,CAAC,GAAG,QAAQ,MAAM,EAAE,GAAG,MAAM,KAAK,CAAC,CAAA;YACjD,OAAO,CAAC,MAAM,CAAC,GAAG,QAAQ,QAAQ,EAAE,GAAG,MAAM,OAAO,CAAC,CAAA;QACvD,CAAC;QACD,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,GAAG,CAAC,CAAC,CAAC,CAAA;IAC/C,CAAC;AAAA,CACF,CAAA","sourcesContent":["import chalk from 'chalk'\nimport { linkSync, mkdirSync } from 'node:fs'\nimport { dirname, relative, resolve } from 'node:path'\nimport config from './config.js'\nimport * as console from './console.js'\nimport ifExist from './if-exist.js'\nimport polyfills from './polyfills.js'\nimport setFolderDialect from './set-folder-dialect.js'\nimport sources from './sources.js'\nimport './tsconfig.js'\n\nconst { esmDialects = [] } = config\n\nexport const buildLiveESM = () => {\n for (const d of ['esm', ...esmDialects]) {\n const pf = polyfills.get(d)\n console.debug(chalk.cyan.dim('linking ' + d))\n for (const s of sources) {\n const source = s.substring('./src/'.length)\n const target = resolve(`.tshy-build/${d}/${source}`)\n mkdirSync(dirname(target), { recursive: true })\n linkSync(s, target)\n }\n setFolderDialect('.tshy-build/' + d, 'esm')\n for (const [override, orig] of pf?.map.entries() ?? []) {\n const stemFrom = resolve(\n `.tshy-build/${d}`,\n relative(resolve('src'), resolve(override)),\n ).replace(/\\.mts$/, '')\n const stemTo = resolve(\n `.tshy-build/${d}`,\n relative(resolve('src'), resolve(orig)),\n ).replace(/\\.tsx?$/, '')\n ifExist.unlink(`${stemTo}.js.map`)\n ifExist.unlink(`${stemTo}.d.ts.map`)\n ifExist.rename(`${stemFrom}.mjs`, `${stemTo}.js`)\n ifExist.rename(`${stemFrom}.d.mts`, `${stemTo}.d.ts`)\n }\n console.error(chalk.cyan.bold('linked ' + d))\n }\n}\n"]}
{"version":3,"file":"build-live-esm.js","sourceRoot":"","sources":["../../src/build-live-esm.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AAC7C,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACtD,OAAO,MAAM,MAAM,aAAa,CAAA;AAChC,OAAO,KAAK,OAAO,MAAM,cAAc,CAAA;AACvC,OAAO,OAAO,MAAM,eAAe,CAAA;AACnC,OAAO,SAAS,MAAM,gBAAgB,CAAA;AACtC,OAAO,gBAAgB,MAAM,yBAAyB,CAAA;AACtD,OAAO,OAAO,MAAM,cAAc,CAAA;AAClC,OAAO,eAAe,CAAA;AAEtB,MAAM,EAAE,WAAW,GAAG,EAAE,EAAE,GAAG,MAAM,CAAA;AA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I,EAAE,EACrB,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC,CACxC,CAAC,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC,CAAA;YACxB,OAAO,CAAC,MAAM,CAAC,GAAG,MAAM,SAAS,CAAC,CAAA;YAClC,OAAO,CAAC,MAAM,CAAC,GAAG,MAAM,WAAW,CAAC,CAAA;YACpC,OAAO,CAAC,MAAM,CAAC,GAAG,QAAQ,MAAM,EAAE,GAAG,MAAM,KAAK,CAAC,CAAA;YACjD,OAAO,CAAC,MAAM,CAAC,GAAG,QAAQ,QAAQ,EAAE,GAAG,MAAM,OAAO,CAAC,CAAA;QACvD,CAAC;QACD,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,GAAG,CAAC,CAAC,CAAC,CAAA;IAC/C,CAAC;IACD,gBAAgB,CAAC,iBAAiB,EAAE,KAAK,CAAC,CAAA;AAAA,CAC3C,CAAA","sourcesContent":["import chalk from 'chalk'\nimport { linkSync, mkdirSync } from 'node:fs'\nimport { dirname, relative, resolve } from 'node:path'\nimport config from './config.js'\nimport * as console from './console.js'\nimport ifExist from './if-exist.js'\nimport polyfills from './polyfills.js'\nimport setFolderDialect from './set-folder-dialect.js'\nimport sources from './sources.js'\nimport './tsconfig.js'\n\nconst { esmDialects = [] } = config\n\nexport const buildLiveESM = () => {\n for (const d of ['esm', ...esmDialects]) {\n const pfn = d === 'esm' ? 'esm' : `esm-${d}`\n const dist = d === 'esm' ? 'esm' : `esm/${d}`\n const pf = polyfills.get(pfn)\n console.debug(chalk.cyan.dim('linking ' + dist))\n for (const s of sources) {\n const source = s.substring('./src/'.length)\n const target = resolve(`.tshy-build/${dist}/${source}`)\n mkdirSync(dirname(target), { recursive: true })\n linkSync(s, target)\n }\n for (const [override, orig] of pf?.map.entries() ?? []) {\n const stemFrom = resolve(\n `.tshy-build/${dist}`,\n relative(resolve('src'), resolve(override)),\n ).replace(/\\.mts$/, '')\n const stemTo = resolve(\n `.tshy-build/${dist}`,\n relative(resolve('src'), resolve(orig)),\n ).replace(/\\.tsx?$/, '')\n ifExist.unlink(`${stemTo}.js.map`)\n ifExist.unlink(`${stemTo}.d.ts.map`)\n ifExist.rename(`${stemFrom}.mjs`, `${stemTo}.js`)\n ifExist.rename(`${stemFrom}.d.mts`, `${stemTo}.d.ts`)\n }\n console.error(chalk.cyan.bold('linked ' + d))\n }\n setFolderDialect('.tshy-build/esm', 'esm')\n}\n"]}

@@ -1,1 +0,1 @@

{"version":3,"file":"console.d.ts","sourceRoot":"","sources":["../../src/console.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,KAAK,uBAGjB,CAAA;AACD,eAAO,MAAM,KAAK,uBAGjB,CAAA;AAGD,eAAO,MAAM,GAAG,uBAEf,CAAA;AAED,eAAO,MAAM,KAAK,YAKjB,CAAA","sourcesContent":["// only print the logs if it fails, or if TSHY_VERBOSE is set\n//oxlint-disable no-console\n//oxlint-disable no-explicit-any\n\nlet verbose = parseInt(process.env.TSHY_VERBOSE || '0')\n\nconst errors: unknown[][] = []\nexport const error = (...a: any[]) => {\n if (verbose >= 1) console.error(...a)\n else errors.push(a)\n}\nexport const debug = (...a: any[]) => {\n if (verbose >= 2) console.error(...a)\n else errors.push(a)\n}\n\n// we only print stdout on success anyway\nexport const log = (...a: any[]) => {\n if (verbose >= 1) console.log(...a)\n}\n\nexport const print = () => {\n for (const a of errors) {\n console.error(...a)\n }\n errors.length = 0\n}\n"]}
{"version":3,"file":"console.d.ts","sourceRoot":"","sources":["../../src/console.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,KAAK,uBAGjB,CAAA;AACD,eAAO,MAAM,KAAK,uBAGjB,CAAA;AAGD,eAAO,MAAM,GAAG,uBAEf,CAAA;AAED,eAAO,MAAM,KAAK,YAKjB,CAAA","sourcesContent":["// only print the logs if it fails, or if TSHY_VERBOSE is set\n//oxlint-disable no-console\n//oxlint-disable no-explicit-any\n\nconst verbose = parseInt(process.env.TSHY_VERBOSE || '0')\n\nconst errors: unknown[][] = []\nexport const error = (...a: any[]) => {\n if (verbose >= 1) console.error(...a)\n else errors.push(a)\n}\nexport const debug = (...a: any[]) => {\n if (verbose >= 2) console.error(...a)\n else errors.push(a)\n}\n\n// we only print stdout on success anyway\nexport const log = (...a: any[]) => {\n if (verbose >= 1) console.log(...a)\n}\n\nexport const print = () => {\n for (const a of errors) {\n console.error(...a)\n }\n errors.length = 0\n}\n"]}
// only print the logs if it fails, or if TSHY_VERBOSE is set
//oxlint-disable no-console
//oxlint-disable no-explicit-any
let verbose = parseInt(process.env.TSHY_VERBOSE || '0');
const verbose = parseInt(process.env.TSHY_VERBOSE || '0');
const errors = [];

@@ -6,0 +6,0 @@ export const error = (...a) => {

@@ -1,1 +0,1 @@

{"version":3,"file":"console.js","sourceRoot":"","sources":["../../src/console.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAC7D,2BAA2B;AAC3B,gCAAgC;AAEhC,IAAI,OAAO,GAAG,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,YAAY,IAAI,GAAG,CAAC,CAAA;AAEvD,MAAM,MAAM,GAAgB,EAAE,CAAA;AAC9B,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,GAAG,CAAQ,EAAE,EAAE,CAAC;IACpC,IAAI,OAAO,IAAI,CAAC;QAAE,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAA;;QAChC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;AAAA,CACpB,CAAA;AACD,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,GAAG,CAAQ,EAAE,EAAE,CAAC;IACpC,IAAI,OAAO,IAAI,CAAC;QAAE,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAA;;QAChC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;AAAA,CACpB,CAAA;AAED,yCAAyC;AACzC,MAAM,CAAC,MAAM,GAAG,GAAG,CAAC,GAAG,CAAQ,EAAE,EAAE,CAAC;IAClC,IAAI,OAAO,IAAI,CAAC;QAAE,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAA;AAAA,CACpC,CAAA;AAED,MAAM,CAAC,MAAM,KAAK,GAAG,GAAG,EAAE,CAAC;IACzB,KAAK,MAAM,CAAC,IAAI,MAAM,EAAE,CAAC;QACvB,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAA;IACrB,CAAC;IACD,MAAM,CAAC,MAAM,GAAG,CAAC,CAAA;AAAA,CAClB,CAAA","sourcesContent":["// only print the logs if it fails, or if TSHY_VERBOSE is set\n//oxlint-disable no-console\n//oxlint-disable no-explicit-any\n\nlet verbose = parseInt(process.env.TSHY_VERBOSE || '0')\n\nconst errors: unknown[][] = []\nexport const error = (...a: any[]) => {\n if (verbose >= 1) console.error(...a)\n else errors.push(a)\n}\nexport const debug = (...a: any[]) => {\n if (verbose >= 2) console.error(...a)\n else errors.push(a)\n}\n\n// we only print stdout on success anyway\nexport const log = (...a: any[]) => {\n if (verbose >= 1) console.log(...a)\n}\n\nexport const print = () => {\n for (const a of errors) {\n console.error(...a)\n }\n errors.length = 0\n}\n"]}
{"version":3,"file":"console.js","sourceRoot":"","sources":["../../src/console.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAC7D,2BAA2B;AAC3B,gCAAgC;AAEhC,MAAM,OAAO,GAAG,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,YAAY,IAAI,GAAG,CAAC,CAAA;AAEzD,MAAM,MAAM,GAAgB,EAAE,CAAA;AAC9B,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,GAAG,CAAQ,EAAE,EAAE,CAAC;IACpC,IAAI,OAAO,IAAI,CAAC;QAAE,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAA;;QAChC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;AAAA,CACpB,CAAA;AACD,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,GAAG,CAAQ,EAAE,EAAE,CAAC;IACpC,IAAI,OAAO,IAAI,CAAC;QAAE,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAA;;QAChC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;AAAA,CACpB,CAAA;AAED,yCAAyC;AACzC,MAAM,CAAC,MAAM,GAAG,GAAG,CAAC,GAAG,CAAQ,EAAE,EAAE,CAAC;IAClC,IAAI,OAAO,IAAI,CAAC;QAAE,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAA;AAAA,CACpC,CAAA;AAED,MAAM,CAAC,MAAM,KAAK,GAAG,GAAG,EAAE,CAAC;IACzB,KAAK,MAAM,CAAC,IAAI,MAAM,EAAE,CAAC;QACvB,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAA;IACrB,CAAC;IACD,MAAM,CAAC,MAAM,GAAG,CAAC,CAAA;AAAA,CAClB,CAAA","sourcesContent":["// only print the logs if it fails, or if TSHY_VERBOSE is set\n//oxlint-disable no-console\n//oxlint-disable no-explicit-any\n\nconst verbose = parseInt(process.env.TSHY_VERBOSE || '0')\n\nconst errors: unknown[][] = []\nexport const error = (...a: any[]) => {\n if (verbose >= 1) console.error(...a)\n else errors.push(a)\n}\nexport const debug = (...a: any[]) => {\n if (verbose >= 2) console.error(...a)\n else errors.push(a)\n}\n\n// we only print stdout on success anyway\nexport const log = (...a: any[]) => {\n if (verbose >= 1) console.log(...a)\n}\n\nexport const print = () => {\n for (const a of errors) {\n console.error(...a)\n }\n errors.length = 0\n}\n"]}

@@ -1,1 +0,1 @@

{"version":3,"file":"exports.d.ts","sourceRoot":"","sources":["../../src/exports.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,gBAAgB,EAEhB,eAAe,EAChB,MAAM,gBAAgB,CAAA;AAKvB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAGjD,OAAO,KAAK,EAAE,OAAO,EAAE,UAAU,EAAc,MAAM,YAAY,CAAA;AAuCjE,eAAO,MAAM,YAAY,sGAG8C,CAAA;AAEvE,eAAO,MAAM,YAAY,sGAUtB,CAAA;AAoIH,eAAO,MAAM,OAAO;;eAoCnB,CAAA;;AAKD,wBAA0B","sourcesContent":["import { relative, resolve } from 'node:path/posix'\nimport type {\n ConditionalValue,\n ConditionalValueObject,\n ExportsSubpaths,\n} from 'resolve-import'\nimport config from './config.js'\nimport dialects from './dialects.js'\nimport fail from './fail.js'\nimport pkg from './package.js'\nimport type { PolyfillSet } from './polyfills.js'\nimport polyfills from './polyfills.js'\nimport { resolveExport } from './resolve-export.js'\nimport type { Package, TshyConfig, TshyExport } from './types.js'\nconst { esmDialects = [], commonjsDialects = [] } = config\n\nconst liveDev =\n config.liveDev &&\n process.env.npm_command !== 'publish' &&\n process.env.npm_command !== 'pack'\n\nconst getTargetForDialectCondition = <T extends string>(\n s: string | TshyExport | undefined | null,\n dialect: T,\n condition: T extends 'esm' ? 'import'\n : T extends 'commonjs' ? 'require'\n : T,\n type: T extends 'esm' ? 'esm'\n : T extends 'commonjs' ? 'commonjs'\n : 'esm' | 'commonjs',\n polyfills: Map<string, PolyfillSet> = new Map(),\n): string | undefined | null => {\n if (s === undefined) return undefined\n if (typeof s === 'string') {\n // the excluded filename pattern\n const xts = type === 'commonjs' ? '.mts' : '.cts'\n if (s.endsWith(xts)) return undefined\n const pf = dialect === 'commonjs' ? 'cjs' : dialect\n const rel = relative(\n resolve('./src'),\n resolve(polyfills.get(pf)?.map.get(s) ?? s),\n )\n const target = liveDev ? rel : rel.replace(/\\.([mc]?)tsx?$/, '.$1js')\n return (\n !s || !s.startsWith('./src/') ? s\n : dialects.includes(type) ? `./dist/${dialect}/${target}`\n : undefined\n )\n }\n return resolveExport(s, [condition])\n}\n\nexport const getImpTarget = (\n s: string | TshyExport | undefined | null,\n polyfills: Map<string, PolyfillSet> = new Map(),\n) => getTargetForDialectCondition(s, 'esm', 'import', 'esm', polyfills)\n\nexport const getReqTarget = (\n s: string | TshyExport | undefined | null,\n polyfills: Map<string, PolyfillSet> = new Map(),\n) =>\n getTargetForDialectCondition(\n s,\n 'commonjs',\n 'require',\n 'commonjs',\n polyfills,\n )\n\nconst getExports = (\n c: TshyConfig,\n pkgType: 'commonjs' | 'module',\n): Record<string, ConditionalValue> => {\n // by this time it always exports, will get the default if missing\n /* c8 ignore start */\n if (!c.exports) {\n fail('no exports on tshy config (is there code in ./src?)')\n return process.exit(1)\n }\n /* c8 ignore stop */\n const e: Record<string, ConditionalValue> = {}\n for (const [sub, s] of Object.entries(c.exports)) {\n // external export, not built by us\n if (s !== null && (typeof s !== 'string' || !s.startsWith('./src/'))) {\n // already been validated, just accept as-is\n e[sub] = s as ConditionalValue\n continue\n }\n\n /* c8 ignore next - already guarded */\n if (s === null) continue\n\n const impTarget = getImpTarget(s, polyfills)\n const reqTarget = getReqTarget(s, polyfills)\n\n // should be impossible\n /* c8 ignore start */\n if (!impTarget && !reqTarget) continue\n /* c8 ignore stop */\n\n const exp: ConditionalValueObject = (e[sub] = {})\n if (impTarget) {\n for (const d of esmDialects) {\n const source = s && (polyfills.get(d)?.map.get(s) ?? s)\n\n const target = getTargetForDialectCondition(\n s,\n d,\n d,\n 'esm',\n polyfills,\n )\n if (target) {\n exp[d] =\n liveDev ?\n {\n ...(pkgType === 'commonjs' ?\n getSourceDialects(source, c)\n : {}),\n default: target,\n }\n : {\n ...(pkgType === 'commonjs' ?\n getSourceDialects(source, c)\n : {}),\n types: target.replace(/\\.js$/, '.d.ts'),\n default: target,\n }\n }\n }\n }\n\n if (reqTarget) {\n for (const d of commonjsDialects) {\n const source = s && (polyfills.get(d)?.map.get(s) ?? s)\n const target = getTargetForDialectCondition(\n s,\n d,\n d,\n 'commonjs',\n polyfills,\n )\n if (target) {\n exp[d] =\n liveDev ?\n {\n ...(pkgType === 'module' ?\n getSourceDialects(source, c)\n : {}),\n default: target,\n }\n : {\n ...(pkgType === 'module' ?\n getSourceDialects(source, c)\n : {}),\n types: target.replace(/\\.js$/, '.d.ts'),\n default: target,\n }\n }\n }\n }\n\n // put the default import/require after all the other special ones.\n if (impTarget) {\n exp.import =\n liveDev ?\n {\n ...(pkgType === 'module' ? getSourceDialects(s, c) : {}),\n default: impTarget,\n }\n : {\n ...(pkgType === 'module' ? getSourceDialects(s, c) : {}),\n types: impTarget.replace(/\\.(m?)js$/, '.d.$1ts'),\n default: impTarget,\n }\n }\n if (reqTarget) {\n exp.require =\n liveDev ?\n {\n ...(pkgType === 'commonjs' ? getSourceDialects(s, c) : {}),\n default: reqTarget,\n }\n : {\n ...(pkgType === 'commonjs' ? getSourceDialects(s, c) : {}),\n types: reqTarget.replace(/\\.(c?)js$/, '.d.$1ts'),\n default: reqTarget,\n }\n }\n }\n return e\n}\n\nconst getSourceDialects = (source: string, c: TshyConfig) => {\n const { sourceDialects } = c\n if (!sourceDialects) return {}\n return Object.fromEntries(sourceDialects.map(s => [s, source]))\n}\n\nexport const setMain = (\n c: TshyConfig | undefined,\n pkg: Package & { exports: ExportsSubpaths },\n) => {\n pkg.type = pkg.type === 'commonjs' ? 'commonjs' : 'module'\n const mod = resolveExport(pkg.exports['.'], ['require'])\n const main = c?.main ?? !!mod\n if (main) {\n if (!mod) {\n fail(`could not resolve exports['.'] for tshy.main 'require'`)\n return process.exit(1)\n }\n const types = resolveExport(pkg.exports['.'], ['require', 'types'])\n pkg.main = mod\n if (types && types !== mod) pkg.types = types\n else delete pkg.types\n } else {\n if (c && c.main !== false) delete c.main\n delete pkg.main\n delete pkg.types\n }\n\n // Set the package module to exports[\".\"]\n const importMod = resolveExport(pkg.exports['.'], ['import'])\n const module = c?.module ?? !!importMod\n if (module) {\n if (!importMod) {\n fail(`could not resolve exports['.'] for tshy.module 'import'`)\n return process.exit(1)\n }\n\n pkg.module = importMod\n } else {\n if (c && c.module !== false) delete c.module\n delete pkg.module\n }\n}\n\npkg.exports = getExports(config, pkg.type)\n\nsetMain(config, pkg as Package & { exports: ExportsSubpaths })\nexport default pkg.exports\n"]}
{"version":3,"file":"exports.d.ts","sourceRoot":"","sources":["../../src/exports.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,gBAAgB,EAEhB,eAAe,EAChB,MAAM,gBAAgB,CAAA;AAKvB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAGjD,OAAO,KAAK,EAAE,OAAO,EAAE,UAAU,EAAc,MAAM,YAAY,CAAA;AA2CjE,eAAO,MAAM,YAAY,sGAG8C,CAAA;AAEvE,eAAO,MAAM,YAAY,sGAUtB,CAAA;AAoIH,eAAO,MAAM,OAAO;;eAoCnB,CAAA;;AAKD,wBAA0B","sourcesContent":["import { relative, resolve } from 'node:path/posix'\nimport type {\n ConditionalValue,\n ConditionalValueObject,\n ExportsSubpaths,\n} from 'resolve-import'\nimport config from './config.js'\nimport dialects from './dialects.js'\nimport fail from './fail.js'\nimport pkg from './package.js'\nimport type { PolyfillSet } from './polyfills.js'\nimport polyfills from './polyfills.js'\nimport { resolveExport } from './resolve-export.js'\nimport type { Package, TshyConfig, TshyExport } from './types.js'\nconst { esmDialects = [], commonjsDialects = [] } = config\n\nconst liveDev =\n config.liveDev &&\n process.env.npm_command !== 'publish' &&\n process.env.npm_command !== 'pack'\n\nconst getTargetForDialectCondition = <T extends string>(\n s: string | TshyExport | undefined | null,\n dialect: T,\n condition: T extends 'esm' ? 'import'\n : T extends 'commonjs' ? 'require'\n : T,\n type: T extends 'esm' ? 'esm'\n : T extends 'commonjs' ? 'commonjs'\n : 'esm' | 'commonjs',\n polyfills: Map<string, PolyfillSet> = new Map(),\n): string | undefined | null => {\n if (s === undefined) return undefined\n if (typeof s === 'string') {\n // the excluded filename pattern\n const xts = type === 'commonjs' ? '.mts' : '.cts'\n if (s.endsWith(xts)) return undefined\n const pf = dialect === 'commonjs' ? 'cjs' : dialect\n const rel = relative(\n resolve('./src'),\n resolve(polyfills.get(pf)?.map.get(s) ?? s),\n )\n const target = liveDev ? rel : rel.replace(/\\.([mc]?)tsx?$/, '.$1js')\n const dt =\n dialect === 'commonjs' || dialect === 'esm' ?\n dialect\n : `${type}/${dialect}`\n return (\n !s || !s.startsWith('./src/') ? s\n : dialects.includes(type) ? `./dist/${dt}/${target}`\n : undefined\n )\n }\n return resolveExport(s, [condition])\n}\n\nexport const getImpTarget = (\n s: string | TshyExport | undefined | null,\n polyfills: Map<string, PolyfillSet> = new Map(),\n) => getTargetForDialectCondition(s, 'esm', 'import', 'esm', polyfills)\n\nexport const getReqTarget = (\n s: string | TshyExport | undefined | null,\n polyfills: Map<string, PolyfillSet> = new Map(),\n) =>\n getTargetForDialectCondition(\n s,\n 'commonjs',\n 'require',\n 'commonjs',\n polyfills,\n )\n\nconst getExports = (\n c: TshyConfig,\n pkgType: 'commonjs' | 'module',\n): Record<string, ConditionalValue> => {\n // by this time it always exports, will get the default if missing\n /* c8 ignore start */\n if (!c.exports) {\n fail('no exports on tshy config (is there code in ./src?)')\n return process.exit(1)\n }\n /* c8 ignore stop */\n const e: Record<string, ConditionalValue> = {}\n for (const [sub, s] of Object.entries(c.exports)) {\n // external export, not built by us\n if (s !== null && (typeof s !== 'string' || !s.startsWith('./src/'))) {\n // already been validated, just accept as-is\n e[sub] = s as ConditionalValue\n continue\n }\n\n /* c8 ignore next - already guarded */\n if (s === null) continue\n\n const impTarget = getImpTarget(s, polyfills)\n const reqTarget = getReqTarget(s, polyfills)\n\n // should be impossible\n /* c8 ignore start */\n if (!impTarget && !reqTarget) continue\n /* c8 ignore stop */\n\n const exp: ConditionalValueObject = (e[sub] = {})\n if (impTarget) {\n for (const d of esmDialects) {\n const source = s && (polyfills.get('esm-' + d)?.rmap.get(s) ?? s)\n\n const target = getTargetForDialectCondition(\n s,\n d,\n d,\n 'esm',\n polyfills,\n )\n if (target) {\n const imp = (exp.import ??= {}) as ConditionalValueObject\n const src =\n pkgType === 'module' || source.endsWith('.mts') ?\n getSourceDialects(source, c)\n : undefined\n const types =\n liveDev ? undefined : (\n { types: target.replace(/\\.js$/, '.d.ts') }\n )\n imp[d] = { ...src, ...types, default: target }\n }\n }\n }\n\n if (reqTarget) {\n for (const d of commonjsDialects) {\n const source =\n s && (polyfills.get('commonjs-' + d)?.rmap.get(s) ?? s)\n const target = getTargetForDialectCondition(\n s,\n d,\n d,\n 'commonjs',\n polyfills,\n )\n if (target) {\n const req = (exp.require ??= {}) as ConditionalValueObject\n const src =\n pkgType === 'commonjs' || source.endsWith('.cts') ?\n getSourceDialects(source, c)\n : undefined\n const types =\n liveDev ? undefined : (\n { types: target.replace(/\\.js$/, '.d.ts') }\n )\n req[d] = { ...src, ...types, default: target }\n }\n }\n }\n\n // put the default import/require after all the other special ones.\n if (impTarget) {\n const source = s && (polyfills.get('esm')?.rmap.get(s) ?? s)\n const src =\n pkgType === 'module' || source.endsWith('.mts') ?\n getSourceDialects(source, c)\n : undefined\n const types =\n liveDev ? undefined : (\n { types: impTarget.replace(/\\.(m?)js$/, '.d.$1ts') }\n )\n exp.import = {\n ...(exp.import as ConditionalValueObject),\n ...src,\n ...types,\n default: impTarget,\n }\n }\n if (reqTarget) {\n const source = s && (polyfills.get('cjs')?.rmap.get(s) ?? s)\n const src =\n pkgType === 'commonjs' || source.endsWith('.cts') ?\n getSourceDialects(source, c)\n : undefined\n const types =\n liveDev ? undefined : (\n { types: reqTarget.replace(/\\.(c?)js$/, '.d.$1ts') }\n )\n\n exp.require = {\n ...(exp.require as ConditionalValueObject),\n ...src,\n ...types,\n default: reqTarget,\n }\n }\n }\n return e\n}\n\nconst getSourceDialects = (source: string, c: TshyConfig) => {\n const { sourceDialects } = c\n if (!sourceDialects) return undefined\n return Object.fromEntries(sourceDialects.map(s => [s, source]))\n}\n\nexport const setMain = (\n c: TshyConfig | undefined,\n pkg: Package & { exports: ExportsSubpaths },\n) => {\n pkg.type = pkg.type === 'commonjs' ? 'commonjs' : 'module'\n const mod = resolveExport(pkg.exports['.'], ['require', 'default'])\n const main = c?.main ?? !!mod\n if (main) {\n if (!mod) {\n fail(`could not resolve exports['.'] for tshy.main 'require'`)\n return process.exit(1)\n }\n const types = resolveExport(pkg.exports['.'], ['require', 'types'])\n pkg.main = mod\n if (types && types !== mod) pkg.types = types\n else delete pkg.types\n } else {\n if (c && c.main !== false) delete c.main\n delete pkg.main\n delete pkg.types\n }\n\n // Set the package module to exports[\".\"]\n const importMod = resolveExport(pkg.exports['.'], ['import', 'default'])\n const module = c?.module ?? !!importMod\n if (module) {\n if (!importMod) {\n fail(`could not resolve exports['.'] for tshy.module 'import'`)\n return process.exit(1)\n }\n\n pkg.module = importMod\n } else {\n if (c && c.module !== false) delete c.module\n delete pkg.module\n }\n}\n\npkg.exports = getExports(config, pkg.type)\n\nsetMain(config, pkg as Package & { exports: ExportsSubpaths })\nexport default pkg.exports\n"]}

@@ -23,4 +23,7 @@ import { relative, resolve } from 'node:path/posix';

const target = liveDev ? rel : rel.replace(/\.([mc]?)tsx?$/, '.$1js');
const dt = dialect === 'commonjs' || dialect === 'esm' ?
dialect
: `${type}/${dialect}`;
return (!s || !s.startsWith('./src/') ? s
: dialects.includes(type) ? `./dist/${dialect}/${target}`
: dialects.includes(type) ? `./dist/${dt}/${target}`
: undefined);

@@ -61,20 +64,11 @@ }

for (const d of esmDialects) {
const source = s && (polyfills.get(d)?.map.get(s) ?? s);
const source = s && (polyfills.get('esm-' + d)?.rmap.get(s) ?? s);
const target = getTargetForDialectCondition(s, d, d, 'esm', polyfills);
if (target) {
exp[d] =
liveDev ?
{
...(pkgType === 'commonjs' ?
getSourceDialects(source, c)
: {}),
default: target,
}
: {
...(pkgType === 'commonjs' ?
getSourceDialects(source, c)
: {}),
types: target.replace(/\.js$/, '.d.ts'),
default: target,
};
const imp = (exp.import ??= {});
const src = pkgType === 'module' || source.endsWith('.mts') ?
getSourceDialects(source, c)
: undefined;
const types = liveDev ? undefined : ({ types: target.replace(/\.js$/, '.d.ts') });
imp[d] = { ...src, ...types, default: target };
}

@@ -85,20 +79,11 @@ }

for (const d of commonjsDialects) {
const source = s && (polyfills.get(d)?.map.get(s) ?? s);
const source = s && (polyfills.get('commonjs-' + d)?.rmap.get(s) ?? s);
const target = getTargetForDialectCondition(s, d, d, 'commonjs', polyfills);
if (target) {
exp[d] =
liveDev ?
{
...(pkgType === 'module' ?
getSourceDialects(source, c)
: {}),
default: target,
}
: {
...(pkgType === 'module' ?
getSourceDialects(source, c)
: {}),
types: target.replace(/\.js$/, '.d.ts'),
default: target,
};
const req = (exp.require ??= {});
const src = pkgType === 'commonjs' || source.endsWith('.cts') ?
getSourceDialects(source, c)
: undefined;
const types = liveDev ? undefined : ({ types: target.replace(/\.js$/, '.d.ts') });
req[d] = { ...src, ...types, default: target };
}

@@ -109,26 +94,26 @@ }

if (impTarget) {
exp.import =
liveDev ?
{
...(pkgType === 'module' ? getSourceDialects(s, c) : {}),
default: impTarget,
}
: {
...(pkgType === 'module' ? getSourceDialects(s, c) : {}),
types: impTarget.replace(/\.(m?)js$/, '.d.$1ts'),
default: impTarget,
};
const source = s && (polyfills.get('esm')?.rmap.get(s) ?? s);
const src = pkgType === 'module' || source.endsWith('.mts') ?
getSourceDialects(source, c)
: undefined;
const types = liveDev ? undefined : ({ types: impTarget.replace(/\.(m?)js$/, '.d.$1ts') });
exp.import = {
...exp.import,
...src,
...types,
default: impTarget,
};
}
if (reqTarget) {
exp.require =
liveDev ?
{
...(pkgType === 'commonjs' ? getSourceDialects(s, c) : {}),
default: reqTarget,
}
: {
...(pkgType === 'commonjs' ? getSourceDialects(s, c) : {}),
types: reqTarget.replace(/\.(c?)js$/, '.d.$1ts'),
default: reqTarget,
};
const source = s && (polyfills.get('cjs')?.rmap.get(s) ?? s);
const src = pkgType === 'commonjs' || source.endsWith('.cts') ?
getSourceDialects(source, c)
: undefined;
const types = liveDev ? undefined : ({ types: reqTarget.replace(/\.(c?)js$/, '.d.$1ts') });
exp.require = {
...exp.require,
...src,
...types,
default: reqTarget,
};
}

@@ -141,3 +126,3 @@ }

if (!sourceDialects)
return {};
return undefined;
return Object.fromEntries(sourceDialects.map(s => [s, source]));

@@ -147,3 +132,3 @@ };

pkg.type = pkg.type === 'commonjs' ? 'commonjs' : 'module';
const mod = resolveExport(pkg.exports['.'], ['require']);
const mod = resolveExport(pkg.exports['.'], ['require', 'default']);
const main = c?.main ?? !!mod;

@@ -169,3 +154,3 @@ if (main) {

// Set the package module to exports["."]
const importMod = resolveExport(pkg.exports['.'], ['import']);
const importMod = resolveExport(pkg.exports['.'], ['import', 'default']);
const module = c?.module ?? !!importMod;

@@ -172,0 +157,0 @@ if (module) {

@@ -1,1 +0,1 @@

{"version":3,"file":"exports.js","sourceRoot":"","sources":["../../src/exports.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAA;AAMnD,OAAO,MAAM,MAAM,aAAa,CAAA;AAChC,OAAO,QAAQ,MAAM,eAAe,CAAA;AACpC,OAAO,IAAI,MAAM,WAAW,CAAA;AAC5B,OAAO,GAAG,MAAM,cAAc,CAAA;AAE9B,OAAO,SAAS,MAAM,gBAAgB,CAAA;AACtC,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAEnD,MAAM,EAAE,WAAW,GAAG,EAAE,EAAE,gBAAgB,GAAG,EAAE,EAAE,GAAG,MAAM,CAAA;AAE1D,MAAM,OAAO,GACX,MAAM,CAAC,OAAO;IACd,OAAO,CAAC,GAAG,CAAC,WAAW,KAAK,SAAS;IACrC,OAAO,CAAC,GAAG,CAAC,WAAW,KAAK,MAAM,CAAA;AAEpC,MAAM,4BAA4B,GAAG,CACnC,CAAyC,EACzC,OAAU,EACV,SAEG,EACH,IAEoB,EACpB,SAAS,GAA6B,IAAI,GAAG,EAAE,EACpB,EAAE,CAAC;IAC9B,IAAI,CAAC,KAAK,SAAS;QAAE,OAAO,SAAS,CAAA;IACrC,IAAI,OAAO,CAAC,KAAK,QAAQ,EAAE,CAAC;QAC1B,gC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G;YAAE,GAAG,CAAC,KAAK,GAAG,KAAK,CAAA;;YACxC,OAAO,GAAG,CAAC,KAAK,CAAA;IACvB,CAAC;SAAM,CAAC;QACN,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,KAAK,KAAK;YAAE,OAAO,CAAC,CAAC,IAAI,CAAA;QACxC,OAAO,GAAG,CAAC,IAAI,CAAA;QACf,OAAO,GAAG,CAAC,KAAK,CAAA;IAClB,CAAC;IAED,yCAAyC;IACzC,MAAM,SAAS,GAAG,aAAa,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAA;IAC7D,MAAM,MAAM,GAAG,CAAC,EAAE,MAAM,IAAI,CAAC,CAAC,SAAS,CAAA;IACvC,IAAI,MAAM,EAAE,CAAC;QACX,IAAI,CAAC,SAAS,EAAE,CAAC;YACf,IAAI,CAAC,yDAAyD,CAAC,CAAA;YAC/D,OAAO,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;QACxB,CAAC;QAED,GAAG,CAAC,MAAM,GAAG,SAAS,CAAA;IACxB,CAAC;SAAM,CAAC;QACN,IAAI,CAAC,IAAI,CAAC,CAAC,MAAM,KAAK,KAAK;YAAE,OAAO,CAAC,CAAC,MAAM,CAAA;QAC5C,OAAO,GAAG,CAAC,MAAM,CAAA;IACnB,CAAC;AAAA,CACF,CAAA;AAED,GAAG,CAAC,OAAO,GAAG,UAAU,CAAC,MAAM,EAAE,GAAG,CAAC,IAAI,CAAC,CAAA;AAE1C,OAAO,CAAC,MAAM,EAAE,GAA6C,CAAC,CAAA;AAC9D,eAAe,GAAG,CAAC,OAAO,CAAA","sourcesContent":["import { relative, resolve } from 'node:path/posix'\nimport type {\n ConditionalValue,\n ConditionalValueObject,\n ExportsSubpaths,\n} from 'resolve-import'\nimport config from './config.js'\nimport dialects from './dialects.js'\nimport fail from './fail.js'\nimport pkg from './package.js'\nimport type { PolyfillSet } from './polyfills.js'\nimport polyfills from './polyfills.js'\nimport { resolveExport } from './resolve-export.js'\nimport type { Package, TshyConfig, TshyExport } from './types.js'\nconst { esmDialects = [], commonjsDialects = [] } = config\n\nconst liveDev =\n config.liveDev &&\n process.env.npm_command !== 'publish' &&\n process.env.npm_command !== 'pack'\n\nconst getTargetForDialectCondition = <T extends string>(\n s: string | TshyExport | undefined | null,\n dialect: T,\n condition: T extends 'esm' ? 'import'\n : T extends 'commonjs' ? 'require'\n : T,\n type: T extends 'esm' ? 'esm'\n : T extends 'commonjs' ? 'commonjs'\n : 'esm' | 'commonjs',\n polyfills: Map<string, PolyfillSet> = new Map(),\n): string | undefined | null => {\n if (s === undefined) return undefined\n if (typeof s === 'string') {\n // the excluded filename pattern\n const xts = type === 'commonjs' ? '.mts' : '.cts'\n if (s.endsWith(xts)) return undefined\n const pf = dialect === 'commonjs' ? 'cjs' : dialect\n const rel = relative(\n resolve('./src'),\n resolve(polyfills.get(pf)?.map.get(s) ?? s),\n )\n const target = liveDev ? rel : rel.replace(/\\.([mc]?)tsx?$/, '.$1js')\n return (\n !s || !s.startsWith('./src/') ? s\n : dialects.includes(type) ? `./dist/${dialect}/${target}`\n : undefined\n )\n }\n return resolveExport(s, [condition])\n}\n\nexport const getImpTarget = (\n s: string | TshyExport | undefined | null,\n polyfills: Map<string, PolyfillSet> = new Map(),\n) => getTargetForDialectCondition(s, 'esm', 'import', 'esm', polyfills)\n\nexport const getReqTarget = (\n s: string | TshyExport | undefined | null,\n polyfills: Map<string, PolyfillSet> = new Map(),\n) =>\n getTargetForDialectCondition(\n s,\n 'commonjs',\n 'require',\n 'commonjs',\n polyfills,\n )\n\nconst getExports = (\n c: TshyConfig,\n pkgType: 'commonjs' | 'module',\n): Record<string, ConditionalValue> => {\n // by this time it always exports, will get the default if missing\n /* c8 ignore start */\n if (!c.exports) {\n fail('no exports on tshy config (is there code in ./src?)')\n return process.exit(1)\n }\n /* c8 ignore stop */\n const e: Record<string, ConditionalValue> = {}\n for (const [sub, s] of Object.entries(c.exports)) {\n // external export, not built by us\n if (s !== null && (typeof s !== 'string' || !s.startsWith('./src/'))) {\n // already been validated, just accept as-is\n e[sub] = s as ConditionalValue\n continue\n }\n\n /* c8 ignore next - already guarded */\n if (s === null) continue\n\n const impTarget = getImpTarget(s, polyfills)\n const reqTarget = getReqTarget(s, polyfills)\n\n // should be impossible\n /* c8 ignore start */\n if (!impTarget && !reqTarget) continue\n /* c8 ignore stop */\n\n const exp: ConditionalValueObject = (e[sub] = {})\n if (impTarget) {\n for (const d of esmDialects) {\n const source = s && (polyfills.get(d)?.map.get(s) ?? s)\n\n const target = getTargetForDialectCondition(\n s,\n d,\n d,\n 'esm',\n polyfills,\n )\n if (target) {\n exp[d] =\n liveDev ?\n {\n ...(pkgType === 'commonjs' ?\n getSourceDialects(source, c)\n : {}),\n default: target,\n }\n : {\n ...(pkgType === 'commonjs' ?\n getSourceDialects(source, c)\n : {}),\n types: target.replace(/\\.js$/, '.d.ts'),\n default: target,\n }\n }\n }\n }\n\n if (reqTarget) {\n for (const d of commonjsDialects) {\n const source = s && (polyfills.get(d)?.map.get(s) ?? s)\n const target = getTargetForDialectCondition(\n s,\n d,\n d,\n 'commonjs',\n polyfills,\n )\n if (target) {\n exp[d] =\n liveDev ?\n {\n ...(pkgType === 'module' ?\n getSourceDialects(source, c)\n : {}),\n default: target,\n }\n : {\n ...(pkgType === 'module' ?\n getSourceDialects(source, c)\n : {}),\n types: target.replace(/\\.js$/, '.d.ts'),\n default: target,\n }\n }\n }\n }\n\n // put the default import/require after all the other special ones.\n if (impTarget) {\n exp.import =\n liveDev ?\n {\n ...(pkgType === 'module' ? getSourceDialects(s, c) : {}),\n default: impTarget,\n }\n : {\n ...(pkgType === 'module' ? getSourceDialects(s, c) : {}),\n types: impTarget.replace(/\\.(m?)js$/, '.d.$1ts'),\n default: impTarget,\n }\n }\n if (reqTarget) {\n exp.require =\n liveDev ?\n {\n ...(pkgType === 'commonjs' ? getSourceDialects(s, c) : {}),\n default: reqTarget,\n }\n : {\n ...(pkgType === 'commonjs' ? getSourceDialects(s, c) : {}),\n types: reqTarget.replace(/\\.(c?)js$/, '.d.$1ts'),\n default: reqTarget,\n }\n }\n }\n return e\n}\n\nconst getSourceDialects = (source: string, c: TshyConfig) => {\n const { sourceDialects } = c\n if (!sourceDialects) return {}\n return Object.fromEntries(sourceDialects.map(s => [s, source]))\n}\n\nexport const setMain = (\n c: TshyConfig | undefined,\n pkg: Package & { exports: ExportsSubpaths },\n) => {\n pkg.type = pkg.type === 'commonjs' ? 'commonjs' : 'module'\n const mod = resolveExport(pkg.exports['.'], ['require'])\n const main = c?.main ?? !!mod\n if (main) {\n if (!mod) {\n fail(`could not resolve exports['.'] for tshy.main 'require'`)\n return process.exit(1)\n }\n const types = resolveExport(pkg.exports['.'], ['require', 'types'])\n pkg.main = mod\n if (types && types !== mod) pkg.types = types\n else delete pkg.types\n } else {\n if (c && c.main !== false) delete c.main\n delete pkg.main\n delete pkg.types\n }\n\n // Set the package module to exports[\".\"]\n const importMod = resolveExport(pkg.exports['.'], ['import'])\n const module = c?.module ?? !!importMod\n if (module) {\n if (!importMod) {\n fail(`could not resolve exports['.'] for tshy.module 'import'`)\n return process.exit(1)\n }\n\n pkg.module = importMod\n } else {\n if (c && c.module !== false) delete c.module\n delete pkg.module\n }\n}\n\npkg.exports = getExports(config, pkg.type)\n\nsetMain(config, pkg as Package & { exports: ExportsSubpaths })\nexport default pkg.exports\n"]}
{"version":3,"file":"exports.js","sourceRoot":"","sources":["../../src/exports.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAA;AAMnD,OAAO,MAAM,MAAM,aAAa,CAAA;AAChC,OAAO,QAAQ,MAAM,eAAe,CAAA;AACpC,OAAO,IAAI,MAAM,WAAW,CAAA;AAC5B,OAAO,GAAG,MAAM,cAAc,CAAA;AAE9B,OAAO,SAAS,MAAM,gBAAgB,CAAA;AACtC,OAAO,EAAE,aAAa,EAAE,MAA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IAAI,KAAK,KAAK;YAAE,OAAO,CAAC,CAAC,IAAI,CAAA;QACxC,OAAO,GAAG,CAAC,IAAI,CAAA;QACf,OAAO,GAAG,CAAC,KAAK,CAAA;IAClB,CAAC;IAED,yCAAyC;IACzC,MAAM,SAAS,GAAG,aAAa,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC,CAAA;IACxE,MAAM,MAAM,GAAG,CAAC,EAAE,MAAM,IAAI,CAAC,CAAC,SAAS,CAAA;IACvC,IAAI,MAAM,EAAE,CAAC;QACX,IAAI,CAAC,SAAS,EAAE,CAAC;YACf,IAAI,CAAC,yDAAyD,CAAC,CAAA;YAC/D,OAAO,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;QACxB,CAAC;QAED,GAAG,CAAC,MAAM,GAAG,SAAS,CAAA;IACxB,CAAC;SAAM,CAAC;QACN,IAAI,CAAC,IAAI,CAAC,CAAC,MAAM,KAAK,KAAK;YAAE,OAAO,CAAC,CAAC,MAAM,CAAA;QAC5C,OAAO,GAAG,CAAC,MAAM,CAAA;IACnB,CAAC;AAAA,CACF,CAAA;AAED,GAAG,CAAC,OAAO,GAAG,UAAU,CAAC,MAAM,EAAE,GAAG,CAAC,IAAI,CAAC,CAAA;AAE1C,OAAO,CAAC,MAAM,EAAE,GAA6C,CAAC,CAAA;AAC9D,eAAe,GAAG,CAAC,OAAO,CAAA","sourcesContent":["import { relative, resolve } from 'node:path/posix'\nimport type {\n ConditionalValue,\n ConditionalValueObject,\n ExportsSubpaths,\n} from 'resolve-import'\nimport config from './config.js'\nimport dialects from './dialects.js'\nimport fail from './fail.js'\nimport pkg from './package.js'\nimport type { PolyfillSet } from './polyfills.js'\nimport polyfills from './polyfills.js'\nimport { resolveExport } from './resolve-export.js'\nimport type { Package, TshyConfig, TshyExport } from './types.js'\nconst { esmDialects = [], commonjsDialects = [] } = config\n\nconst liveDev =\n config.liveDev &&\n process.env.npm_command !== 'publish' &&\n process.env.npm_command !== 'pack'\n\nconst getTargetForDialectCondition = <T extends string>(\n s: string | TshyExport | undefined | null,\n dialect: T,\n condition: T extends 'esm' ? 'import'\n : T extends 'commonjs' ? 'require'\n : T,\n type: T extends 'esm' ? 'esm'\n : T extends 'commonjs' ? 'commonjs'\n : 'esm' | 'commonjs',\n polyfills: Map<string, PolyfillSet> = new Map(),\n): string | undefined | null => {\n if (s === undefined) return undefined\n if (typeof s === 'string') {\n // the excluded filename pattern\n const xts = type === 'commonjs' ? '.mts' : '.cts'\n if (s.endsWith(xts)) return undefined\n const pf = dialect === 'commonjs' ? 'cjs' : dialect\n const rel = relative(\n resolve('./src'),\n resolve(polyfills.get(pf)?.map.get(s) ?? s),\n )\n const target = liveDev ? rel : rel.replace(/\\.([mc]?)tsx?$/, '.$1js')\n const dt =\n dialect === 'commonjs' || dialect === 'esm' ?\n dialect\n : `${type}/${dialect}`\n return (\n !s || !s.startsWith('./src/') ? s\n : dialects.includes(type) ? `./dist/${dt}/${target}`\n : undefined\n )\n }\n return resolveExport(s, [condition])\n}\n\nexport const getImpTarget = (\n s: string | TshyExport | undefined | null,\n polyfills: Map<string, PolyfillSet> = new Map(),\n) => getTargetForDialectCondition(s, 'esm', 'import', 'esm', polyfills)\n\nexport const getReqTarget = (\n s: string | TshyExport | undefined | null,\n polyfills: Map<string, PolyfillSet> = new Map(),\n) =>\n getTargetForDialectCondition(\n s,\n 'commonjs',\n 'require',\n 'commonjs',\n polyfills,\n )\n\nconst getExports = (\n c: TshyConfig,\n pkgType: 'commonjs' | 'module',\n): Record<string, ConditionalValue> => {\n // by this time it always exports, will get the default if missing\n /* c8 ignore start */\n if (!c.exports) {\n fail('no exports on tshy config (is there code in ./src?)')\n return process.exit(1)\n }\n /* c8 ignore stop */\n const e: Record<string, ConditionalValue> = {}\n for (const [sub, s] of Object.entries(c.exports)) {\n // external export, not built by us\n if (s !== null && (typeof s !== 'string' || !s.startsWith('./src/'))) {\n // already been validated, just accept as-is\n e[sub] = s as ConditionalValue\n continue\n }\n\n /* c8 ignore next - already guarded */\n if (s === null) continue\n\n const impTarget = getImpTarget(s, polyfills)\n const reqTarget = getReqTarget(s, polyfills)\n\n // should be impossible\n /* c8 ignore start */\n if (!impTarget && !reqTarget) continue\n /* c8 ignore stop */\n\n const exp: ConditionalValueObject = (e[sub] = {})\n if (impTarget) {\n for (const d of esmDialects) {\n const source = s && (polyfills.get('esm-' + d)?.rmap.get(s) ?? s)\n\n const target = getTargetForDialectCondition(\n s,\n d,\n d,\n 'esm',\n polyfills,\n )\n if (target) {\n const imp = (exp.import ??= {}) as ConditionalValueObject\n const src =\n pkgType === 'module' || source.endsWith('.mts') ?\n getSourceDialects(source, c)\n : undefined\n const types =\n liveDev ? undefined : (\n { types: target.replace(/\\.js$/, '.d.ts') }\n )\n imp[d] = { ...src, ...types, default: target }\n }\n }\n }\n\n if (reqTarget) {\n for (const d of commonjsDialects) {\n const source =\n s && (polyfills.get('commonjs-' + d)?.rmap.get(s) ?? s)\n const target = getTargetForDialectCondition(\n s,\n d,\n d,\n 'commonjs',\n polyfills,\n )\n if (target) {\n const req = (exp.require ??= {}) as ConditionalValueObject\n const src =\n pkgType === 'commonjs' || source.endsWith('.cts') ?\n getSourceDialects(source, c)\n : undefined\n const types =\n liveDev ? undefined : (\n { types: target.replace(/\\.js$/, '.d.ts') }\n )\n req[d] = { ...src, ...types, default: target }\n }\n }\n }\n\n // put the default import/require after all the other special ones.\n if (impTarget) {\n const source = s && (polyfills.get('esm')?.rmap.get(s) ?? s)\n const src =\n pkgType === 'module' || source.endsWith('.mts') ?\n getSourceDialects(source, c)\n : undefined\n const types =\n liveDev ? undefined : (\n { types: impTarget.replace(/\\.(m?)js$/, '.d.$1ts') }\n )\n exp.import = {\n ...(exp.import as ConditionalValueObject),\n ...src,\n ...types,\n default: impTarget,\n }\n }\n if (reqTarget) {\n const source = s && (polyfills.get('cjs')?.rmap.get(s) ?? s)\n const src =\n pkgType === 'commonjs' || source.endsWith('.cts') ?\n getSourceDialects(source, c)\n : undefined\n const types =\n liveDev ? undefined : (\n { types: reqTarget.replace(/\\.(c?)js$/, '.d.$1ts') }\n )\n\n exp.require = {\n ...(exp.require as ConditionalValueObject),\n ...src,\n ...types,\n default: reqTarget,\n }\n }\n }\n return e\n}\n\nconst getSourceDialects = (source: string, c: TshyConfig) => {\n const { sourceDialects } = c\n if (!sourceDialects) return undefined\n return Object.fromEntries(sourceDialects.map(s => [s, source]))\n}\n\nexport const setMain = (\n c: TshyConfig | undefined,\n pkg: Package & { exports: ExportsSubpaths },\n) => {\n pkg.type = pkg.type === 'commonjs' ? 'commonjs' : 'module'\n const mod = resolveExport(pkg.exports['.'], ['require', 'default'])\n const main = c?.main ?? !!mod\n if (main) {\n if (!mod) {\n fail(`could not resolve exports['.'] for tshy.main 'require'`)\n return process.exit(1)\n }\n const types = resolveExport(pkg.exports['.'], ['require', 'types'])\n pkg.main = mod\n if (types && types !== mod) pkg.types = types\n else delete pkg.types\n } else {\n if (c && c.main !== false) delete c.main\n delete pkg.main\n delete pkg.types\n }\n\n // Set the package module to exports[\".\"]\n const importMod = resolveExport(pkg.exports['.'], ['import', 'default'])\n const module = c?.module ?? !!importMod\n if (module) {\n if (!importMod) {\n fail(`could not resolve exports['.'] for tshy.module 'import'`)\n return process.exit(1)\n }\n\n pkg.module = importMod\n } else {\n if (c && c.module !== false) delete c.module\n delete pkg.module\n }\n}\n\npkg.exports = getExports(config, pkg.type)\n\nsetMain(config, pkg as Package & { exports: ExportsSubpaths })\nexport default pkg.exports\n"]}

@@ -5,2 +5,3 @@ export declare class PolyfillSet {

map: Map<string, string>;
rmap: Map<string, string>;
constructor(type: 'esm' | 'commonjs', name: string);

@@ -7,0 +8,0 @@ addFile(f: string, sources: Set<string>): void;

@@ -1,1 +0,1 @@

{"version":3,"file":"polyfills.d.ts","sourceRoot":"","sources":["../../src/polyfills.ts"],"names":[],"mappings":"AAQA,qBAAa,WAAW;IACtB,IAAI,EAAE,KAAK,GAAG,UAAU,CAAA;IACxB,IAAI,EAAE,MAAM,CAAA;IACZ,GAAG,sBAA4B;IAC/B,YAAY,IAAI,EAAE,KAAK,GAAG,UAAU,EAAE,IAAI,EAAE,MAAM,EAGjD;IACD,OAAO,CAAC,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,CAAC,MAAM,CAAC,QAQtC;CAIF;AAED,QAAA,MAAM,SAAS,0BAEb,CAAA;AAoBF,eAAe,SAAS,CAAA","sourcesContent":["// the modules like -cjs.cts that override a module at .ts\nimport chalk from 'chalk'\nimport config from './config.js'\nimport * as console from './console.js'\nimport sources from './sources.js'\n\nconst { esmDialects = [], commonjsDialects = [] } = config\n\nexport class PolyfillSet {\n type: 'esm' | 'commonjs'\n name: string\n map = new Map<string, string>()\n constructor(type: 'esm' | 'commonjs', name: string) {\n this.type = type\n this.name = name\n }\n addFile(f: string, sources: Set<string>) {\n const dotts = this.type === 'commonjs' ? 'cts' : 'mts'\n const ending = `-${this.name}.${dotts}`\n if (!f.endsWith(ending)) return\n const ts = f.substring(0, f.length - ending.length) + '.ts'\n const tsx = ts + 'x'\n if (sources.has(ts)) this.map.set(f, ts)\n else if (sources.has(tsx)) this.map.set(f, tsx)\n }\n [Symbol.for('nodejs.util.inspect.custom')]() {\n return [this.name, this.map]\n }\n}\n\nconst polyfills = new Map<string, PolyfillSet>([\n ['cjs', new PolyfillSet('commonjs', 'cjs')],\n])\nfor (const d of commonjsDialects)\n polyfills.set(d, new PolyfillSet('commonjs', d))\nfor (const d of esmDialects) polyfills.set(d, new PolyfillSet('esm', d))\n\nfor (const f of sources) {\n for (const pf of polyfills.values()) {\n pf.addFile(f, sources)\n }\n}\n\n// delete any polyfill types that have no entries\nfor (const [name, pf] of polyfills.entries()) {\n if (pf.map.size === 0) polyfills.delete(name)\n}\n\nif (polyfills.size) {\n console.debug(chalk.cyan.dim('polyfills detected'), polyfills)\n}\n\nexport default polyfills\n"]}
{"version":3,"file":"polyfills.d.ts","sourceRoot":"","sources":["../../src/polyfills.ts"],"names":[],"mappings":"AAQA,qBAAa,WAAW;IACtB,IAAI,EAAE,KAAK,GAAG,UAAU,CAAA;IACxB,IAAI,EAAE,MAAM,CAAA;IACZ,GAAG,sBAA4B;IAC/B,IAAI,sBAA4B;IAChC,YAAY,IAAI,EAAE,KAAK,GAAG,UAAU,EAAE,IAAI,EAAE,MAAM,EAGjD;IACD,OAAO,CAAC,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,CAAC,MAAM,CAAC,QAyBtC;CAIF;AAED,QAAA,MAAM,SAAS,0BAGb,CAAA;AAqBF,eAAe,SAAS,CAAA","sourcesContent":["// the modules like -cjs.cts that override a module at .ts\nimport chalk from 'chalk'\nimport config from './config.js'\nimport * as console from './console.js'\nimport sources from './sources.js'\n\nconst { esmDialects = [], commonjsDialects = [] } = config\n\nexport class PolyfillSet {\n type: 'esm' | 'commonjs'\n name: string\n map = new Map<string, string>()\n rmap = new Map<string, string>()\n constructor(type: 'esm' | 'commonjs', name: string) {\n this.type = type\n this.name = name\n }\n addFile(f: string, sources: Set<string>) {\n const dotts = this.type === 'commonjs' ? 'cts' : 'mts'\n let ending = `-${this.name}.${dotts}`\n // custom dialects can override both types with a -name.ts file.\n if (\n !f.endsWith(ending) &&\n this.name !== 'cjs' &&\n this.name !== 'esm'\n ) {\n ending = `-${this.name}.ts`\n }\n if (!f.endsWith(ending)) {\n return\n }\n const ts = f.substring(0, f.length - ending.length) + '.ts'\n const tsx = ts + 'x'\n const src =\n sources.has(ts) ? ts\n : sources.has(tsx) ? tsx\n : undefined\n if (!src) {\n return\n }\n this.map.set(f, src)\n this.rmap.set(src, f)\n }\n [Symbol.for('nodejs.util.inspect.custom')]() {\n return [this.name, this.type, this.map]\n }\n}\n\nconst polyfills = new Map<string, PolyfillSet>([\n ['cjs', new PolyfillSet('commonjs', 'cjs')],\n ['esm', new PolyfillSet('esm', 'esm')],\n])\nfor (const d of commonjsDialects)\n polyfills.set('commonjs-' + d, new PolyfillSet('commonjs', d))\nfor (const d of esmDialects)\n polyfills.set('esm-' + d, new PolyfillSet('esm', d))\n\nfor (const f of sources) {\n for (const pf of polyfills.values()) {\n pf.addFile(f, sources)\n }\n}\n\n// delete any polyfill types that have no entries\nfor (const [name, pf] of polyfills.entries()) {\n if (pf.map.size === 0) polyfills.delete(name)\n}\n\nif (polyfills.size) {\n console.debug(chalk.cyan.dim('polyfills detected'), polyfills)\n}\n\nexport default polyfills\n"]}

@@ -11,2 +11,3 @@ // the modules like -cjs.cts that override a module at .ts

map = new Map();
rmap = new Map();
constructor(type, name) {

@@ -18,14 +19,25 @@ this.type = type;

const dotts = this.type === 'commonjs' ? 'cts' : 'mts';
const ending = `-${this.name}.${dotts}`;
if (!f.endsWith(ending))
let ending = `-${this.name}.${dotts}`;
// custom dialects can override both types with a -name.ts file.
if (!f.endsWith(ending) &&
this.name !== 'cjs' &&
this.name !== 'esm') {
ending = `-${this.name}.ts`;
}
if (!f.endsWith(ending)) {
return;
}
const ts = f.substring(0, f.length - ending.length) + '.ts';
const tsx = ts + 'x';
if (sources.has(ts))
this.map.set(f, ts);
else if (sources.has(tsx))
this.map.set(f, tsx);
const src = sources.has(ts) ? ts
: sources.has(tsx) ? tsx
: undefined;
if (!src) {
return;
}
this.map.set(f, src);
this.rmap.set(src, f);
}
[Symbol.for('nodejs.util.inspect.custom')]() {
return [this.name, this.map];
return [this.name, this.type, this.map];
}

@@ -35,7 +47,8 @@ }

['cjs', new PolyfillSet('commonjs', 'cjs')],
['esm', new PolyfillSet('esm', 'esm')],
]);
for (const d of commonjsDialects)
polyfills.set(d, new PolyfillSet('commonjs', d));
polyfills.set('commonjs-' + d, new PolyfillSet('commonjs', d));
for (const d of esmDialects)
polyfills.set(d, new PolyfillSet('esm', d));
polyfills.set('esm-' + d, new PolyfillSet('esm', d));
for (const f of sources) {

@@ -42,0 +55,0 @@ for (const pf of polyfills.values()) {

@@ -1,1 +0,1 @@

{"version":3,"file":"polyfills.js","sourceR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'./config.js'\nimport * as console from './console.js'\nimport sources from './sources.js'\n\nconst { esmDialects = [], commonjsDialects = [] } = config\n\nexport class PolyfillSet {\n type: 'esm' | 'commonjs'\n name: string\n map = new Map<string, string>()\n constructor(type: 'esm' | 'commonjs', name: string) {\n this.type = type\n this.name = name\n }\n addFile(f: string, sources: Set<string>) {\n const dotts = this.type === 'commonjs' ? 'cts' : 'mts'\n const ending = `-${this.name}.${dotts}`\n if (!f.endsWith(ending)) return\n const ts = f.substring(0, f.length - ending.length) + '.ts'\n const tsx = ts + 'x'\n if (sources.has(ts)) this.map.set(f, ts)\n else if (sources.has(tsx)) this.map.set(f, tsx)\n }\n [Symbol.for('nodejs.util.inspect.custom')]() {\n return [this.name, this.map]\n }\n}\n\nconst polyfills = new Map<string, PolyfillSet>([\n ['cjs', new PolyfillSet('commonjs', 'cjs')],\n])\nfor (const d of commonjsDialects)\n polyfills.set(d, new PolyfillSet('commonjs', d))\nfor (const d of esmDialects) polyfills.set(d, new PolyfillSet('esm', d))\n\nfor (const f of sources) {\n for (const pf of polyfills.values()) {\n pf.addFile(f, sources)\n }\n}\n\n// delete any polyfill types that have no entries\nfor (const [name, pf] of polyfills.entries()) {\n if (pf.map.size === 0) polyfills.delete(name)\n}\n\nif (polyfills.size) {\n console.debug(chalk.cyan.dim('polyfills detected'), polyfills)\n}\n\nexport default polyfills\n"]}
{"version":3,"file":"polyfills.js","sourceRoot":"","sources":["../../src/polyfills.ts"],"names":[],"mappings":"AAAA,0DAA0D;AAC1D,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,MAAM,MAAM,aAAa,CAAA;AAChC,OAAO,KAAK,OAAO,MAAM,cAAc,CAAA;AACvC,OAAO,OAAO,MAAM,cAAc,CAAA;AAElC,MAAM,EAAE,WAAW,GAAG,EAAE,EAAE,gBAAgB,GAAG,EAAE,EAAE,GAAG,MAAM,CAAA;AAE1D,MAAM,OAAO,WAAW;IACtB,IAAI,CAAoB;IACxB,IAAI,CAAQ;IACZ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,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,oBAAoB,CAAC,EAAE,SAAS,CAAC,CAAA;AAChE,CAAC;AAED,eAAe,SAAS,CAAA","sourcesContent":["// the modules like -cjs.cts that override a module at .ts\nimport chalk from 'chalk'\nimport config from './config.js'\nimport * as console from './console.js'\nimport sources from './sources.js'\n\nconst { esmDialects = [], commonjsDialects = [] } = config\n\nexport class PolyfillSet {\n type: 'esm' | 'commonjs'\n name: string\n map = new Map<string, string>()\n rmap = new Map<string, string>()\n constructor(type: 'esm' | 'commonjs', name: string) {\n this.type = type\n this.name = name\n }\n addFile(f: string, sources: Set<string>) {\n const dotts = this.type === 'commonjs' ? 'cts' : 'mts'\n let ending = `-${this.name}.${dotts}`\n // custom dialects can override both types with a -name.ts file.\n if (\n !f.endsWith(ending) &&\n this.name !== 'cjs' &&\n this.name !== 'esm'\n ) {\n ending = `-${this.name}.ts`\n }\n if (!f.endsWith(ending)) {\n return\n }\n const ts = f.substring(0, f.length - ending.length) + '.ts'\n const tsx = ts + 'x'\n const src =\n sources.has(ts) ? ts\n : sources.has(tsx) ? tsx\n : undefined\n if (!src) {\n return\n }\n this.map.set(f, src)\n this.rmap.set(src, f)\n }\n [Symbol.for('nodejs.util.inspect.custom')]() {\n return [this.name, this.type, this.map]\n }\n}\n\nconst polyfills = new Map<string, PolyfillSet>([\n ['cjs', new PolyfillSet('commonjs', 'cjs')],\n ['esm', new PolyfillSet('esm', 'esm')],\n])\nfor (const d of commonjsDialects)\n polyfills.set('commonjs-' + d, new PolyfillSet('commonjs', d))\nfor (const d of esmDialects)\n polyfills.set('esm-' + d, new PolyfillSet('esm', d))\n\nfor (const f of sources) {\n for (const pf of polyfills.values()) {\n pf.addFile(f, sources)\n }\n}\n\n// delete any polyfill types that have no entries\nfor (const [name, pf] of polyfills.entries()) {\n if (pf.map.size === 0) polyfills.delete(name)\n}\n\nif (polyfills.size) {\n console.debug(chalk.cyan.dim('polyfills detected'), polyfills)\n}\n\nexport default polyfills\n"]}

@@ -1,1 +0,1 @@

{"version":3,"file":"resolve-export.d.ts","sourceRoot":"","sources":["../../src/resolve-export.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,aAAa,mEAqBzB,CAAA","sourcesContent":["export const resolveExport = (\n exp: unknown,\n conditions: string[],\n): string | undefined | null => {\n if (typeof exp === 'string') return exp\n if (typeof exp !== 'object') return undefined\n if (exp === null) return exp\n if (Array.isArray(exp)) {\n for (const e of exp) {\n const u = resolveExport(e, conditions)\n if (u || u === null) return u\n }\n return undefined\n }\n const conds = [...conditions, 'node', 'default']\n for (const [c, e] of Object.entries(exp)) {\n if (conds.includes(c)) {\n const u = resolveExport(e, conditions)\n if (u || u === null) return u\n }\n }\n}\n"]}
{"version":3,"file":"resolve-export.d.ts","sourceRoot":"","sources":["../../src/resolve-export.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,aAAa,mEAqBzB,CAAA","sourcesContent":["export const resolveExport = (\n exp: unknown,\n conditions: string[],\n): string | undefined | null => {\n if (typeof exp === 'string') return exp\n if (typeof exp !== 'object') return undefined\n if (exp === null) return exp\n if (Array.isArray(exp)) {\n for (const e of exp) {\n const u = resolveExport(e, conditions)\n if (u || u === null) return u\n }\n return undefined\n }\n const conds = [...conditions, 'default']\n for (const [c, e] of Object.entries(exp)) {\n if (conds.includes(c)) {\n const u = resolveExport(e, conditions)\n if (u || u === null) return u\n }\n }\n}\n"]}

@@ -16,3 +16,3 @@ export const resolveExport = (exp, conditions) => {

}
const conds = [...conditions, 'node', 'default'];
const conds = [...conditions, 'default'];
for (const [c, e] of Object.entries(exp)) {

@@ -19,0 +19,0 @@ if (conds.includes(c)) {

@@ -1,1 +0,1 @@

{"version":3,"file":"resolve-export.js","sourceRoot":"","sources":["../../src/resolve-export.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,aAAa,GAAG,CAC3B,GAAY,EACZ,UAAoB,EACO,EAAE,CAAC;IAC9B,IAAI,OAAO,GAAG,KAAK,QAAQ;QAAE,OAAO,GAAG,CAAA;IACvC,IAAI,OAAO,GAAG,KAAK,QAAQ;QAAE,OAAO,SAAS,CAAA;IAC7C,IAAI,GAAG,KAAK,IAAI;QAAE,OAAO,GAAG,CAAA;IAC5B,IAAI,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;QACvB,KAAK,MAAM,CAAC,IAAI,GAAG,EAAE,CAAC;YACpB,MAAM,CAAC,GAAG,aAAa,CAAC,CAAC,EAAE,UAAU,CAAC,CAAA;YACtC,IAAI,CAAC,IAAI,CAAC,KAAK,IAAI;gBAAE,OAAO,CAAC,CAAA;QAC/B,CAAC;QACD,OAAO,SAAS,CAAA;IAClB,CAAC;IACD,MAAM,KAAK,GAAG,CAAC,GAAG,UAAU,EAAE,MAAM,EAAE,SAAS,CAAC,CAAA;IAChD,KAAK,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;QACzC,IAAI,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC;YACtB,MAAM,CAAC,GAAG,aAAa,CAAC,CAAC,EAAE,UAAU,CAAC,CAAA;YACtC,IAAI,CAAC,IAAI,CAAC,KAAK,IAAI;gBAAE,OAAO,CAAC,CAAA;QAC/B,CAAC;IACH,CAAC;AAAA,CACF,CAAA","sourcesContent":["export const resolveExport = (\n exp: unknown,\n conditions: string[],\n): string | undefined | null => {\n if (typeof exp === 'string') return exp\n if (typeof exp !== 'object') return undefined\n if (exp === null) return exp\n if (Array.isArray(exp)) {\n for (const e of exp) {\n const u = resolveExport(e, conditions)\n if (u || u === null) return u\n }\n return undefined\n }\n const conds = [...conditions, 'node', 'default']\n for (const [c, e] of Object.entries(exp)) {\n if (conds.includes(c)) {\n const u = resolveExport(e, conditions)\n if (u || u === null) return u\n }\n }\n}\n"]}
{"version":3,"file":"resolve-export.js","sourceRoot":"","sources":["../../src/resolve-export.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,aAAa,GAAG,CAC3B,GAAY,EACZ,UAAoB,EACO,EAAE,CAAC;IAC9B,IAAI,OAAO,GAAG,KAAK,QAAQ;QAAE,OAAO,GAAG,CAAA;IACvC,IAAI,OAAO,GAAG,KAAK,QAAQ;QAAE,OAAO,SAAS,CAAA;IAC7C,IAAI,GAAG,KAAK,IAAI;QAAE,OAAO,GAAG,CAAA;IAC5B,IAAI,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;QACvB,KAAK,MAAM,CAAC,IAAI,GAAG,EAAE,CAAC;YACpB,MAAM,CAAC,GAAG,aAAa,CAAC,CAAC,EAAE,UAAU,CAAC,CAAA;YACtC,IAAI,CAAC,IAAI,CAAC,KAAK,IAAI;gBAAE,OAAO,CAAC,CAAA;QAC/B,CAAC;QACD,OAAO,SAAS,CAAA;IAClB,CAAC;IACD,MAAM,KAAK,GAAG,CAAC,GAAG,UAAU,EAAE,SAAS,CAAC,CAAA;IACxC,KAAK,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;QACzC,IAAI,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC;YACtB,MAAM,CAAC,GAAG,aAAa,CAAC,CAAC,EAAE,UAAU,CAAC,CAAA;YACtC,IAAI,CAAC,IAAI,CAAC,KAAK,IAAI;gBAAE,OAAO,CAAC,CAAA;QAC/B,CAAC;IACH,CAAC;AAAA,CACF,CAAA","sourcesContent":["export const resolveExport = (\n exp: unknown,\n conditions: string[],\n): string | undefined | null => {\n if (typeof exp === 'string') return exp\n if (typeof exp !== 'object') return undefined\n if (exp === null) return exp\n if (Array.isArray(exp)) {\n for (const e of exp) {\n const u = resolveExport(e, conditions)\n if (u || u === null) return u\n }\n return undefined\n }\n const conds = [...conditions, 'default']\n for (const [c, e] of Object.entries(exp)) {\n if (conds.includes(c)) {\n const u = resolveExport(e, conditions)\n if (u || u === null) return u\n }\n }\n}\n"]}

@@ -1,1 +0,1 @@

{"version":3,"file":"tsconfig.d.ts","sourceRoot":"","sources":["../../src/tsconfig.ts"],"names":[],"mappings":"","sourcesContent":["import chalk from 'chalk'\nimport { mkdirpSync } from 'mkdirp'\nimport {\n existsSync,\n readdirSync,\n unlinkSync,\n writeFileSync,\n} from 'node:fs'\nimport { resolve } from 'node:path'\nimport { join } from 'node:path/posix'\nimport * as console from './console.js'\n\n// the commonjs build needs to exclude anything that will be polyfilled\nimport config from './config.js'\nimport polyfills from './polyfills.js'\nimport preventVerbatimModuleSyntax from './prevent-verbatim-module-syntax.js'\nimport readTypescriptConfig from './read-typescript-config.js'\n\nconst {\n dialects = ['esm', 'commonjs'],\n esmDialects = [],\n commonjsDialects = [],\n exclude = [],\n} = config\n\nconst relativeExclude = exclude.map(e => `../${e.replace(/^\\.\\//, '')}`)\n\nconst recommended: Record<string, unknown> = {\n compilerOptions: {\n types: ['node'],\n rootDir: './',\n declaration: true,\n declarationMap: true,\n esModuleInterop: true,\n forceConsistentCasingInFileNames: true,\n inlineSources: true,\n jsx: 'react',\n module: 'nodenext',\n moduleResolution: 'nodenext',\n noUncheckedIndexedAccess: true,\n resolveJsonModule: true,\n skipLibCheck: true,\n sourceMap: true,\n strict: true,\n target: 'es2022',\n },\n}\n\nconst build = (): Record<string, unknown> => ({\n extends:\n config.project === undefined ?\n '../tsconfig.json'\n : join('..', config.project),\n compilerOptions: {\n target:\n readTypescriptConfig().compilerOptions.target === undefined ?\n 'es2022'\n : undefined,\n rootDir: '../src',\n module: 'nodenext',\n moduleResolution: 'nodenext',\n },\n})\n\nconst commonjs = (dialect: string): Record<string, unknown> => {\n const exclude = [\n ...relativeExclude,\n '../src/**/*.mts',\n '../src/package.json',\n ]\n for (const [d, pf] of polyfills) {\n if (d === dialect) continue\n for (const f of pf.map.keys()) {\n exclude.push(`../${join(f)}`)\n }\n }\n return {\n extends: './build.json',\n include: [\n '../src/**/*.ts',\n '../src/**/*.cts',\n '../src/**/*.tsx',\n '../src/**/*.json',\n ],\n exclude,\n compilerOptions: {\n outDir:\n '../.tshy-build/' + (dialect === 'cjs' ? 'commonjs' : dialect),\n },\n }\n}\n\nconst esm = (dialect: string): Record<string, unknown> => {\n const exclude: string[] = [...relativeExclude, '../src/package.json']\n for (const [d, pf] of polyfills) {\n if (d === dialect) continue\n for (const f of pf.map.keys()) {\n exclude.push(`../${f.replace(/^\\.\\//, '')}`)\n }\n }\n return {\n extends: './build.json',\n include: [\n '../src/**/*.ts',\n '../src/**/*.mts',\n '../src/**/*.tsx',\n '../src/**/*.json',\n ],\n exclude,\n compilerOptions: {\n outDir: '../.tshy-build/' + dialect,\n },\n }\n}\n\nmkdirpSync('.tshy')\nconst writeConfig = (name: string, data: Record<string, unknown>) =>\n writeFileSync(`.tshy/${name}.json`, JSON.stringify(data, null, 2) + '\\n')\n\nconsole.debug(chalk.cyan.dim('writing tsconfig files...'))\nif (config.project === undefined && !existsSync('tsconfig.json')) {\n console.debug('using recommended tsconfig.json')\n writeConfig('../tsconfig', recommended)\n} else {\n if (dialects.length > 1) preventVerbatimModuleSyntax()\n console.debug('using existing tsconfig.json')\n}\nfor (const f of readdirSync('.tshy')) {\n unlinkSync(resolve('.tshy', f))\n}\nwriteConfig('build', build())\nif (dialects.includes('commonjs')) {\n writeConfig('commonjs', commonjs('cjs'))\n for (const d of commonjsDialects) {\n writeConfig(d, commonjs(d))\n }\n}\nif (dialects.includes('esm')) {\n writeConfig('esm', esm('esm'))\n for (const d of esmDialects) {\n writeConfig(d, esm(d))\n }\n}\n"]}
{"version":3,"file":"tsconfig.d.ts","sourceRoot":"","sources":["../../src/tsconfig.ts"],"names":[],"mappings":"","sourcesContent":["import chalk from 'chalk'\nimport { mkdirpSync } from 'mkdirp'\nimport {\n existsSync,\n readdirSync,\n unlinkSync,\n writeFileSync,\n} from 'node:fs'\nimport { resolve } from 'node:path'\nimport { join } from 'node:path/posix'\nimport * as console from './console.js'\n\n// the commonjs build needs to exclude anything that will be polyfilled\nimport config from './config.js'\nimport polyfills from './polyfills.js'\nimport preventVerbatimModuleSyntax from './prevent-verbatim-module-syntax.js'\nimport readTypescriptConfig from './read-typescript-config.js'\n\nconst {\n dialects = ['esm', 'commonjs'],\n esmDialects = [],\n commonjsDialects = [],\n exclude = [],\n} = config\n\nconst relativeExclude = exclude.map(e => `../${e.replace(/^\\.\\//, '')}`)\n\nconst recommended: Record<string, unknown> = {\n compilerOptions: {\n types: ['node'],\n rootDir: './',\n declaration: true,\n declarationMap: true,\n esModuleInterop: true,\n forceConsistentCasingInFileNames: true,\n inlineSources: true,\n jsx: 'react',\n module: 'nodenext',\n moduleResolution: 'nodenext',\n noUncheckedIndexedAccess: true,\n resolveJsonModule: true,\n skipLibCheck: true,\n sourceMap: true,\n strict: true,\n target: 'es2022',\n },\n}\n\nconst build = (): Record<string, unknown> => ({\n extends:\n config.project === undefined ?\n '../tsconfig.json'\n : join('..', config.project),\n compilerOptions: {\n target:\n readTypescriptConfig().compilerOptions.target === undefined ?\n 'es2022'\n : undefined,\n rootDir: '../src',\n module: 'nodenext',\n moduleResolution: 'nodenext',\n },\n})\n\nconst commonjs = (\n dialect: string,\n dist: string,\n): Record<string, unknown> => {\n const exclude = [\n ...relativeExclude,\n '../src/**/*.mts',\n '../src/package.json',\n ]\n for (const pf of polyfills.values()) {\n if (pf.name === dialect && pf.type === 'commonjs') continue\n for (const f of pf.map.keys()) {\n exclude.push(`../${join(f)}`)\n }\n }\n console.error('excluded:', exclude)\n return {\n extends: './build.json',\n include: [\n '../src/**/*.ts',\n '../src/**/*.cts',\n '../src/**/*.tsx',\n '../src/**/*.json',\n ],\n exclude,\n compilerOptions: {\n outDir: '../.tshy-build/' + dist,\n },\n }\n}\n\nconst esm = (dialect: string, dist: string): Record<string, unknown> => {\n const exclude: string[] = [...relativeExclude, '../src/package.json']\n for (const pf of polyfills.values()) {\n if (pf.name === dialect && pf.type === 'esm') continue\n for (const f of pf.map.keys()) {\n exclude.push(`../${f.replace(/^\\.\\//, '')}`)\n }\n }\n return {\n extends: './build.json',\n include: [\n '../src/**/*.ts',\n '../src/**/*.mts',\n '../src/**/*.tsx',\n '../src/**/*.json',\n ],\n exclude,\n compilerOptions: {\n outDir: '../.tshy-build/' + dist,\n },\n }\n}\n\nmkdirpSync('.tshy')\nconst writeConfig = (name: string, data: Record<string, unknown>) =>\n writeFileSync(`.tshy/${name}.json`, JSON.stringify(data, null, 2) + '\\n')\n\nconsole.debug(chalk.cyan.dim('writing tsconfig files...'))\nif (config.project === undefined && !existsSync('tsconfig.json')) {\n console.debug('using recommended tsconfig.json')\n writeConfig('../tsconfig', recommended)\n} else {\n if (dialects.length > 1) preventVerbatimModuleSyntax()\n console.debug('using existing tsconfig.json')\n}\nfor (const f of readdirSync('.tshy')) {\n unlinkSync(resolve('.tshy', f))\n}\nwriteConfig('build', build())\nif (dialects.includes('commonjs')) {\n writeConfig('commonjs', commonjs('cjs', 'commonjs'))\n for (const d of commonjsDialects) {\n writeConfig(`commonjs-${d}`, commonjs(d, `commonjs/${d}`))\n }\n}\nif (dialects.includes('esm')) {\n writeConfig('esm', esm('esm', 'esm'))\n for (const d of esmDialects) {\n writeConfig(`esm-${d}`, esm(d, `esm/${d}`))\n }\n}\n"]}

@@ -47,3 +47,3 @@ import chalk from 'chalk';

});
const commonjs = (dialect) => {
const commonjs = (dialect, dist) => {
const exclude = [

@@ -54,4 +54,4 @@ ...relativeExclude,

];
for (const [d, pf] of polyfills) {
if (d === dialect)
for (const pf of polyfills.values()) {
if (pf.name === dialect && pf.type === 'commonjs')
continue;

@@ -62,2 +62,3 @@ for (const f of pf.map.keys()) {

}
console.error('excluded:', exclude);
return {

@@ -73,10 +74,10 @@ extends: './build.json',

compilerOptions: {
outDir: '../.tshy-build/' + (dialect === 'cjs' ? 'commonjs' : dialect),
outDir: '../.tshy-build/' + dist,
},
};
};
const esm = (dialect) => {
const esm = (dialect, dist) => {
const exclude = [...relativeExclude, '../src/package.json'];
for (const [d, pf] of polyfills) {
if (d === dialect)
for (const pf of polyfills.values()) {
if (pf.name === dialect && pf.type === 'esm')
continue;

@@ -97,3 +98,3 @@ for (const f of pf.map.keys()) {

compilerOptions: {
outDir: '../.tshy-build/' + dialect,
outDir: '../.tshy-build/' + dist,
},

@@ -119,13 +120,13 @@ };

if (dialects.includes('commonjs')) {
writeConfig('commonjs', commonjs('cjs'));
writeConfig('commonjs', commonjs('cjs', 'commonjs'));
for (const d of commonjsDialects) {
writeConfig(d, commonjs(d));
writeConfig(`commonjs-${d}`, commonjs(d, `commonjs/${d}`));
}
}
if (dialects.includes('esm')) {
writeConfig('esm', esm('esm'));
writeConfig('esm', esm('esm', 'esm'));
for (const d of esmDialects) {
writeConfig(d, esm(d));
writeConfig(`esm-${d}`, esm(d, `esm/${d}`));
}
}
//# sourceMappingURL=tsconfig.js.map

@@ -1,1 +0,1 @@

{"version":3,"file":"tsconfig.js","sourceRoot":"","sources":["../../src/tsconfig.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAA;AACnC,OAAO,EACL,UAAU,EACV,WAAW,EACX,UAAU,EACV,aAAa,GACd,MAAM,SAAS,CAAA;AAChB,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAA;AACtC,OAAO,KAAK,OAAO,MAAM,cAAc,CAAA;AAEvC,uEAAuE;AACvE,OAAO,MAAM,MAAM,aAAa,CAAA;AAChC,OAAO,SAAS,MAAM,gBAAgB,CAAA;AACtC,OAAO,2BAA2B,MAAM,qCAAqC,CAAA;AAC7E,OAAO,oBAAoB,MAAM,6BAA6B,CAAA;AAE9D,MAAM,EACJ,QAAQ,GAAG,CAAC,KAAK,EAAE,UAAU,CAAC,EAC9B,WAAW,GAAG,EAAE,EAChB,gBAAgB,GAAG,EAAE,EACrB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AAK,CAAC,CAAC,CAAA;IAC9B,KAAK,MAAM,CAAC,IAAI,WAAW,EAAE,CAAC;QAC5B,WAAW,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,CAAA;IACxB,CAAC;AACH,CAAC","sourcesContent":["import chalk from 'chalk'\nimport { mkdirpSync } from 'mkdirp'\nimport {\n existsSync,\n readdirSync,\n unlinkSync,\n writeFileSync,\n} from 'node:fs'\nimport { resolve } from 'node:path'\nimport { join } from 'node:path/posix'\nimport * as console from './console.js'\n\n// the commonjs build needs to exclude anything that will be polyfilled\nimport config from './config.js'\nimport polyfills from './polyfills.js'\nimport preventVerbatimModuleSyntax from './prevent-verbatim-module-syntax.js'\nimport readTypescriptConfig from './read-typescript-config.js'\n\nconst {\n dialects = ['esm', 'commonjs'],\n esmDialects = [],\n commonjsDialects = [],\n exclude = [],\n} = config\n\nconst relativeExclude = exclude.map(e => `../${e.replace(/^\\.\\//, '')}`)\n\nconst recommended: Record<string, unknown> = {\n compilerOptions: {\n types: ['node'],\n rootDir: './',\n declaration: true,\n declarationMap: true,\n esModuleInterop: true,\n forceConsistentCasingInFileNames: true,\n inlineSources: true,\n jsx: 'react',\n module: 'nodenext',\n moduleResolution: 'nodenext',\n noUncheckedIndexedAccess: true,\n resolveJsonModule: true,\n skipLibCheck: true,\n sourceMap: true,\n strict: true,\n target: 'es2022',\n },\n}\n\nconst build = (): Record<string, unknown> => ({\n extends:\n config.project === undefined ?\n '../tsconfig.json'\n : join('..', config.project),\n compilerOptions: {\n target:\n readTypescriptConfig().compilerOptions.target === undefined ?\n 'es2022'\n : undefined,\n rootDir: '../src',\n module: 'nodenext',\n moduleResolution: 'nodenext',\n },\n})\n\nconst commonjs = (dialect: string): Record<string, unknown> => {\n const exclude = [\n ...relativeExclude,\n '../src/**/*.mts',\n '../src/package.json',\n ]\n for (const [d, pf] of polyfills) {\n if (d === dialect) continue\n for (const f of pf.map.keys()) {\n exclude.push(`../${join(f)}`)\n }\n }\n return {\n extends: './build.json',\n include: [\n '../src/**/*.ts',\n '../src/**/*.cts',\n '../src/**/*.tsx',\n '../src/**/*.json',\n ],\n exclude,\n compilerOptions: {\n outDir:\n '../.tshy-build/' + (dialect === 'cjs' ? 'commonjs' : dialect),\n },\n }\n}\n\nconst esm = (dialect: string): Record<string, unknown> => {\n const exclude: string[] = [...relativeExclude, '../src/package.json']\n for (const [d, pf] of polyfills) {\n if (d === dialect) continue\n for (const f of pf.map.keys()) {\n exclude.push(`../${f.replace(/^\\.\\//, '')}`)\n }\n }\n return {\n extends: './build.json',\n include: [\n '../src/**/*.ts',\n '../src/**/*.mts',\n '../src/**/*.tsx',\n '../src/**/*.json',\n ],\n exclude,\n compilerOptions: {\n outDir: '../.tshy-build/' + dialect,\n },\n }\n}\n\nmkdirpSync('.tshy')\nconst writeConfig = (name: string, data: Record<string, unknown>) =>\n writeFileSync(`.tshy/${name}.json`, JSON.stringify(data, null, 2) + '\\n')\n\nconsole.debug(chalk.cyan.dim('writing tsconfig files...'))\nif (config.project === undefined && !existsSync('tsconfig.json')) {\n console.debug('using recommended tsconfig.json')\n writeConfig('../tsconfig', recommended)\n} else {\n if (dialects.length > 1) preventVerbatimModuleSyntax()\n console.debug('using existing tsconfig.json')\n}\nfor (const f of readdirSync('.tshy')) {\n unlinkSync(resolve('.tshy', f))\n}\nwriteConfig('build', build())\nif (dialects.includes('commonjs')) {\n writeConfig('commonjs', commonjs('cjs'))\n for (const d of commonjsDialects) {\n writeConfig(d, commonjs(d))\n }\n}\nif (dialects.includes('esm')) {\n writeConfig('esm', esm('esm'))\n for (const d of esmDialects) {\n writeConfig(d, esm(d))\n }\n}\n"]}
{"version":3,"file":"tsconfig.js","sourceRoot":"","sources":["../../src/tsconfig.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAA;AACnC,OAAO,EACL,UAAU,EACV,WAAW,EACX,UAAU,EACV,aAAa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,WAAW,CAAC,OAAO,CAAC,EAAE,CAAC;IACrC,UAAU,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,CAAA;AACjC,CAAC;AACD,WAAW,CAAC,OAAO,EAAE,KAAK,EAAE,CAAC,CAAA;AAC7B,IAAI,QAAQ,CAAC,QAAQ,CAAC,UAAU,CAAC,EAAE,CAAC;IAClC,WAAW,CAAC,UAAU,EAAE,QAAQ,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC,CAAA;IACpD,KAAK,MAAM,CAAC,IAAI,gBAAgB,EAAE,CAAC;QACjC,WAAW,CAAC,YAAY,CAAC,EAAE,EAAE,QAAQ,CAAC,CAAC,EAAE,YAAY,CAAC,EAAE,CAAC,CAAC,CAAA;IAC5D,CAAC;AACH,CAAC;AACD,IAAI,QAAQ,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;IAC7B,WAAW,CAAC,KAAK,EAAE,GAAG,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,CAAA;IACrC,KAAK,MAAM,CAAC,IAAI,WAAW,EAAE,CAAC;QAC5B,WAAW,CAAC,OAAO,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC,EAAE,OAAO,CAAC,EAAE,CAAC,CAAC,CAAA;IAC7C,CAAC;AACH,CAAC","sourcesContent":["import chalk from 'chalk'\nimport { mkdirpSync } from 'mkdirp'\nimport {\n existsSync,\n readdirSync,\n unlinkSync,\n writeFileSync,\n} from 'node:fs'\nimport { resolve } from 'node:path'\nimport { join } from 'node:path/posix'\nimport * as console from './console.js'\n\n// the commonjs build needs to exclude anything that will be polyfilled\nimport config from './config.js'\nimport polyfills from './polyfills.js'\nimport preventVerbatimModuleSyntax from './prevent-verbatim-module-syntax.js'\nimport readTypescriptConfig from './read-typescript-config.js'\n\nconst {\n dialects = ['esm', 'commonjs'],\n esmDialects = [],\n commonjsDialects = [],\n exclude = [],\n} = config\n\nconst relativeExclude = exclude.map(e => `../${e.replace(/^\\.\\//, '')}`)\n\nconst recommended: Record<string, unknown> = {\n compilerOptions: {\n types: ['node'],\n rootDir: './',\n declaration: true,\n declarationMap: true,\n esModuleInterop: true,\n forceConsistentCasingInFileNames: true,\n inlineSources: true,\n jsx: 'react',\n module: 'nodenext',\n moduleResolution: 'nodenext',\n noUncheckedIndexedAccess: true,\n resolveJsonModule: true,\n skipLibCheck: true,\n sourceMap: true,\n strict: true,\n target: 'es2022',\n },\n}\n\nconst build = (): Record<string, unknown> => ({\n extends:\n config.project === undefined ?\n '../tsconfig.json'\n : join('..', config.project),\n compilerOptions: {\n target:\n readTypescriptConfig().compilerOptions.target === undefined ?\n 'es2022'\n : undefined,\n rootDir: '../src',\n module: 'nodenext',\n moduleResolution: 'nodenext',\n },\n})\n\nconst commonjs = (\n dialect: string,\n dist: string,\n): Record<string, unknown> => {\n const exclude = [\n ...relativeExclude,\n '../src/**/*.mts',\n '../src/package.json',\n ]\n for (const pf of polyfills.values()) {\n if (pf.name === dialect && pf.type === 'commonjs') continue\n for (const f of pf.map.keys()) {\n exclude.push(`../${join(f)}`)\n }\n }\n console.error('excluded:', exclude)\n return {\n extends: './build.json',\n include: [\n '../src/**/*.ts',\n '../src/**/*.cts',\n '../src/**/*.tsx',\n '../src/**/*.json',\n ],\n exclude,\n compilerOptions: {\n outDir: '../.tshy-build/' + dist,\n },\n }\n}\n\nconst esm = (dialect: string, dist: string): Record<string, unknown> => {\n const exclude: string[] = [...relativeExclude, '../src/package.json']\n for (const pf of polyfills.values()) {\n if (pf.name === dialect && pf.type === 'esm') continue\n for (const f of pf.map.keys()) {\n exclude.push(`../${f.replace(/^\\.\\//, '')}`)\n }\n }\n return {\n extends: './build.json',\n include: [\n '../src/**/*.ts',\n '../src/**/*.mts',\n '../src/**/*.tsx',\n '../src/**/*.json',\n ],\n exclude,\n compilerOptions: {\n outDir: '../.tshy-build/' + dist,\n },\n }\n}\n\nmkdirpSync('.tshy')\nconst writeConfig = (name: string, data: Record<string, unknown>) =>\n writeFileSync(`.tshy/${name}.json`, JSON.stringify(data, null, 2) + '\\n')\n\nconsole.debug(chalk.cyan.dim('writing tsconfig files...'))\nif (config.project === undefined && !existsSync('tsconfig.json')) {\n console.debug('using recommended tsconfig.json')\n writeConfig('../tsconfig', recommended)\n} else {\n if (dialects.length > 1) preventVerbatimModuleSyntax()\n console.debug('using existing tsconfig.json')\n}\nfor (const f of readdirSync('.tshy')) {\n unlinkSync(resolve('.tshy', f))\n}\nwriteConfig('build', build())\nif (dialects.includes('commonjs')) {\n writeConfig('commonjs', commonjs('cjs', 'commonjs'))\n for (const d of commonjsDialects) {\n writeConfig(`commonjs-${d}`, commonjs(d, `commonjs/${d}`))\n }\n}\nif (dialects.includes('esm')) {\n writeConfig('esm', esm('esm', 'esm'))\n for (const d of esmDialects) {\n writeConfig(`esm-${d}`, esm(d, `esm/${d}`))\n }\n}\n"]}

@@ -1,1 +0,1 @@

{"version":3,"file":"valid-extra-dialects.d.ts","sourceRoot":"","sources":["../../src/valid-extra-dialects.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;;AAuC5C,wBA0CC","sourcesContent":["// validate esmDialects and commonjsDialects\nimport fail from './fail.js'\nimport type { TshyConfig } from './types.js'\n\nconst arrayOverlap = (\n a: string[] | undefined,\n b: string[] | undefined,\n): string | false => {\n if (!a || !b) return false\n for (const av of a) {\n if (b.includes(av)) return av\n }\n return false\n}\n\nconst validExtraDialectSet = (\n e: string[],\n which: 'commonjs' | 'esm' | 'source',\n) => {\n for (const d of e) {\n if (typeof d !== 'string') {\n fail(`${which} must be an array of strings, got: ${d}`)\n return process.exit(1)\n }\n if (\n d === 'commonjs' ||\n d === 'cjs' ||\n d === 'esm' ||\n d === 'require' ||\n d === 'import' ||\n d === 'node' ||\n d === 'source' ||\n d === 'default'\n ) {\n fail(`tshy.${which}Dialects must not contain ${JSON.stringify(d)}`)\n return process.exit(1)\n }\n }\n return true\n}\n\nexport default ({\n commonjsDialects,\n esmDialects,\n sourceDialects,\n}: TshyConfig) => {\n if (\n commonjsDialects === undefined &&\n esmDialects === undefined &&\n sourceDialects === undefined\n ) {\n return true\n }\n if (\n commonjsDialects &&\n !validExtraDialectSet(commonjsDialects, 'commonjs')\n ) {\n return false\n }\n if (esmDialects && !validExtraDialectSet(esmDialects, 'esm')) {\n return false\n }\n if (sourceDialects && !validExtraDialectSet(sourceDialects, 'source')) {\n return false\n }\n for (const [aname, bname, a, b] of [\n ['commonjsDialects', 'esmDialects', commonjsDialects, esmDialects],\n [\n 'commonjsDialects',\n 'sourceDialects',\n commonjsDialects,\n sourceDialects,\n ],\n ['esmDialects', 'sourceDialects', esmDialects, sourceDialects],\n ] as const) {\n const overlap = arrayOverlap(a, b)\n if (!overlap) continue\n fail(\n `${aname} and ${bname} must be unique, found ${overlap} in both lists`,\n )\n return process.exit(1)\n }\n return true\n}\n"]}
{"version":3,"file":"valid-extra-dialects.d.ts","sourceRoot":"","sources":["../../src/valid-extra-dialects.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;;AAmD5C,wBAqCC","sourcesContent":["// validate esmDialects and commonjsDialects\nimport { readdirSync } from 'node:fs'\nimport fail from './fail.js'\nimport type { TshyConfig } from './types.js'\n\nconst arrayOverlap = (\n a: string[] | undefined,\n b: string[] | undefined,\n): string | false => {\n if (!a || !b) return false\n for (const av of a) {\n if (b.includes(av)) return av\n }\n return false\n}\n\nconst validExtraDialectSet = (\n e: string[],\n which: 'commonjs' | 'esm' | 'source',\n) => {\n const srcContents = readdirSync('src')\n\n for (const d of e) {\n if (typeof d !== 'string') {\n fail(`tshy.${which}Dialects must be an array of strings, got: ${d}`)\n return process.exit(1)\n }\n if (srcContents.includes(d)) {\n fail(\n `tshy.${which}Dialects contains a src entry, not allowed: '${d}'`,\n )\n return process.exit(1)\n }\n if (d.includes('/') || d.includes('\\\\')) {\n fail(`tshy.${which}Dialects entries may not contain slashes: '${d}'`)\n return process.exit(1)\n }\n if (\n d === 'commonjs' ||\n d === 'cjs' ||\n d === 'esm' ||\n d === 'require' ||\n d === 'import' ||\n d === 'source' ||\n d === 'types' ||\n d === 'default'\n ) {\n fail(`tshy.${which}Dialects must not contain '${d}'`)\n return process.exit(1)\n }\n }\n return true\n}\n\nexport default ({\n commonjsDialects,\n esmDialects,\n sourceDialects,\n}: TshyConfig) => {\n if (\n commonjsDialects === undefined &&\n esmDialects === undefined &&\n sourceDialects === undefined\n ) {\n return true\n }\n if (\n commonjsDialects &&\n !validExtraDialectSet(commonjsDialects, 'commonjs')\n ) {\n return false\n }\n if (esmDialects && !validExtraDialectSet(esmDialects, 'esm')) {\n return false\n }\n if (sourceDialects && !validExtraDialectSet(sourceDialects, 'source')) {\n return false\n }\n const srcCjs = arrayOverlap(sourceDialects, commonjsDialects)\n if (srcCjs) {\n fail(\n `tshy.commonjsDialects overlap with tshy.sourceDialects: ${srcCjs}`,\n )\n return process.exit(1)\n }\n const srcEsm = arrayOverlap(sourceDialects, esmDialects)\n if (srcEsm) {\n fail(`tshy.esmDialects overlap with tshy.sourceDialects: ${srcEsm}`)\n return process.exit(1)\n }\n return true\n}\n"]}
// validate esmDialects and commonjsDialects
import { readdirSync } from 'node:fs';
import fail from './fail.js';

@@ -13,7 +14,16 @@ const arrayOverlap = (a, b) => {

const validExtraDialectSet = (e, which) => {
const srcContents = readdirSync('src');
for (const d of e) {
if (typeof d !== 'string') {
fail(`${which} must be an array of strings, got: ${d}`);
fail(`tshy.${which}Dialects must be an array of strings, got: ${d}`);
return process.exit(1);
}
if (srcContents.includes(d)) {
fail(`tshy.${which}Dialects contains a src entry, not allowed: '${d}'`);
return process.exit(1);
}
if (d.includes('/') || d.includes('\\')) {
fail(`tshy.${which}Dialects entries may not contain slashes: '${d}'`);
return process.exit(1);
}
if (d === 'commonjs' ||

@@ -24,6 +34,6 @@ d === 'cjs' ||

d === 'import' ||
d === 'node' ||
d === 'source' ||
d === 'types' ||
d === 'default') {
fail(`tshy.${which}Dialects must not contain ${JSON.stringify(d)}`);
fail(`tshy.${which}Dialects must not contain '${d}'`);
return process.exit(1);

@@ -50,20 +60,14 @@ }

}
for (const [aname, bname, a, b] of [
['commonjsDialects', 'esmDialects', commonjsDialects, esmDialects],
[
'commonjsDialects',
'sourceDialects',
commonjsDialects,
sourceDialects,
],
['esmDialects', 'sourceDialects', esmDialects, sourceDialects],
]) {
const overlap = arrayOverlap(a, b);
if (!overlap)
continue;
fail(`${aname} and ${bname} must be unique, found ${overlap} in both lists`);
const srcCjs = arrayOverlap(sourceDialects, commonjsDialects);
if (srcCjs) {
fail(`tshy.commonjsDialects overlap with tshy.sourceDialects: ${srcCjs}`);
return process.exit(1);
}
const srcEsm = arrayOverlap(sourceDialects, esmDialects);
if (srcEsm) {
fail(`tshy.esmDialects overlap with tshy.sourceDialects: ${srcEsm}`);
return process.exit(1);
}
return true;
};
//# sourceMappingURL=valid-extra-dialects.js.map

@@ -1,1 +0,1 @@

{"version":3,"file":"valid-extra-dialects.js","sourceRoot":"","sources":["../../src/valid-extra-dialects.ts"],"names":[],"mappings":"AAAA,4CAA4C;AAC5C,OAAO,IAAI,MAAM,WAAW,CAAA;AAG5B,MAAM,YAAY,GAAG,CACnB,CAAuB,EACvB,CAAuB,EACP,EAAE,CAAC;IACnB,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC;QAAE,OAAO,KAAK,CAAA;IAC1B,KAAK,MAAM,EAAE,IAAI,CAAC,EAAE,CAAC;QACnB,IAAI,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC;YAAE,OAAO,EAAE,CAAA;IAC/B,CAAC;IACD,OAAO,KAAK,CAAA;AAAA,CACb,CAAA;AAED,MAAM,oBAAoB,GAAG,CAC3B,CAAW,EACX,KAAoC,EACpC,EAAE,CAAC;IACH,KAAK,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC;QAClB,IAAI,OAAO,CAAC,KAAK,QAAQ,EAAE,CAAC;YAC1B,IAAI,CAAC,GAAG,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AClB,gBAAgB;YAChB,gBAAgB;YAChB,cAAc;SACf;QACD,CAAC,aAAa,EAAE,gBAAgB,EAAE,WAAW,EAAE,cAAc,CAAC;KACtD,EAAE,CAAC;QACX,MAAM,OAAO,GAAG,YAAY,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;QAClC,IAAI,CAAC,OAAO;YAAE,SAAQ;QACtB,IAAI,CACF,GAAG,KAAK,QAAQ,KAAK,0BAA0B,OAAO,gBAAgB,CACvE,CAAA;QACD,OAAO,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;IACxB,CAAC;IACD,OAAO,IAAI,CAAA;AAAA,CACZ,CAAA","sourcesContent":["// validate esmDialects and commonjsDialects\nimport fail from './fail.js'\nimport type { TshyConfig } from './types.js'\n\nconst arrayOverlap = (\n a: string[] | undefined,\n b: string[] | undefined,\n): string | false => {\n if (!a || !b) return false\n for (const av of a) {\n if (b.includes(av)) return av\n }\n return false\n}\n\nconst validExtraDialectSet = (\n e: string[],\n which: 'commonjs' | 'esm' | 'source',\n) => {\n for (const d of e) {\n if (typeof d !== 'string') {\n fail(`${which} must be an array of strings, got: ${d}`)\n return process.exit(1)\n }\n if (\n d === 'commonjs' ||\n d === 'cjs' ||\n d === 'esm' ||\n d === 'require' ||\n d === 'import' ||\n d === 'node' ||\n d === 'source' ||\n d === 'default'\n ) {\n fail(`tshy.${which}Dialects must not contain ${JSON.stringify(d)}`)\n return process.exit(1)\n }\n }\n return true\n}\n\nexport default ({\n commonjsDialects,\n esmDialects,\n sourceDialects,\n}: TshyConfig) => {\n if (\n commonjsDialects === undefined &&\n esmDialects === undefined &&\n sourceDialects === undefined\n ) {\n return true\n }\n if (\n commonjsDialects &&\n !validExtraDialectSet(commonjsDialects, 'commonjs')\n ) {\n return false\n }\n if (esmDialects && !validExtraDialectSet(esmDialects, 'esm')) {\n return false\n }\n if (sourceDialects && !validExtraDialectSet(sourceDialects, 'source')) {\n return false\n }\n for (const [aname, bname, a, b] of [\n ['commonjsDialects', 'esmDialects', commonjsDialects, esmDialects],\n [\n 'commonjsDialects',\n 'sourceDialects',\n commonjsDialects,\n sourceDialects,\n ],\n ['esmDialects', 'sourceDialects', esmDialects, sourceDialects],\n ] as const) {\n const overlap = arrayOverlap(a, b)\n if (!overlap) continue\n fail(\n `${aname} and ${bname} must be unique, found ${overlap} in both lists`,\n )\n return process.exit(1)\n }\n return true\n}\n"]}
{"version":3,"file":"valid-extra-dialects.js","sourceRoot":"","sources":["../../src/valid-extra-dialects.ts"],"names":[],"mappings":"AAAA,4CAA4C;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AACrC,OAAO,IAAI,MAAM,WAAW,CAAA;AAG5B,MAAM,YAAY,GAAG,CACnB,CAAuB,EACvB,CAAuB,EACP,EAAE,CAAC;IACnB,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC;QAAE,OAAO,KAAK,CAAA;IAC1B,KAAK,MAAM,EAAE,IAAI,CAAC,EAAE,CAAC;QACnB,IAAI,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC;YAAE,OAAO,EAAE,CAAA;IAC/B,CAAC;IACD,OAAO,KAAK,CAAA;AAAA,CACb,CAAA;AAED,MAAM,oBAAoB,GAAG,CAC3B,CAAW,EACX,KAAoC,EACpC,EAAE,CAAC;IACH,MAAM,WAAW,GAAG,WAAW,CAAC,KAAK,CAAC,CAAA;IAEtC,KAAK,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC;QAClB,IAAI,OAAO,CAAC,KAAK,QAAQ,EAAE,CAAC;YAC1B,IAAI,CAAC,QAAQ,KAAK,8CAA8C,CAAC,EAAE,CAAC,CAAA;YACpE,OAAO,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;QACxB,CAAC;QACD,IAAI,WAAW,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC;YAC5B,IAAI,CACF,QAAQ,KAAK,gDAAgD,CAAC,GAAG,CAClE,CAAA;YACD,OAAO,OAAO,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GAAG,YAAY,CAAC,cAAc,EAAE,gBAAgB,CAAC,CAAA;IAC7D,IAAI,MAAM,EAAE,CAAC;QACX,IAAI,CACF,2DAA2D,MAAM,EAAE,CACpE,CAAA;QACD,OAAO,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;IACxB,CAAC;IACD,MAAM,MAAM,GAAG,YAAY,CAAC,cAAc,EAAE,WAAW,CAAC,CAAA;IACxD,IAAI,MAAM,EAAE,CAAC;QACX,IAAI,CAAC,sDAAsD,MAAM,EAAE,CAAC,CAAA;QACpE,OAAO,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;IACxB,CAAC;IACD,OAAO,IAAI,CAAA;AAAA,CACZ,CAAA","sourcesContent":["// validate esmDialects and commonjsDialects\nimport { readdirSync } from 'node:fs'\nimport fail from './fail.js'\nimport type { TshyConfig } from './types.js'\n\nconst arrayOverlap = (\n a: string[] | undefined,\n b: string[] | undefined,\n): string | false => {\n if (!a || !b) return false\n for (const av of a) {\n if (b.includes(av)) return av\n }\n return false\n}\n\nconst validExtraDialectSet = (\n e: string[],\n which: 'commonjs' | 'esm' | 'source',\n) => {\n const srcContents = readdirSync('src')\n\n for (const d of e) {\n if (typeof d !== 'string') {\n fail(`tshy.${which}Dialects must be an array of strings, got: ${d}`)\n return process.exit(1)\n }\n if (srcContents.includes(d)) {\n fail(\n `tshy.${which}Dialects contains a src entry, not allowed: '${d}'`,\n )\n return process.exit(1)\n }\n if (d.includes('/') || d.includes('\\\\')) {\n fail(`tshy.${which}Dialects entries may not contain slashes: '${d}'`)\n return process.exit(1)\n }\n if (\n d === 'commonjs' ||\n d === 'cjs' ||\n d === 'esm' ||\n d === 'require' ||\n d === 'import' ||\n d === 'source' ||\n d === 'types' ||\n d === 'default'\n ) {\n fail(`tshy.${which}Dialects must not contain '${d}'`)\n return process.exit(1)\n }\n }\n return true\n}\n\nexport default ({\n commonjsDialects,\n esmDialects,\n sourceDialects,\n}: TshyConfig) => {\n if (\n commonjsDialects === undefined &&\n esmDialects === undefined &&\n sourceDialects === undefined\n ) {\n return true\n }\n if (\n commonjsDialects &&\n !validExtraDialectSet(commonjsDialects, 'commonjs')\n ) {\n return false\n }\n if (esmDialects && !validExtraDialectSet(esmDialects, 'esm')) {\n return false\n }\n if (sourceDialects && !validExtraDialectSet(sourceDialects, 'source')) {\n return false\n }\n const srcCjs = arrayOverlap(sourceDialects, commonjsDialects)\n if (srcCjs) {\n fail(\n `tshy.commonjsDialects overlap with tshy.sourceDialects: ${srcCjs}`,\n )\n return process.exit(1)\n }\n const srcEsm = arrayOverlap(sourceDialects, esmDialects)\n if (srcEsm) {\n fail(`tshy.esmDialects overlap with tshy.sourceDialects: ${srcEsm}`)\n return process.exit(1)\n }\n return true\n}\n"]}
{
"name": "tshy",
"version": "4.0.0",
"version": "4.1.0",
"description": "TypeScript HYbridizer - Hybrid (CommonJS/ESM) TypeScript node package builder",

@@ -5,0 +5,0 @@ "author": "Isaac Z. Schlueter <i@izs.me> (https://izs.me)",

+24
-50

@@ -14,7 +14,8 @@ # tshy - TypeScript HYbridizer

>
> ## Upgrading from v3 to v4
> ## Upgrading from v3 to v4 and v5
>
> Version 4 switches from TypeScript 5 to TypeScript 6. (Note: you
> can already preview TypeScript 7 by setting `"compiler": "tsgo"`
> in your tshy options.)
> Version 4 switches from TypeScript 5 to TypeScript 6 by
> default. (Note: you can already preview TypeScript 7 by setting
> `"compiler": "tsgo"` in your tshy options, or any other version
> by specify `typescript` as a `devDependency` in your project.)
>

@@ -284,2 +285,6 @@ > This may cause problems upgrading, because tshy will only

### How to Configure Tshy
Set options in the `tshy` field in `package.json`.
### `exports`

@@ -775,3 +780,5 @@

depending on whether you want them to be built as CommonJS or
ESM.
ESM. As of version 4.1, it is possible to have a dialect in both
types, and it'll build to both `dist/commonjs/${name}` and
`dist/esm/${name}`, as appropriate.

@@ -802,15 +809,7 @@ Note that each added dialect you create will result in another

".": {
"deno": {
"types": "./dist/deno/index.d.ts",
"default": "./dist/deno/index.js"
},
"browser": {
"types": "./dist/browser/index.d.ts",
"default": "./dist/browser/index.js"
},
"webpack": {
"types": "./dist/webpack/index.d.ts",
"default": "./dist/webpack/index.js"
},
"require": {
"webpack": {
"types": "./dist/commonjs/webpack/index.d.ts",
"default": "./dist/commonjs/webpack/index.js"
},
"types": "./dist/commonjs/index.d.ts",

@@ -820,2 +819,10 @@ "default": "./dist/commonjs/index.js"

"import": {
"deno": {
"types": "./dist/esm/deno/index.d.ts",
"default": "./dist/esm/deno/index.js"
},
"browser": {
"types": "./dist/esm/browser/index.d.ts",
"default": "./dist/esm/browser/index.js"
},
"types": "./dist/esm/index.d.ts",

@@ -846,35 +853,2 @@ "default": "./dist/esm/index.js"

If dialect overrides are used, then the `"source"` export
condition will refer to the original source for the override. For
example:
```json
{
"exports": {
".": {
"deno": {
"types": "./dist/deno/index.d.ts",
"default": "./dist/deno/index.js"
},
"browser": {
"types": "./dist/browser/index.d.ts",
"default": "./dist/browser/index.js"
},
"webpack": {
"types": "./dist/webpack/index.d.ts",
"default": "./dist/webpack/index.js"
},
"require": {
"types": "./dist/commonjs/index.d.ts",
"default": "./dist/commonjs/index.js"
},
"import": {
"types": "./dist/esm/index.d.ts",
"default": "./dist/esm/index.js"
}
}
}
}
```
Note that the `commonjs` override uses the abbreviated `cjs`

@@ -881,0 +855,0 @@ name (historical reasons, it was originally the only override

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display