tshy 4.0.0 → 4.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
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"]}
1
+ {"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"]}
@@ -9,24 +9,34 @@ import polyfills from './polyfills.js';
9
9
  import setFolderDialect from './set-folder-dialect.js';
10
10
  import './tsconfig.js';
11
11
  import tsc from './which-tsc.js';
12
+ import { mkdirSync } from 'node:fs';
12
13
  const node = process.execPath;
13
14
  const { commonjsDialects = [] } = config;
14
15
  export const buildCommonJS = () => {
15
16
  setFolderDialect('src', 'commonjs');
16
17
  for (const d of ['commonjs', ...commonjsDialects]) {
17
- const pf = polyfills.get(d === 'commonjs' ? 'cjs' : d);
18
- console.debug(chalk.cyan.dim('building ' + d));
19
- const res = spawnSync(node, [tsc, '-p', `.tshy/${d}.json`], {
18
+ const pfn = d === 'commonjs' ? 'cjs' : `commonjs-${d}`;
19
+ const pf = polyfills.get(pfn);
20
+ const cfg = d === 'commonjs' ? 'commonjs' : `commonjs-${d}`;
21
+ console.debug(chalk.cyan.dim('building ' + cfg), [
22
+ node,
23
+ [tsc, '-p', `.tshy/${cfg}.json`],
24
+ {
25
+ stdio: 'inherit',
26
+ },
27
+ ]);
28
+ const res = spawnSync(node, [tsc, '-p', `.tshy/${cfg}.json`], {
20
29
  stdio: 'inherit',
21
30
  });
22
31
  if (res.status || res.signal) {
23
32
  setFolderDialect('src');
24
33
  return buildFail(res);
25
34
  }
26
- setFolderDialect('.tshy-build/' + d, 'commonjs');
35
+ const dist = d === 'commonjs' ? d : `commonjs/${d}`;
36
+ mkdirSync(`.tshy-build/${dist}`, { recursive: true });
27
37
  for (const [override, orig] of pf?.map.entries() ?? []) {
28
- const stemFrom = resolve(`.tshy-build/${d}`, relative(resolve('src'), resolve(override))).replace(/\.cts$/, '');
29
- const stemTo = resolve(`.tshy-build/${d}`, relative(resolve('src'), resolve(orig))).replace(/\.tsx?$/, '');
38
+ const stemFrom = resolve(`.tshy-build/${dist}`, relative(resolve('src'), resolve(override))).replace(/\.cts$/, '');
39
+ const stemTo = resolve(`.tshy-build/${dist}`, relative(resolve('src'), resolve(orig))).replace(/\.tsx?$/, '');
30
40
  const stemToPath = `${stemTo}.js.map`;
31
41
  const stemToDtsPath = `${stemTo}.d.ts.map`;
32
42
  ifExist.unlink(stemToPath);
@@ -34,7 +44,8 @@ export const buildCommonJS = () => {
34
44
  ifExist.rename(`${stemFrom}.cjs`, `${stemTo}.js`);
35
45
  ifExist.rename(`${stemFrom}.d.cts`, `${stemTo}.d.ts`);
36
46
  }
37
- console.error(chalk.cyan.bold('built commonjs'));
47
+ setFolderDialect('.tshy-build/commonjs', 'commonjs');
48
+ console.error(chalk.cyan.bold('built ' + dist));
38
49
  }
39
50
  setFolderDialect('src');
40
51
  };
@@ -1 +1 @@
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,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M,UAAU,GAAG,GAAG,MAAM,SAAS,CAAA;YACrC,MAAM,aAAa,GAAG,GAAG,MAAM,WAAW,CAAA;YAC1C,OAAO,CAAC,MAAM,CAAC,UAAU,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,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"]}
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;AAChC,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AAEnC,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,GAAG,GAAG,CAAC,KAAK,UAAU,CAAC,CAAC,CAAC,KAAK,CAA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E,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,MAAM,UAAU,GAAG,GAAG,MAAM,SAAS,CAAA;YACrC,MAAM,aAAa,GAAG,GAAG,MAAM,WAAW,CAAA;YAC1C,OAAO,CAAC,MAAM,CAAC,UAAU,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 @@
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"]}
1
+ {"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"]}
@@ -9,30 +9,34 @@ import polyfills from './polyfills.js';
9
9
  import setFolderDialect from './set-folder-dialect.js';
10
10
  import './tsconfig.js';
11
11
  import tsc from './which-tsc.js';
12
+ import { mkdirSync } from 'node:fs';
12
13
  const node = process.execPath;
13
14
  const { esmDialects = [] } = config;
14
15
  export const buildESM = () => {
15
16
  setFolderDialect('src', 'esm');
16
17
  for (const d of ['esm', ...esmDialects]) {
17
- const pf = polyfills.get(d);
18
- console.debug(chalk.cyan.dim('building ' + d));
19
- const res = spawnSync(node, [tsc, '-p', `.tshy/${d}.json`], {
18
+ const pfn = d === 'esm' ? d : `esm-${d}`;
19
+ const pf = polyfills.get(pfn);
20
+ console.debug(chalk.cyan.dim('building ' + pfn));
21
+ const res = spawnSync(node, [tsc, '-p', `.tshy/${pfn}.json`], {
20
22
  stdio: 'inherit',
21
23
  });
22
24
  if (res.status || res.signal) {
23
25
  setFolderDialect('src');
24
26
  return buildFail(res);
25
27
  }
26
- setFolderDialect('.tshy-build/' + d, 'esm');
28
+ const dist = d === 'esm' ? d : `esm/${d}`;
29
+ mkdirSync(`.tshy-build/${dist}`, { recursive: true });
27
30
  for (const [override, orig] of pf?.map.entries() ?? []) {
28
- const stemFrom = resolve(`.tshy-build/${d}`, relative(resolve('src'), resolve(override))).replace(/\.mts$/, '');
29
- const stemTo = resolve(`.tshy-build/${d}`, relative(resolve('src'), resolve(orig))).replace(/\.tsx?$/, '');
31
+ const stemFrom = resolve(`.tshy-build/${dist}`, relative(resolve('src'), resolve(override))).replace(/\.mts$/, '');
32
+ const stemTo = resolve(`.tshy-build/${dist}`, relative(resolve('src'), resolve(orig))).replace(/\.tsx?$/, '');
30
33
  ifExist.unlink(`${stemTo}.js.map`);
31
34
  ifExist.unlink(`${stemTo}.d.ts.map`);
32
35
  ifExist.rename(`${stemFrom}.mjs`, `${stemTo}.js`);
33
36
  ifExist.rename(`${stemFrom}.d.mts`, `${stemTo}.d.ts`);
34
37
  }
35
- console.error(chalk.cyan.bold('built ' + d));
38
+ setFolderDialect('.tshy-build/esm', 'esm');
39
+ console.error(chalk.cyan.bold('built ' + dist));
36
40
  }
37
41
  setFolderDialect('src');
38
42
  };
@@ -1 +1 @@
1
- {"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,MAAM,yBAAyB,CAAA;AACtD,OAAO,eAAe,CAAA;AACtB,OAAO,GAAG,MAAM,gBAAgB,CAAA;AAEhC,MAAM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AAC,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"]}
1
+ {"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,MAAM,yBAAyB,CAAA;AACtD,OAAO,eAAe,CAAA;AACtB,OAAO,GAAG,MAAM,gBAAgB,CAAA;AAChC,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AAEnC,MAAM,IAAI,GAAG,OAAO,CAAC,QAAQ,CAAA;AAC7B,MAAM,EAAE,WAAW,GAAG,EAAE,EAAE,GAAG,MAAM,CAAA;AAEnC,MAAM,CAAC,MAAM,QAAQ,GAAG,GAAG,EAAE,CAAC;IAC5B,gBAAgB,CAAC,KAAK,EAAE,KAAK,CAAC,CAAA;IAC9B,KAAK,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,GAAG,WAAW,CAAC,EAAE,CAAC;QACxC,MAAM,GAAG,GAAG,CAAC,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,EAAE,CAAA;QACxC,MAA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AC,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 @@
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"]}
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,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"]}
@@ -13,18 +13,19 @@ const { commonjsDialects = [] } = config;
13
13
  // don't actually do a build, just link files into places.
14
14
  export const buildLiveCommonJS = () => {
15
15
  for (const d of ['commonjs', ...commonjsDialects]) {
16
- const pf = polyfills.get(d === 'commonjs' ? 'cjs' : d);
17
- console.debug(chalk.cyan.dim('linking ' + d));
16
+ const pfn = d === 'commonjs' ? 'cjs' : `commonjs-${d}`;
17
+ const dist = d === 'commonjs' ? 'commonjs' : `commonjs/${d}`;
18
+ const pf = polyfills.get(pfn);
19
+ console.debug(chalk.cyan.dim('linking ' + dist));
18
20
  for (const s of sources) {
19
21
  const source = s.substring('./src/'.length);
20
- const target = resolve(`.tshy-build/${d}/${source}`);
22
+ const target = resolve(`.tshy-build/${dist}/${source}`);
21
23
  mkdirSync(dirname(target), { recursive: true });
22
24
  linkSync(s, target);
23
25
  }
24
- setFolderDialect('.tshy-build/' + d, 'commonjs');
25
26
  for (const [override, orig] of pf?.map.entries() ?? []) {
26
- const stemFrom = resolve(`.tshy-build/${d}`, relative(resolve('src'), resolve(override))).replace(/\.cts$/, '');
27
- const stemTo = resolve(`.tshy-build/${d}`, relative(resolve('src'), resolve(orig))).replace(/\.tsx?$/, '');
27
+ const stemFrom = resolve(`.tshy-build/${dist}`, relative(resolve('src'), resolve(override))).replace(/\.cts$/, '');
28
+ const stemTo = resolve(`.tshy-build/${dist}`, relative(resolve('src'), resolve(orig))).replace(/\.tsx?$/, '');
28
29
  ifExist.unlink(`${stemTo}.js.map`);
29
30
  ifExist.unlink(`${stemTo}.d.ts.map`);
30
31
  ifExist.rename(`${stemFrom}.cjs`, `${stemTo}.js`);
@@ -32,5 +33,6 @@ export const buildLiveCommonJS = () => {
32
33
  }
33
34
  console.error(chalk.cyan.bold('linked commonjs'));
34
35
  }
36
+ setFolderDialect('.tshy-build/commonjs', 'commonjs');
35
37
  };
36
38
  //# sourceMappingURL=build-live-commonjs.js.map
@@ -1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C,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,UAAU,CAAC,CAAA;QAChD,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,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"]}
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,MAA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,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 @@
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"]}
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,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"]}
@@ -11,18 +11,19 @@ import './tsconfig.js';
11
11
  const { esmDialects = [] } = config;
12
12
  export const buildLiveESM = () => {
13
13
  for (const d of ['esm', ...esmDialects]) {
14
- const pf = polyfills.get(d);
15
- console.debug(chalk.cyan.dim('linking ' + d));
14
+ const pfn = d === 'esm' ? 'esm' : `esm-${d}`;
15
+ const dist = d === 'esm' ? 'esm' : `esm/${d}`;
16
+ const pf = polyfills.get(pfn);
17
+ console.debug(chalk.cyan.dim('linking ' + dist));
16
18
  for (const s of sources) {
17
19
  const source = s.substring('./src/'.length);
18
- const target = resolve(`.tshy-build/${d}/${source}`);
20
+ const target = resolve(`.tshy-build/${dist}/${source}`);
19
21
  mkdirSync(dirname(target), { recursive: true });
20
22
  linkSync(s, target);
21
23
  }
22
- setFolderDialect('.tshy-build/' + d, 'esm');
23
24
  for (const [override, orig] of pf?.map.entries() ?? []) {
24
- const stemFrom = resolve(`.tshy-build/${d}`, relative(resolve('src'), resolve(override))).replace(/\.mts$/, '');
25
- const stemTo = resolve(`.tshy-build/${d}`, relative(resolve('src'), resolve(orig))).replace(/\.tsx?$/, '');
25
+ const stemFrom = resolve(`.tshy-build/${dist}`, relative(resolve('src'), resolve(override))).replace(/\.mts$/, '');
26
+ const stemTo = resolve(`.tshy-build/${dist}`, relative(resolve('src'), resolve(orig))).replace(/\.tsx?$/, '');
26
27
  ifExist.unlink(`${stemTo}.js.map`);
27
28
  ifExist.unlink(`${stemTo}.d.ts.map`);
28
29
  ifExist.rename(`${stemFrom}.mjs`, `${stemTo}.js`);
@@ -30,5 +31,6 @@ export const buildLiveESM = () => {
30
31
  }
31
32
  console.error(chalk.cyan.bold('linked ' + d));
32
33
  }
34
+ setFolderDialect('.tshy-build/esm', 'esm');
33
35
  };
34
36
  //# sourceMappingURL=build-live-esm.js.map
@@ -1 +1 @@
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"]}
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,E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AA;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,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 @@
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"]}
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\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,7 +1,7 @@
1
1
  // only print the logs if it fails, or if TSHY_VERBOSE is set
2
2
  //oxlint-disable no-console
3
3
  //oxlint-disable no-explicit-any
4
- let verbose = parseInt(process.env.TSHY_VERBOSE || '0');
4
+ const verbose = parseInt(process.env.TSHY_VERBOSE || '0');
5
5
  const errors = [];
6
6
  export const error = (...a) => {
7
7
  if (verbose >= 1)
@@ -1 +1 @@
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"]}
1
+ {"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 @@
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"]}
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;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"]}
@@ -20,8 +20,11 @@ const getTargetForDialectCondition = (s, dialect, condition, type, polyfills = n
20
20
  const pf = dialect === 'commonjs' ? 'cjs' : dialect;
21
21
  const rel = relative(resolve('./src'), resolve(polyfills.get(pf)?.map.get(s) ?? s));
22
22
  const target = liveDev ? rel : rel.replace(/\.([mc]?)tsx?$/, '.$1js');
23
+ const dt = dialect === 'commonjs' || dialect === 'esm' ?
24
+ dialect
25
+ : `${type}/${dialect}`;
23
26
  return (!s || !s.startsWith('./src/') ? s
24
- : dialects.includes(type) ? `./dist/${dialect}/${target}`
27
+ : dialects.includes(type) ? `./dist/${dt}/${target}`
25
28
  : undefined);
26
29
  }
27
30
  return resolveExport(s, [condition]);
@@ -57,76 +60,58 @@ const getExports = (c, pkgType) => {
57
60
  const exp = (e[sub] = {});
58
61
  if (impTarget) {
59
62
  for (const d of esmDialects) {
60
- const source = s && (polyfills.get(d)?.map.get(s) ?? s);
63
+ const source = s && (polyfills.get('esm-' + d)?.rmap.get(s) ?? s);
61
64
  const target = getTargetForDialectCondition(s, d, d, 'esm', polyfills);
62
65
  if (target) {
63
- exp[d] =
64
- liveDev ?
65
- {
66
- ...(pkgType === 'commonjs' ?
67
- getSourceDialects(source, c)
68
- : {}),
69
- default: target,
70
- }
71
- : {
72
- ...(pkgType === 'commonjs' ?
73
- getSourceDialects(source, c)
74
- : {}),
75
- types: target.replace(/\.js$/, '.d.ts'),
76
- default: target,
77
- };
66
+ const imp = (exp.import ??= {});
67
+ const src = pkgType === 'module' || source.endsWith('.mts') ?
68
+ getSourceDialects(source, c)
69
+ : undefined;
70
+ const types = liveDev ? undefined : ({ types: target.replace(/\.js$/, '.d.ts') });
71
+ imp[d] = { ...src, ...types, default: target };
78
72
  }
79
73
  }
80
74
  }
81
75
  if (reqTarget) {
82
76
  for (const d of commonjsDialects) {
83
- const source = s && (polyfills.get(d)?.map.get(s) ?? s);
77
+ const source = s && (polyfills.get('commonjs-' + d)?.rmap.get(s) ?? s);
84
78
  const target = getTargetForDialectCondition(s, d, d, 'commonjs', polyfills);
85
79
  if (target) {
86
- exp[d] =
87
- liveDev ?
88
- {
89
- ...(pkgType === 'module' ?
90
- getSourceDialects(source, c)
91
- : {}),
92
- default: target,
93
- }
94
- : {
95
- ...(pkgType === 'module' ?
96
- getSourceDialects(source, c)
97
- : {}),
98
- types: target.replace(/\.js$/, '.d.ts'),
99
- default: target,
100
- };
80
+ const req = (exp.require ??= {});
81
+ const src = pkgType === 'commonjs' || source.endsWith('.cts') ?
82
+ getSourceDialects(source, c)
83
+ : undefined;
84
+ const types = liveDev ? undefined : ({ types: target.replace(/\.js$/, '.d.ts') });
85
+ req[d] = { ...src, ...types, default: target };
101
86
  }
102
87
  }
103
88
  }
104
89
  // put the default import/require after all the other special ones.
105
90
  if (impTarget) {
106
- exp.import =
107
- liveDev ?
108
- {
109
- ...(pkgType === 'module' ? getSourceDialects(s, c) : {}),
110
- default: impTarget,
111
- }
112
- : {
113
- ...(pkgType === 'module' ? getSourceDialects(s, c) : {}),
114
- types: impTarget.replace(/\.(m?)js$/, '.d.$1ts'),
115
- default: impTarget,
116
- };
91
+ const source = s && (polyfills.get('esm')?.rmap.get(s) ?? s);
92
+ const src = pkgType === 'module' || source.endsWith('.mts') ?
93
+ getSourceDialects(source, c)
94
+ : undefined;
95
+ const types = liveDev ? undefined : ({ types: impTarget.replace(/\.(m?)js$/, '.d.$1ts') });
96
+ exp.import = {
97
+ ...exp.import,
98
+ ...src,
99
+ ...types,
100
+ default: impTarget,
101
+ };
117
102
  }
118
103
  if (reqTarget) {
119
- exp.require =
120
- liveDev ?
121
- {
122
- ...(pkgType === 'commonjs' ? getSourceDialects(s, c) : {}),
123
- default: reqTarget,
124
- }
125
- : {
126
- ...(pkgType === 'commonjs' ? getSourceDialects(s, c) : {}),
127
- types: reqTarget.replace(/\.(c?)js$/, '.d.$1ts'),
128
- default: reqTarget,
129
- };
104
+ const source = s && (polyfills.get('cjs')?.rmap.get(s) ?? s);
105
+ const src = pkgType === 'commonjs' || source.endsWith('.cts') ?
106
+ getSourceDialects(source, c)
107
+ : undefined;
108
+ const types = liveDev ? undefined : ({ types: reqTarget.replace(/\.(c?)js$/, '.d.$1ts') });
109
+ exp.require = {
110
+ ...exp.require,
111
+ ...src,
112
+ ...types,
113
+ default: reqTarget,
114
+ };
130
115
  }
131
116
  }
132
117
  return e;
@@ -134,12 +119,12 @@ const getExports = (c, pkgType) => {
134
119
  const getSourceDialects = (source, c) => {
135
120
  const { sourceDialects } = c;
136
121
  if (!sourceDialects)
137
- return {};
122
+ return undefined;
138
123
  return Object.fromEntries(sourceDialects.map(s => [s, source]));
139
124
  };
140
125
  export const setMain = (c, pkg) => {
141
126
  pkg.type = pkg.type === 'commonjs' ? 'commonjs' : 'module';
142
- const mod = resolveExport(pkg.exports['.'], ['require']);
127
+ const mod = resolveExport(pkg.exports['.'], ['require', 'default']);
143
128
  const main = c?.main ?? !!mod;
144
129
  if (main) {
145
130
  if (!mod) {
@@ -160,7 +145,7 @@ export const setMain = (c, pkg) => {
160
145
  delete pkg.types;
161
146
  }
162
147
  // Set the package module to exports["."]
163
- const importMod = resolveExport(pkg.exports['.'], ['import']);
148
+ const importMod = resolveExport(pkg.exports['.'], ['import', 'default']);
164
149
  const module = c?.module ?? !!importMod;
165
150
  if (module) {
166
151
  if (!importMod) {