tshy 1.13.1 → 1.14.1
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.
- package/README.md +71 -4
- package/dist/esm/build-commonjs.d.ts.map +1 -1
- package/dist/esm/build-commonjs.js +5 -7
- package/dist/esm/build-commonjs.js.map +1 -1
- package/dist/esm/build-esm.js +5 -5
- package/dist/esm/build-esm.js.map +1 -1
- package/dist/esm/config.d.ts.map +1 -1
- package/dist/esm/config.js +63 -15
- package/dist/esm/config.js.map +1 -1
- package/dist/esm/exports.d.ts +0 -1
- package/dist/esm/exports.d.ts.map +1 -1
- package/dist/esm/if-exist.d.ts +6 -0
- package/dist/esm/if-exist.d.ts.map +1 -0
- package/dist/esm/if-exist.js +8 -0
- package/dist/esm/if-exist.js.map +1 -0
- package/dist/esm/types.d.ts +6 -3
- package/dist/esm/types.d.ts.map +1 -1
- package/dist/esm/types.js.map +1 -1
- package/dist/esm/valid-exports.d.ts +1 -1
- package/dist/esm/write-package.d.ts.map +1 -1
- package/dist/esm/write-package.js.map +1 -1
- package/package.json +8 -7
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@ Hybrid (CommonJS/ESM) TypeScript node package builder. Write
|
|
|
4
4
|
modules that Just Work in ESM and CommonJS, in easy mode.
|
|
5
5
|
|
|
6
6
|
This tool manages the `exports` in your package.json file, and
|
|
7
|
-
builds your TypeScript program using `tsc` 5.2
|
|
7
|
+
builds your TypeScript program using `tsc` 5.2+, emitting both ESM
|
|
8
8
|
and CommonJS variants, [providing the full strength of
|
|
9
9
|
TypeScript’s checking for both output
|
|
10
10
|
formats](https://twitter.com/atcb/status/1702069237710479608).
|
|
@@ -50,7 +50,7 @@ Consider this contrived example:
|
|
|
50
50
|
// import the class from ESM
|
|
51
51
|
import { SomeClass } from 'module-built-by-tshy'
|
|
52
52
|
import { createRequire } from 'node:module'
|
|
53
|
-
const
|
|
53
|
+
const require = createRequire(import.meta.url)
|
|
54
54
|
|
|
55
55
|
// create an object using the commonjs version
|
|
56
56
|
function getObject() {
|
|
@@ -314,6 +314,73 @@ just be passed through as-is.
|
|
|
314
314
|
}
|
|
315
315
|
```
|
|
316
316
|
|
|
317
|
+
### Glob Exports
|
|
318
|
+
|
|
319
|
+
You can also specify one or more [glob](http://npm.im/glob)
|
|
320
|
+
patterns to define your exported modules. This is handy if you
|
|
321
|
+
want to export several things as subpath exports to avoid "bucket
|
|
322
|
+
modules".
|
|
323
|
+
|
|
324
|
+
Anything named `src/index.*` that is matched in this way will be
|
|
325
|
+
used as the main `"."` export. Anything else will have the
|
|
326
|
+
`./src` stripped from the front, and the file extension removed
|
|
327
|
+
from the end. `./package.json` will always be exported, and any
|
|
328
|
+
pattern matches outside of the `./src` folder will be ignored.
|
|
329
|
+
|
|
330
|
+
```json
|
|
331
|
+
{
|
|
332
|
+
"tshy": {
|
|
333
|
+
"exports": "./src/**"
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
```
|
|
337
|
+
|
|
338
|
+
If you use this config, and you have files at `./src/index.ts`
|
|
339
|
+
and `./src/component/foo.tsx`, then the resulting exports will
|
|
340
|
+
be:
|
|
341
|
+
|
|
342
|
+
```json
|
|
343
|
+
{
|
|
344
|
+
"exports": {
|
|
345
|
+
".": {
|
|
346
|
+
"require": {
|
|
347
|
+
"types": "./dist/commonjs/index.d.ts",
|
|
348
|
+
"default": "./dist/commonjs/index.js"
|
|
349
|
+
},
|
|
350
|
+
"import": {
|
|
351
|
+
"types": "./dist/esm/index.d.ts",
|
|
352
|
+
"default": "./dist/esm/index.js"
|
|
353
|
+
}
|
|
354
|
+
},
|
|
355
|
+
"./component/foo": {
|
|
356
|
+
"require": {
|
|
357
|
+
"types": "./dist/commonjs/component/foo.d.ts",
|
|
358
|
+
"default": "./dist/commonjs/component/foo.js"
|
|
359
|
+
},
|
|
360
|
+
"import": {
|
|
361
|
+
"types": "./dist/esm/component/foo.d.ts",
|
|
362
|
+
"default": "./dist/esm/component/foo.js"
|
|
363
|
+
}
|
|
364
|
+
},
|
|
365
|
+
"./package.json": "./package.json"
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
```
|
|
369
|
+
|
|
370
|
+
You may also specify an array of glob exports, like so:
|
|
371
|
+
|
|
372
|
+
```json
|
|
373
|
+
{
|
|
374
|
+
"tshy": {
|
|
375
|
+
"exports": ["./src/*.ts", "./src/utils/*.ts"]
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
```
|
|
379
|
+
|
|
380
|
+
This would export a file at `./src/foo.ts` as `./foo`, and a file
|
|
381
|
+
at `./src/utils/bar.ts` as `./utils/bar`, but would ignore a file
|
|
382
|
+
at `./internal/private.ts`.
|
|
383
|
+
|
|
317
384
|
### Package `#imports`
|
|
318
385
|
|
|
319
386
|
You can use `"imports"` in your package.json, and it will be
|
|
@@ -572,7 +639,7 @@ in `src/<whatever>.ts` and the CommonJS polyfill living in
|
|
|
572
639
|
|
|
573
640
|
If you want to keep some files from being processed by tshy's
|
|
574
641
|
builds entirely, you can add an `exclude` `string[]` field to the
|
|
575
|
-
`tshy` object in `package.json`.
|
|
642
|
+
`tshy` object in `package.json`. For example:
|
|
576
643
|
|
|
577
644
|
```json
|
|
578
645
|
{
|
|
@@ -721,7 +788,7 @@ tsconfig file. This is often useful when you have multiple
|
|
|
721
788
|
`typescript-eslint`, specifying `"noEmit": true` and
|
|
722
789
|
`"include": ["**/*.ts"]`
|
|
723
790
|
- A `tsconfig.build.json` for compilation, with `"noEmit":
|
|
724
|
-
|
|
791
|
+
false`. Note that the [caveats](#tsconfigs) above still apply.
|
|
725
792
|
|
|
726
793
|
```json
|
|
727
794
|
{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build-commonjs.d.ts","sourceRoot":"","sources":["../../src/build-commonjs.ts"],"names":[],"mappings":"AASA,OAAO,eAAe,CAAA;
|
|
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"}
|
|
@@ -1,18 +1,16 @@
|
|
|
1
1
|
import chalk from 'chalk';
|
|
2
2
|
import { spawnSync } from 'node:child_process';
|
|
3
|
-
import { existsSync, renameSync, unlinkSync } from 'node:fs';
|
|
4
3
|
import { relative, resolve } from 'node:path/posix';
|
|
5
4
|
import buildFail from './build-fail.js';
|
|
6
5
|
import config from './config.js';
|
|
7
6
|
import * as console from './console.js';
|
|
7
|
+
import ifExist from './if-exist.js';
|
|
8
8
|
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
12
|
const node = process.execPath;
|
|
13
13
|
const { commonjsDialects = [] } = config;
|
|
14
|
-
const unlinkIfExist = (f) => existsSync(f) && unlinkSync(f);
|
|
15
|
-
const renameIfExist = (f, to) => existsSync(f) && renameSync(f, to);
|
|
16
14
|
export const buildCommonJS = () => {
|
|
17
15
|
setFolderDialect('src', 'commonjs');
|
|
18
16
|
for (const d of ['commonjs', ...commonjsDialects]) {
|
|
@@ -31,10 +29,10 @@ export const buildCommonJS = () => {
|
|
|
31
29
|
const stemTo = resolve(`.tshy-build/${d}`, relative(resolve('src'), resolve(orig))).replace(/\.tsx?$/, '');
|
|
32
30
|
const stemToPath = `${stemTo}.js.map`;
|
|
33
31
|
const stemToDtsPath = `${stemTo}.d.ts.map`;
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
32
|
+
ifExist.unlink(stemToPath);
|
|
33
|
+
ifExist.unlink(stemToDtsPath);
|
|
34
|
+
ifExist.rename(`${stemFrom}.cjs`, `${stemTo}.js`);
|
|
35
|
+
ifExist.rename(`${stemFrom}.d.cts`, `${stemTo}.d.ts`);
|
|
38
36
|
}
|
|
39
37
|
console.error(chalk.cyan.bold('built commonjs'));
|
|
40
38
|
}
|
|
@@ -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,
|
|
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;IAChC,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;AACzB,CAAC,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"]}
|
package/dist/esm/build-esm.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import chalk from 'chalk';
|
|
2
2
|
import { spawnSync } from 'node:child_process';
|
|
3
|
-
import { renameSync, unlinkSync } from 'node:fs';
|
|
4
3
|
import { relative, resolve } from 'node:path';
|
|
5
4
|
import buildFail from './build-fail.js';
|
|
6
5
|
import config from './config.js';
|
|
7
6
|
import * as console from './console.js';
|
|
7
|
+
import ifExist from './if-exist.js';
|
|
8
8
|
import polyfills from './polyfills.js';
|
|
9
9
|
import setFolderDialect from './set-folder-dialect.js';
|
|
10
10
|
import './tsconfig.js';
|
|
@@ -27,10 +27,10 @@ export const buildESM = () => {
|
|
|
27
27
|
for (const [override, orig] of pf?.map.entries() ?? []) {
|
|
28
28
|
const stemFrom = resolve(`.tshy-build/${d}`, relative(resolve('src'), resolve(override))).replace(/\.mts$/, '');
|
|
29
29
|
const stemTo = resolve(`.tshy-build/${d}`, relative(resolve('src'), resolve(orig))).replace(/\.tsx?$/, '');
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
30
|
+
ifExist.unlink(`${stemTo}.js.map`);
|
|
31
|
+
ifExist.unlink(`${stemTo}.d.ts.map`);
|
|
32
|
+
ifExist.rename(`${stemFrom}.mjs`, `${stemTo}.js`);
|
|
33
|
+
ifExist.rename(`${stemFrom}.d.mts`, `${stemTo}.d.ts`);
|
|
34
34
|
}
|
|
35
35
|
console.error(chalk.cyan.bold('built ' + d));
|
|
36
36
|
}
|
|
@@ -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,
|
|
1
|
+
{"version":3,"file":"build-esm.js","sourceRoot":"","sources":["../../src/build-esm.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO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A;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;AACzB,CAAC,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"]}
|
package/dist/esm/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/config.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/config.ts"],"names":[],"mappings":"AAQA,OAAO,EAEL,UAAU,EAEX,MAAM,YAAY,CAAA;AAiHnB,QAAA,MAAM,MAAM,EAAE,UAAoC,CAAA;AAClD,eAAe,MAAM,CAAA"}
|
package/dist/esm/config.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// get the config and package and stuff
|
|
2
2
|
import chalk from 'chalk';
|
|
3
|
+
import { Minimatch } from 'minimatch';
|
|
3
4
|
import * as console from './console.js';
|
|
4
5
|
import fail from './fail.js';
|
|
5
6
|
import pkg from './package.js';
|
|
@@ -17,18 +18,61 @@ const validBoolean = (e, name) => {
|
|
|
17
18
|
fail(`tshy.${name} must be a boolean value if specified, got: ` + v);
|
|
18
19
|
return process.exit(1);
|
|
19
20
|
};
|
|
21
|
+
const isStringArray = (e) => !!e && Array.isArray(e) && !e.some(e => typeof e !== 'string');
|
|
20
22
|
const validConfig = (e) => !!e &&
|
|
21
23
|
typeof e === 'object' &&
|
|
22
|
-
(e.exports === undefined ||
|
|
24
|
+
(e.exports === undefined ||
|
|
25
|
+
typeof e.exports === 'string' ||
|
|
26
|
+
isStringArray(e.exports) ||
|
|
27
|
+
validExports(e.exports)) &&
|
|
23
28
|
(e.dialects === undefined || validDialects(e.dialects)) &&
|
|
24
29
|
(e.project === undefined || validProject(e.project)) &&
|
|
25
30
|
(e.exclude === undefined || validExclude(e.exclude)) &&
|
|
26
31
|
validExtraDialects(e) &&
|
|
27
32
|
validBoolean(e, 'selfLink') &&
|
|
28
33
|
validBoolean(e, 'main');
|
|
34
|
+
const match = (e, pattern) => pattern.some(m => m.match(e));
|
|
35
|
+
const parsePattern = (p) => Array.isArray(p)
|
|
36
|
+
? p.map(p => new Minimatch(p.replace(/^\.\//, '')))
|
|
37
|
+
: parsePattern([p]);
|
|
29
38
|
const getConfig = (pkg, sources) => {
|
|
30
|
-
const tshy = validConfig(pkg.tshy)
|
|
31
|
-
|
|
39
|
+
const tshy = validConfig(pkg.tshy)
|
|
40
|
+
? pkg.tshy
|
|
41
|
+
: {};
|
|
42
|
+
let exportsConfig = tshy.exports;
|
|
43
|
+
if (typeof exportsConfig === 'string' ||
|
|
44
|
+
Array.isArray(exportsConfig)) {
|
|
45
|
+
// Strip off the `./src` prefix and the extension
|
|
46
|
+
// exports: "src/**/*.ts" => exports: {"./foo": "./src/foo.ts"}
|
|
47
|
+
const exp = {};
|
|
48
|
+
const pattern = exportsConfig;
|
|
49
|
+
const m = parsePattern(pattern);
|
|
50
|
+
for (const e of sources) {
|
|
51
|
+
if (!match(e.replace(/^\.\//, ''), m))
|
|
52
|
+
continue;
|
|
53
|
+
// index is main, anything else is a subpath
|
|
54
|
+
const sp = /^\.\/src\/index.([mc]?[jt]s|[jt]sx)$/.test(e)
|
|
55
|
+
? '.'
|
|
56
|
+
: './' +
|
|
57
|
+
e
|
|
58
|
+
.replace(/^\.\/src\//, '')
|
|
59
|
+
.replace(/\.([mc]?[tj]s|[jt]sx)$/, '');
|
|
60
|
+
exp[sp] = `./${e}`;
|
|
61
|
+
}
|
|
62
|
+
/* c8 ignore start - should be impossible */
|
|
63
|
+
if (!validExports(exp)) {
|
|
64
|
+
console.error('invalid exports pattern, using default exports');
|
|
65
|
+
delete tshy.exports;
|
|
66
|
+
exportsConfig = undefined;
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
/* c8 ignore stop */
|
|
70
|
+
exp['./package.json'] = './package.json';
|
|
71
|
+
tshy.exports = exp;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
const config = { ...tshy };
|
|
75
|
+
const ti = config;
|
|
32
76
|
if (ti.imports) {
|
|
33
77
|
console.debug(chalk.cyan.dim('imports') +
|
|
34
78
|
' moving from tshy config to top level');
|
|
@@ -39,20 +83,24 @@ const getConfig = (pkg, sources) => {
|
|
|
39
83
|
delete ti.imports;
|
|
40
84
|
}
|
|
41
85
|
validImports(pkg);
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
break;
|
|
86
|
+
if (!exportsConfig) {
|
|
87
|
+
const e = {
|
|
88
|
+
'./package.json': './package.json',
|
|
89
|
+
};
|
|
90
|
+
for (const i of sources) {
|
|
91
|
+
if (/^\.\/src\/index\.[^\.]+$/.test(i)) {
|
|
92
|
+
e['.'] = i;
|
|
93
|
+
break;
|
|
94
|
+
}
|
|
52
95
|
}
|
|
96
|
+
config.exports = e;
|
|
97
|
+
tshy.exports = e;
|
|
98
|
+
exportsConfig = e;
|
|
53
99
|
}
|
|
54
|
-
|
|
55
|
-
|
|
100
|
+
// return the filled out config, but leave the package.json
|
|
101
|
+
// exports as they were, as long as they turned out to be valid.
|
|
102
|
+
pkg.tshy = { ...tshy, exports: exportsConfig };
|
|
103
|
+
return config;
|
|
56
104
|
};
|
|
57
105
|
const config = getConfig(pkg, sources);
|
|
58
106
|
export default config;
|
package/dist/esm/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/config.ts"],"names":[],"mappings":"AAAA,uCAAuC;AAEvC,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,KAAK,OAAO,MAAM,cAAc,CAAA;AACvC,OAAO,IAAI,MAAM,WAAW,CAAA;AAC5B,OAAO,GAAG,MAAM,cAAc,CAAA;AAC9B,OAAO,OAAO,MAAM,cAAc,CAAA;
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/config.ts"],"names":[],"mappings":"AAAA,uCAAuC;AAEvC,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;AACrC,OAAO,KAAK,OAAO,MAAM,cAAc,CAAA;AACvC,OAAO,IAAI,MAAM,WAAW,CAAA;AAC5B,OAAO,GAAG,MAAM,cAAc,CAAA;AAC9B,OAAO,OAAO,MAAM,cAAc,CAAA;AAMlC,OAAO,aAAa,MAAM,qBAAqB,CAAA;AAC/C,OAAO,YAAY,MAAM,oBAAoB,CAAA;AAC7C,OAAO,YAAY,MAAM,oBAAoB,CAAA;AAC7C,OAAO,kBAAkB,MAAM,2BAA2B,CAAA;AAC1D,OAAO,YAAY,MAAM,oBAAoB,CAAA;AAC7C,OAAO,YAAY,MAAM,oBAAoB,CAAA;AAE7C,MAAM,YAAY,GAAG,CAAC,CAAsB,EAAE,IAAY,EAAE,EAAE;IAC5D,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,CAAA;IACjB,IAAI,CAAC,KAAK,SAAS,IAAI,OAAO,CA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ChE,GAAG,CAAC,IAAI,GAAG,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,aAAa,EAAE,CAAA;IAC9C,OAAO,MAAM,CAAA;AACf,CAAC,CAAA;AAED,MAAM,MAAM,GAAe,SAAS,CAAC,GAAG,EAAE,OAAO,CAAC,CAAA;AAClD,eAAe,MAAM,CAAA","sourcesContent":["// get the config and package and stuff\n\nimport chalk from 'chalk'\nimport { Minimatch } from 'minimatch'\nimport * as console from './console.js'\nimport fail from './fail.js'\nimport pkg from './package.js'\nimport sources from './sources.js'\nimport {\n Package,\n TshyConfig,\n TshyConfigMaybeGlobExports,\n} from './types.js'\nimport validDialects from './valid-dialects.js'\nimport validExclude from './valid-exclude.js'\nimport validExports from './valid-exports.js'\nimport validExtraDialects from './valid-extra-dialects.js'\nimport validImports from './valid-imports.js'\nimport validProject from './valid-project.js'\n\nconst validBoolean = (e: Record<string, any>, name: string) => {\n const v = e[name]\n if (v === undefined || typeof v === 'boolean') return true\n fail(`tshy.${name} must be a boolean value if specified, got: ` + v)\n return process.exit(1)\n}\n\nconst isStringArray = (e: any): e is string[] =>\n !!e && Array.isArray(e) && !e.some(e => typeof e !== 'string')\n\nconst validConfig = (e: any): e is TshyConfigMaybeGlobExports =>\n !!e &&\n typeof e === 'object' &&\n (e.exports === undefined ||\n typeof e.exports === 'string' ||\n isStringArray(e.exports) ||\n validExports(e.exports)) &&\n (e.dialects === undefined || validDialects(e.dialects)) &&\n (e.project === undefined || validProject(e.project)) &&\n (e.exclude === undefined || validExclude(e.exclude)) &&\n validExtraDialects(e) &&\n validBoolean(e, 'selfLink') &&\n validBoolean(e, 'main')\n\nconst match = (e: string, pattern: Minimatch[]): boolean =>\n pattern.some(m => m.match(e))\n\nconst parsePattern = (p: string | string[]): Minimatch[] =>\n Array.isArray(p)\n ? p.map(p => new Minimatch(p.replace(/^\\.\\//, '')))\n : parsePattern([p])\n\nconst getConfig = (\n pkg: Package,\n sources: Set<string>\n): TshyConfig => {\n const tshy: TshyConfigMaybeGlobExports = validConfig(pkg.tshy)\n ? pkg.tshy\n : {}\n let exportsConfig = tshy.exports\n if (\n typeof exportsConfig === 'string' ||\n Array.isArray(exportsConfig)\n ) {\n // Strip off the `./src` prefix and the extension\n // exports: \"src/**/*.ts\" => exports: {\"./foo\": \"./src/foo.ts\"}\n const exp: Exclude<TshyConfig['exports'], undefined> = {}\n const pattern: string | string[] = exportsConfig\n const m = parsePattern(pattern)\n for (const e of sources) {\n if (!match(e.replace(/^\\.\\//, ''), m)) continue\n // index is main, anything else is a subpath\n const sp = /^\\.\\/src\\/index.([mc]?[jt]s|[jt]sx)$/.test(e)\n ? '.'\n : './' +\n e\n .replace(/^\\.\\/src\\//, '')\n .replace(/\\.([mc]?[tj]s|[jt]sx)$/, '')\n exp[sp] = `./${e}`\n }\n /* c8 ignore start - should be impossible */\n if (!validExports(exp)) {\n console.error('invalid exports pattern, using default exports')\n delete tshy.exports\n exportsConfig = undefined\n } else {\n /* c8 ignore stop */\n exp['./package.json'] = './package.json'\n tshy.exports = exp\n }\n }\n const config = { ...tshy } as TshyConfig\n const ti = config as TshyConfig & { imports?: any }\n if (ti.imports) {\n console.debug(\n chalk.cyan.dim('imports') +\n ' moving from tshy config to top level'\n )\n pkg.imports = {\n ...pkg.imports,\n ...ti.imports,\n }\n delete ti.imports\n }\n validImports(pkg)\n if (!exportsConfig) {\n const e: Exclude<TshyConfig['exports'], undefined> = {\n './package.json': './package.json',\n }\n for (const i of sources) {\n if (/^\\.\\/src\\/index\\.[^\\.]+$/.test(i)) {\n e['.'] = i\n break\n }\n }\n config.exports = e\n tshy.exports = e\n exportsConfig = e\n }\n // return the filled out config, but leave the package.json\n // exports as they were, as long as they turned out to be valid.\n pkg.tshy = { ...tshy, exports: exportsConfig }\n return config\n}\n\nconst config: TshyConfig = getConfig(pkg, sources)\nexport default config\n"]}
|
package/dist/esm/exports.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exports.d.ts","sourceRoot":"","sources":["../../src/exports.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"exports.d.ts","sourceRoot":"","sources":["../../src/exports.ts"],"names":[],"mappings":"AACA,OAAO,EAGL,eAAe,EAChB,MAAM,gBAAgB,CAAA;AAKvB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAGjD,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAoC5D,eAAO,MAAM,YAAY,MACpB,MAAM,GAAG,UAAU,GAAG,SAAS,GAAG,IAAI,cAC9B,IAAI,MAAM,EAAE,WAAW,CAAC,8BAE+B,CAAA;AAEpE,eAAO,MAAM,YAAY,MACpB,MAAM,GAAG,UAAU,GAAG,SAAS,GAAG,IAAI,cAC9B,IAAI,MAAM,EAAE,WAAW,CAAC,8BAQlC,CAAA;AAqFH,eAAO,MAAM,OAAO,MACf,UAAU,GAAG,SAAS,OACpB,OAAO,GAAG;IAAE,OAAO,EAAE,eAAe,CAAA;CAAE,cAsB5C,CAAA;;AAMD,wBAA0B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"if-exist.d.ts","sourceRoot":"","sources":["../../src/if-exist.ts"],"names":[],"mappings":";;;;AAMA,wBAGC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"if-exist.js","sourceRoot":"","sources":["../../src/if-exist.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,IAAI,CAAA;AAEvD,MAAM,MAAM,GAAG,CAAC,CAAS,EAAE,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI,UAAU,CAAC,CAAC,CAAC,CAAA;AAC5D,MAAM,MAAM,GAAG,CAAC,CAAS,EAAE,EAAU,EAAE,EAAE,CACvC,UAAU,CAAC,CAAC,CAAC,IAAI,UAAU,CAAC,CAAC,EAAE,EAAE,CAAC,CAAA;AAEpC,eAAe;IACb,MAAM;IACN,MAAM;CACP,CAAA","sourcesContent":["import { existsSync, renameSync, unlinkSync } from 'fs'\n\nconst unlink = (f: string) => existsSync(f) && unlinkSync(f)\nconst rename = (f: string, to: string) =>\n existsSync(f) && renameSync(f, to)\n\nexport default {\n unlink,\n rename,\n}\n"]}
|
package/dist/esm/types.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ConditionalValue, ExportsSubpaths, Imports } from 'resolve-import';
|
|
2
|
-
export type
|
|
3
|
-
exports?: Record<string, TshyExport>;
|
|
2
|
+
export type TshyConfigMaybeGlobExports = {
|
|
3
|
+
exports?: string | string[] | Record<string, TshyExport>;
|
|
4
4
|
dialects?: Dialect[];
|
|
5
5
|
selfLink?: boolean;
|
|
6
6
|
main?: boolean;
|
|
@@ -9,6 +9,9 @@ export type TshyConfig = {
|
|
|
9
9
|
project?: string;
|
|
10
10
|
exclude?: string[];
|
|
11
11
|
};
|
|
12
|
+
export type TshyConfig = TshyConfigMaybeGlobExports & {
|
|
13
|
+
exports?: Record<string, TshyExport>;
|
|
14
|
+
};
|
|
12
15
|
export type Dialect = 'commonjs' | 'esm';
|
|
13
16
|
export type ExportDetail = {
|
|
14
17
|
default: string;
|
|
@@ -23,7 +26,7 @@ export type Package = {
|
|
|
23
26
|
type?: 'module' | 'commonjs';
|
|
24
27
|
bin?: string | Record<string, string>;
|
|
25
28
|
exports?: ExportsSubpaths;
|
|
26
|
-
tshy?:
|
|
29
|
+
tshy?: TshyConfigMaybeGlobExports;
|
|
27
30
|
imports?: Imports;
|
|
28
31
|
[k: string]: any;
|
|
29
32
|
};
|
package/dist/esm/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,EAChB,eAAe,EACf,OAAO,EACR,MAAM,gBAAgB,CAAA;AAEvB,MAA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AE,eAAe,CAAA;IACzB,IAAI,CAAC,EAAE,0BAA0B,CAAA;IACjC,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,CAAC,CAAC,EAAE,MAAM,GAAG,GAAG,CAAA;CACjB,CAAA"}
|
package/dist/esm/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"","sourcesContent":["import type {\n ConditionalValue,\n ExportsSubpaths,\n Imports,\n} from 'resolve-import'\n\nexport type
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"","sourcesContent":["import type {\n ConditionalValue,\n ExportsSubpaths,\n Imports,\n} from 'resolve-import'\n\nexport type TshyConfigMaybeGlobExports = {\n exports?: string | string[] | Record<string, TshyExport>\n dialects?: Dialect[]\n selfLink?: boolean\n main?: boolean\n commonjsDialects?: string[]\n esmDialects?: string[]\n project?: string\n exclude?: string[]\n}\n\nexport type TshyConfig = TshyConfigMaybeGlobExports & {\n exports?: Record<string, TshyExport>\n}\n\nexport type Dialect = 'commonjs' | 'esm'\n\nexport type ExportDetail = {\n default: string\n [k: string]: string\n}\n\nexport type TshyExport = ConditionalValue\n\nexport type Package = {\n name: string\n version: string\n main?: string\n types?: string\n type?: 'module' | 'commonjs'\n bin?: string | Record<string, string>\n exports?: ExportsSubpaths\n tshy?: TshyConfigMaybeGlobExports\n imports?: Imports\n [k: string]: any\n}\n"]}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
declare const _default: (e: any) => e is Record<string, import("resolve-import").ConditionalValue>;
|
|
1
|
+
declare const _default: (e: any) => e is (string | string[] | Record<string, import("resolve-import").ConditionalValue>) & Record<string, import("resolve-import").ConditionalValue>;
|
|
2
2
|
export default _default;
|
|
3
3
|
//# sourceMappingURL=valid-exports.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"write-package.d.ts","sourceRoot":"","sources":["../../src/write-package.ts"],"names":[],"mappings":";AAIA,
|
|
1
|
+
{"version":3,"file":"write-package.d.ts","sourceRoot":"","sources":["../../src/write-package.ts"],"names":[],"mappings":";AAIA,wBAAkE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"write-package.js","sourceRoot":"","sources":["../../src/write-package.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,IAAI,CAAA;AAClC,OAAO,
|
|
1
|
+
{"version":3,"file":"write-package.js","sourceRoot":"","sources":["../../src/write-package.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,IAAI,CAAA;AAClC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AACvC,OAAO,GAAG,MAAM,cAAc,CAAA;AAE9B,eAAe,GAAG,EAAE,CAAC,aAAa,CAAC,cAAc,EAAE,SAAS,CAAC,GAAG,CAAC,CAAC,CAAA","sourcesContent":["import { writeFileSync } from 'fs'\nimport { stringify } from 'polite-json'\nimport pkg from './package.js'\n\nexport default () => writeFileSync('package.json', stringify(pkg))\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tshy",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.14.1",
|
|
4
4
|
"description": "TypeScript HYbridizer - Hybrid (CommonJS/ESM) TypeScript node package builder",
|
|
5
5
|
"author": "Isaac Z. Schlueter <i@izs.me> (https://izs.me)",
|
|
6
6
|
"license": "BlueOak-1.0.0",
|
|
@@ -11,14 +11,15 @@
|
|
|
11
11
|
],
|
|
12
12
|
"dependencies": {
|
|
13
13
|
"chalk": "^5.3.0",
|
|
14
|
-
"chokidar": "^3.
|
|
14
|
+
"chokidar": "^3.6.0",
|
|
15
15
|
"foreground-child": "^3.1.1",
|
|
16
|
+
"minimatch": "^9.0.4",
|
|
16
17
|
"mkdirp": "^3.0.1",
|
|
17
18
|
"polite-json": "^4.0.1",
|
|
18
|
-
"resolve-import": "^1.4.
|
|
19
|
+
"resolve-import": "^1.4.5",
|
|
19
20
|
"rimraf": "^5.0.1",
|
|
20
21
|
"sync-content": "^1.0.2",
|
|
21
|
-
"typescript": "5.
|
|
22
|
+
"typescript": "^5.4.5",
|
|
22
23
|
"walk-up-path": "^3.0.1"
|
|
23
24
|
},
|
|
24
25
|
"scripts": {
|
|
@@ -48,10 +49,10 @@
|
|
|
48
49
|
"build"
|
|
49
50
|
],
|
|
50
51
|
"devDependencies": {
|
|
51
|
-
"@types/node": "^20.
|
|
52
|
+
"@types/node": "^20.12.7",
|
|
52
53
|
"prettier": "^2.8.8",
|
|
53
|
-
"tap": "^
|
|
54
|
-
"typedoc": "^0.25.
|
|
54
|
+
"tap": "^19.2.1",
|
|
55
|
+
"typedoc": "^0.25.13"
|
|
55
56
|
},
|
|
56
57
|
"prettier": {
|
|
57
58
|
"semi": false,
|