tshy 1.0.0 → 1.1.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 CHANGED
@@ -102,7 +102,7 @@ just be passed through as-is.
102
102
  "./arraystyle": [
103
103
  { "import": "./no-op.js" },
104
104
  { "browser": "./browser-thing.js" },
105
- { "require": [{ "types": "./using-require.d.ts" }, "./using-require.js"],
105
+ { "require": [{ "types": "./using-require.d.ts" }, "./using-require.js"]},
106
106
  { "types": "./blah.d.ts" },
107
107
  "./etc.js"
108
108
  ]
@@ -214,17 +214,6 @@ If you don't provide that config, then the default is:
214
214
  }
215
215
  ```
216
216
 
217
- ## Package `#imports`
218
-
219
- Using the `imports` field in `package.json` is not currently
220
- supported, because this looks at the nearest `package.json` to
221
- get local imports, and the package.json files placed in
222
- `dist/{commonjs,esm}` can't have local imports outside of their
223
- folders.
224
-
225
- There's a way it could theoretically be done, but it's a bit
226
- complicated. A future version may support this.
227
-
228
217
  ## TSConfigs
229
218
 
230
219
  Put whatever configuration you want in `tsconfig.json`, with the
@@ -257,3 +246,124 @@ During the build, `tshy` will create a file at `src/package.json`
257
246
  for this purpose, and then delete it afterwards. If that file
258
247
  exists and _wasn't_ put there by `tshy`, then it will be
259
248
  destroyed.
249
+
250
+ ## Package `#imports`
251
+
252
+ If you use `"imports"` in your package.json, then tshy will set
253
+ `scripts.preinstall` to set up some symbolic links to make it
254
+ work. This just means you can't use `scripts.preinstall` for
255
+ anything else if you use `"imports"`.
256
+
257
+ <details>
258
+ <summary>tl;dr explanation</summary>
259
+
260
+ The `"imports"` field in package.json allows you to set local
261
+ package imports, which have the same kind of conditional import
262
+ logic as `"exports"`. This is especially useful when you have a
263
+ vendored dependency with `require` and `import` variants, modules
264
+ that have to be bundled in different ways for different
265
+ environments, or different dependencies for different
266
+ environments.
267
+
268
+ These package imports are _always_ resolved against the nearest
269
+ `package.json` file, and tshy uses generated package.json files
270
+ to set the module dialect to `"type":"module"` in `dist/esm` and
271
+ `"type":"commonjs"` in `dist/commonjs`, and it swaps the
272
+ `src/package.json` file between this during the `tsc` builds.
273
+
274
+ Furthermore, local package imports may not be relative files
275
+ outside the package folder. They may only be local files within
276
+ the local package, or dependencies resolved in `node_modules`.
277
+
278
+ To support this, tshy copies the `imports` field from the
279
+ project's package.json into these dialect-setting generated
280
+ package.json files, and creates symlinks into the appropriate
281
+ places so that they resolve to the same files on disk.
282
+
283
+ Because symlinks may not be included in npm packages (and even if
284
+ they are included, they won't be unpacked at install time), the
285
+ symlinks it places in `./dist` wouldn't do much good. In order to
286
+ work around _this_ restriction, tshy creates a node program at
287
+ `dist/.tshy-link-imports.mjs`, which generates the symlinks at
288
+ install time via the `preinstall` script.
289
+
290
+ </details>
291
+
292
+ ## Local Package `exports`
293
+
294
+ In order to facilitate local package exports, tshy will create a
295
+ symlink to the current package temporarily in
296
+ `./src/node_modules` and permanently in `./dist/node_modules`.
297
+
298
+ If you rely on this feature, you may need to add a `paths`
299
+ section to your `tsconfig.json` so that you don't get nagged
300
+ constantly by your editor about missing type references.
301
+
302
+ <details>
303
+ <summary>tl;dr explanation</summary>
304
+
305
+ Similar to local module imports, Node supports importing the
306
+ `exports` of the current package as if it was a dependency of
307
+ itself. The generated `package.json` files mess with this similar
308
+ to `imports`, but it's much easier to work around.
309
+
310
+ For example, if you had this in your package.json:
311
+
312
+ ```json
313
+ {
314
+ "name": "@my/package",
315
+ "exports": {
316
+ "./foo": {
317
+ "import": "./lib/foo.mjs",
318
+ "require": "./lib/foo.cjs"
319
+ }
320
+ }
321
+ }
322
+ ```
323
+
324
+ Then any module in the package could do
325
+ `import('@my/package/foo')` or `require('@my/package/foo')` to
326
+ pull in the appropriate file.
327
+
328
+ In order to make this wort, tshy links the current project
329
+ directory into `./src/node_modules/<pkgname>` during the builds,
330
+ and removes the link afterwards, so that TypeScript knows what
331
+ those things refer to.
332
+
333
+ The link is also created in the `dist` folder, but it's only
334
+ relevant if your tests load the code from `./dist` rather than
335
+ from `./src`. In the install, there's no need to re-create this
336
+ link, because the package will be in a `node_modules` folder
337
+ already.
338
+
339
+ If you use this feature, you can put something like this in your
340
+ `tsconfig.json` file so that your editor knows what those things
341
+ refer to:
342
+
343
+ ```json
344
+ {
345
+ "compilerOptions": {
346
+ "paths": {
347
+ "@my/package/foo": ["./src/foo.js"],
348
+ "@my/package/bar": ["./src/bar.js"]
349
+ }
350
+ }
351
+ }
352
+ ```
353
+
354
+ Note the `.js` extension, rather than `.ts`. Add this for each
355
+ submodule path that you use in this way, or use a wildcard if you
356
+ prefer, though this might result in failing to catch errors if
357
+ you use a submodule identifier that isn't actually exported:
358
+
359
+ ```json
360
+ {
361
+ "compilerOptions": {
362
+ "paths": {
363
+ "@my/package/*": ["./src/*.js"]
364
+ }
365
+ }
366
+ }
367
+ ```
368
+
369
+ </details>
@@ -1 +1 @@
1
- {"version":3,"file":"build-fail.d.ts","sourceRoot":"","sources":["../../src/build-fail.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AAIrD,OAAO,eAAe,CAAA;8BAED,iBAAiB,MAAM,CAAC;AAA7C,wBAKC"}
1
+ {"version":3,"file":"build-fail.d.ts","sourceRoot":"","sources":["../../src/build-fail.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AAIrD,OAAO,eAAe,CAAA;8BAKD,iBAAiB,MAAM,CAAC;AAA7C,wBAOC"}
@@ -2,8 +2,13 @@ import * as console from './console.js';
2
2
  import fail from './fail.js';
3
3
  import setFolderDialect from './set-folder-dialect.js';
4
4
  import './tsconfig.js';
5
+ import { unlink as unlinkImports } from './imports.js';
6
+ import { unlink as unlinkSelfDep } from './self-dep.js';
7
+ import pkg from './package.js';
5
8
  export default (res) => {
6
9
  setFolderDialect('src');
10
+ unlinkImports(pkg, 'src');
11
+ unlinkSelfDep(pkg, 'src');
7
12
  fail('build failed');
8
13
  console.error(res);
9
14
  process.exit(1);
@@ -1 +1 @@
1
- {"version":3,"file":"build-fail.js","sourceRoot":"","sources":["../../src/build-fail.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,OAAO,MAAM,cAAc,CAAA;AACvC,OAAO,IAAI,MAAM,WAAW,CAAA;AAC5B,OAAO,gBAAgB,MAAM,yBAAyB,CAAA;AACtD,OAAO,eAAe,CAAA;AAEtB,eAAe,CAAC,GAA6B,EAAE,EAAE;IAC/C,gBAAgB,CAAC,KAAK,CAAC,CAAA;IACvB,IAAI,CAAC,cAAc,CAAC,CAAA;IACpB,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;IAClB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;AACjB,CAAC,CAAA","sourcesContent":["import { SpawnSyncReturns } from 'node:child_process'\nimport * as console from './console.js'\nimport fail from './fail.js'\nimport setFolderDialect from './set-folder-dialect.js'\nimport './tsconfig.js'\n\nexport default (res: SpawnSyncReturns<Buffer>) => {\n setFolderDialect('src')\n fail('build failed')\n console.error(res)\n process.exit(1)\n}\n"]}
1
+ {"version":3,"file":"build-fail.js","sourceRoot":"","sources":["../../src/build-fail.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,OAAO,MAAM,cAAc,CAAA;AACvC,OAAO,IAAI,MAAM,WAAW,CAAA;AAC5B,OAAO,gBAAgB,MAAM,yBAAyB,CAAA;AACtD,OAAO,eAAe,CAAA;AACtB,OAAO,EAAE,MAAM,IAAI,aAAa,EAAE,MAAM,cAAc,CAAA;AACtD,OAAO,EAAE,MAAM,IAAI,aAAa,EAAE,MAAM,eAAe,CAAA;AACvD,OAAO,GAAG,MAAM,cAAc,CAAA;AAE9B,eAAe,CAAC,GAA6B,EAAE,EAAE;IAC/C,gBAAgB,CAAC,KAAK,CAAC,CAAA;IACvB,aAAa,CAAC,GAAG,EAAE,KAAK,CAAC,CAAA;IACzB,aAAa,CAAC,GAAG,EAAE,KAAK,CAAC,CAAA;IACzB,IAAI,CAAC,cAAc,CAAC,CAAA;IACpB,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;IAClB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;AACjB,CAAC,CAAA","sourcesContent":["import { SpawnSyncReturns } from 'node:child_process'\nimport * as console from './console.js'\nimport fail from './fail.js'\nimport setFolderDialect from './set-folder-dialect.js'\nimport './tsconfig.js'\nimport { unlink as unlinkImports } from './imports.js'\nimport { unlink as unlinkSelfDep } from './self-dep.js'\nimport pkg from './package.js'\n\nexport default (res: SpawnSyncReturns<Buffer>) => {\n setFolderDialect('src')\n unlinkImports(pkg, 'src')\n unlinkSelfDep(pkg, 'src')\n fail('build failed')\n console.error(res)\n process.exit(1)\n}\n"]}
@@ -1,4 +1,4 @@
1
1
  import './tsconfig.js';
2
- declare const _default: () => void;
2
+ declare const _default: () => Promise<void>;
3
3
  export default _default;
4
4
  //# sourceMappingURL=build.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../src/build.ts"],"names":[],"mappings":"AAQA,OAAO,eAAe,CAAA;;AAGtB,wBAcC"}
1
+ {"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../src/build.ts"],"names":[],"mappings":"AAkBA,OAAO,eAAe,CAAA;;AAGtB,wBAmCC"}
package/dist/esm/build.js CHANGED
@@ -6,18 +6,39 @@ import { buildCommonJS } from './build-commonjs.js';
6
6
  import { buildESM } from './build-esm.js';
7
7
  import * as console from './console.js';
8
8
  import dialects from './dialects.js';
9
+ import { link as linkImports, save as saveImports, unlink as unlinkImports, } from './imports.js';
10
+ import pkg from './package.js';
11
+ import { link as linkSelfDep, unlink as unlinkSelfDep, } from './self-dep.js';
9
12
  import './tsconfig.js';
10
13
  import writePackage from './write-package.js';
11
- export default () => {
14
+ export default async () => {
12
15
  rimrafSync('.tshy-build-tmp');
16
+ linkSelfDep(pkg, 'src');
17
+ await linkImports(pkg, 'src');
13
18
  if (dialects.includes('esm'))
14
19
  buildESM();
15
20
  if (dialects.includes('commonjs'))
16
21
  buildCommonJS();
22
+ await unlinkImports(pkg, 'src');
23
+ unlinkSelfDep(pkg, 'src');
17
24
  console.debug(chalk.cyan.dim('moving to ./dist'));
18
25
  syncContentSync('.tshy-build-tmp', 'dist');
19
26
  console.debug(chalk.cyan.dim('removing build temp dir'));
20
27
  rimrafSync('.tshy-build-tmp');
28
+ linkSelfDep(pkg, 'dist');
29
+ if (pkg.imports) {
30
+ console.debug('linking package imports', pkg.imports);
31
+ if (dialects.includes('commonjs'))
32
+ await linkImports(pkg, 'dist/commonjs', true);
33
+ if (dialects.includes('esm'))
34
+ await linkImports(pkg, 'dist/esm', true);
35
+ if (saveImports('dist/.tshy-link-imports.mjs')) {
36
+ pkg.scripts = pkg.scripts || {};
37
+ pkg.scripts.preinstall =
38
+ 'node -e "import(process.argv[1]).catch(()=>{})" ' +
39
+ 'dist/.tshy-link-imports.mjs';
40
+ }
41
+ }
21
42
  console.debug(chalk.cyan.dim('chmod bins'));
22
43
  bins();
23
44
  console.debug(chalk.cyan.dim('write package.json'));
@@ -1 +1 @@
1
- {"version":3,"file":"build.js","sourceRoot":"","sources":["../../src/build.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAA;AACnC,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAC9C,OAAO,IAAI,MAAM,WAAW,CAAA;AAC5B,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AACnD,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AACzC,OAAO,KAAK,OAAO,MAAM,cAAc,CAAA;AACvC,OAAO,QAAQ,MAAM,eAAe,CAAA;AACpC,OAAO,eAAe,CAAA;AACtB,OAAO,YAAY,MAAM,oBAAoB,CAAA;AAE7C,eAAe,GAAG,EAAE;IAClB,UAAU,CAAC,iBAAiB,CAAC,CAAA;IAE7B,IAAI,QAAQ,CAAC,QAAQ,CAAC,KAAK,CAAC;QAAE,QAAQ,EAAE,CAAA;IACxC,IAAI,QAAQ,CAAC,QAAQ,CAAC,UAAU,CAAC;QAAE,aAAa,EAAE,CAAA;IAElD,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,kBAAkB,CAAC,CAAC,CAAA;IACjD,eAAe,CAAC,iBAAiB,EAAE,MAAM,CAAC,CAAA;IAC1C,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,yBAAyB,CAAC,CAAC,CAAA;IACxD,UAAU,CAAC,iBAAiB,CAAC,CAAA;IAC7B,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC,CAAA;IAC3C,IAAI,EAAE,CAAA;IACN,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAC,CAAA;IACnD,YAAY,EAAE,CAAA;AAChB,CAAC,CAAA","sourcesContent":["import chalk from 'chalk'\nimport { rimrafSync } from 'rimraf'\nimport { syncContentSync } from 'sync-content'\nimport bins from './bins.js'\nimport { buildCommonJS } from './build-commonjs.js'\nimport { buildESM } from './build-esm.js'\nimport * as console from './console.js'\nimport dialects from './dialects.js'\nimport './tsconfig.js'\nimport writePackage from './write-package.js'\n\nexport default () => {\n rimrafSync('.tshy-build-tmp')\n\n if (dialects.includes('esm')) buildESM()\n if (dialects.includes('commonjs')) buildCommonJS()\n\n console.debug(chalk.cyan.dim('moving to ./dist'))\n syncContentSync('.tshy-build-tmp', 'dist')\n console.debug(chalk.cyan.dim('removing build temp dir'))\n rimrafSync('.tshy-build-tmp')\n console.debug(chalk.cyan.dim('chmod bins'))\n bins()\n console.debug(chalk.cyan.dim('write package.json'))\n writePackage()\n}\n"]}
1
+ {"version":3,"file":"build.js","sourceRoot":"","sources":["../../src/build.ts"],"names":[],"mapp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,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,yBAAyB,CAAC,CAAC,CAAA;IACxD,UAAU,CAAC,iBAAiB,CAAC,CAAA;IAE7B,WAAW,CAAC,GAAG,EAAE,MAAM,CAAC,CAAA;IAExB,IAAI,GAAG,CAAC,OAAO,EAAE;QACf,OAAO,CAAC,KAAK,CAAC,yBAAyB,EAAE,GAAG,CAAC,OAAO,CAAC,CAAA;QACrD,IAAI,QAAQ,CAAC,QAAQ,CAAC,UAAU,CAAC;YAC/B,MAAM,WAAW,CAAC,GAAG,EAAE,eAAe,EAAE,IAAI,CAAC,CAAA;QAC/C,IAAI,QAAQ,CAAC,QAAQ,CAAC,KAAK,CAAC;YAC1B,MAAM,WAAW,CAAC,GAAG,EAAE,UAAU,EAAE,IAAI,CAAC,CAAA;QAC1C,IAAI,WAAW,CAAC,6BAA6B,CAAC,EAAE;YAC9C,GAAG,CAAC,OAAO,GAAG,GAAG,CAAC,OAAO,IAAI,EAAE,CAAA;YAC/B,GAAG,CAAC,OAAO,CAAC,UAAU;gBACpB,kDAAkD;oBAClD,6BAA6B,CAAA;SAChC;KACF;IAED,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC,CAAA;IAC3C,IAAI,EAAE,CAAA;IACN,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAC,CAAA;IACnD,YAAY,EAAE,CAAA;AAChB,CAAC,CAAA","sourcesContent":["import chalk from 'chalk'\nimport { rimrafSync } from 'rimraf'\nimport { syncContentSync } from 'sync-content'\nimport bins from './bins.js'\nimport { buildCommonJS } from './build-commonjs.js'\nimport { buildESM } from './build-esm.js'\nimport * as console from './console.js'\nimport dialects from './dialects.js'\nimport {\n link as linkImports,\n save as saveImports,\n unlink as unlinkImports,\n} from './imports.js'\nimport pkg from './package.js'\nimport {\n link as linkSelfDep,\n unlink as unlinkSelfDep,\n} from './self-dep.js'\nimport './tsconfig.js'\nimport writePackage from './write-package.js'\n\nexport default async () => {\n rimrafSync('.tshy-build-tmp')\n\n linkSelfDep(pkg, 'src')\n await linkImports(pkg, 'src')\n if (dialects.includes('esm')) buildESM()\n if (dialects.includes('commonjs')) buildCommonJS()\n await unlinkImports(pkg, 'src')\n unlinkSelfDep(pkg, 'src')\n\n console.debug(chalk.cyan.dim('moving to ./dist'))\n syncContentSync('.tshy-build-tmp', 'dist')\n console.debug(chalk.cyan.dim('removing build temp dir'))\n rimrafSync('.tshy-build-tmp')\n\n linkSelfDep(pkg, 'dist')\n\n if (pkg.imports) {\n console.debug('linking package imports', pkg.imports)\n if (dialects.includes('commonjs'))\n await linkImports(pkg, 'dist/commonjs', true)\n if (dialects.includes('esm'))\n await linkImports(pkg, 'dist/esm', true)\n if (saveImports('dist/.tshy-link-imports.mjs')) {\n pkg.scripts = pkg.scripts || {}\n pkg.scripts.preinstall =\n 'node -e \"import(process.argv[1]).catch(()=>{})\" ' +\n 'dist/.tshy-link-imports.mjs'\n }\n }\n\n console.debug(chalk.cyan.dim('chmod bins'))\n bins()\n console.debug(chalk.cyan.dim('write package.json'))\n writePackage()\n}\n"]}
@@ -0,0 +1,5 @@
1
+ import { Package } from './types.js';
2
+ export declare const save: (f: string) => boolean;
3
+ export declare const link: (pkg: Package, dir: string, save?: boolean) => Promise<void>;
4
+ export declare const unlink: (pkg: Package, dir: string) => Promise<void>;
5
+ //# sourceMappingURL=imports.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"imports.d.ts","sourceRoot":"","sources":["../../src/imports.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;AAKpC,eAAO,MAAM,IAAI,MAAO,MAAM,KAAG,OAkBhC,CAAA;AA6BD,eAAO,MAAM,IAAI,QACV,OAAO,OACP,MAAM,kCAkCZ,CAAA;AAGD,eAAO,MAAM,MAAM,QAAe,OAAO,OAAO,MAAM,kBAerD,CAAA"}
@@ -0,0 +1,109 @@
1
+ import { writeFileSync } from 'fs';
2
+ import { symlink } from 'fs/promises';
3
+ import { mkdirp } from 'mkdirp';
4
+ import { dirname, relative, resolve, sep } from 'path';
5
+ import { getAllConditionalValues, getUniqueConditionSets, resolveAllLocalImports, } from 'resolve-import';
6
+ import { rimraf } from 'rimraf';
7
+ import { fileURLToPath } from 'url';
8
+ import * as console from './console.js';
9
+ const dirsMade = new Set();
10
+ // write out the steps to the save file script
11
+ export const save = (f) => {
12
+ const links = [...saveSet.entries()];
13
+ if (!links.length)
14
+ return false;
15
+ const dirs = new Set(links.map(([dest]) => dirname(dest)));
16
+ console.debug('save import linker', f);
17
+ writeFileSync(f, `import { mkdirSync } from 'node:fs'
18
+ import { symlink } from 'node:fs/promises'
19
+ const dirs = ${JSON.stringify([...dirs])}
20
+ const links = [
21
+ ${links.map(l => ` ${JSON.stringify(l)},\n`).join('')}]
22
+ const e = (er) => { if (er.code !== 'EEXIST') throw er }
23
+ for (const d of dirs) mkdirSync(d, { recursive: true })
24
+ Promise.all(links.map(([dest, src]) => symlink(src, dest).catch(e)))
25
+ `);
26
+ return true;
27
+ };
28
+ let targets = undefined;
29
+ const getTargets = async (imports) => {
30
+ const conds = getAllConditionalValues(imports);
31
+ if (!conds.some(c => c.includes('*'))) {
32
+ // fast path
33
+ return (targets = conds.filter(c => c.startsWith('./')));
34
+ }
35
+ const sets = getUniqueConditionSets(imports);
36
+ const t = new Set();
37
+ const pj = resolve('package.json');
38
+ for (const conditions of sets) {
39
+ const imps = await resolveAllLocalImports(pj, { conditions });
40
+ for (const url of Object.values(imps)) {
41
+ // node builtin
42
+ if (typeof url === 'string')
43
+ continue;
44
+ const p = fileURLToPath(url);
45
+ const rel = relative(process.cwd(), p);
46
+ if (!rel || rel.startsWith('..' + sep))
47
+ continue;
48
+ t.add('./' + rel.replace(/\\/g, '/'));
49
+ }
50
+ }
51
+ return (targets = [...t]);
52
+ };
53
+ const saveSet = new Map();
54
+ // create symlinks for the package imports in the target dir
55
+ export const link = async (pkg, dir, save = false) => {
56
+ const { imports } = pkg;
57
+ if (!imports)
58
+ return;
59
+ if (!targets)
60
+ targets = await getTargets(imports);
61
+ console.debug(`link import targets in ${dir}`, targets);
62
+ const rel = relative(resolve(dir), process.cwd());
63
+ const lps = [];
64
+ for (const t of targets) {
65
+ const l = t.replace(/^\.\//, '');
66
+ const df = dirname(l);
67
+ const dfrel = df === '.'
68
+ ? ''
69
+ : df
70
+ .split('/')
71
+ .map(() => '../')
72
+ .join('');
73
+ const dest = dir + '/' + l;
74
+ const src = rel + '/' + dfrel + l;
75
+ if (save)
76
+ saveSet.set(dest, src);
77
+ lps.push(mkdirp(dirname(dest))
78
+ .then(d => {
79
+ // if we aren't saving, then this is a transient link
80
+ // save the dirs created so that we can clean them up
81
+ if (!save && d)
82
+ dirsMade.add(d);
83
+ return rimraf(dest);
84
+ })
85
+ .then(() => symlink(src, dest)));
86
+ }
87
+ await Promise.all(lps);
88
+ };
89
+ // remove symlinks created for package imports in the target dir
90
+ export const unlink = async (pkg, dir) => {
91
+ const { imports } = pkg;
92
+ if (!imports)
93
+ return;
94
+ // will always have targets by this point
95
+ /* c8 ignore start */
96
+ if (!targets)
97
+ targets = await getTargets(imports);
98
+ /* c8 ignore stop */
99
+ console.debug(`unlink import targets in ${dir}`, targets);
100
+ const lps = [];
101
+ for (const t of targets) {
102
+ const dest = resolve(dir, t);
103
+ lps.push(rimraf(dest));
104
+ }
105
+ for (const d of dirsMade)
106
+ lps.push(rimraf(d));
107
+ await Promise.all(lps);
108
+ };
109
+ //# sourceMappingURL=imports.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"imports.js","sourceRoot":"","sources":["../../src/imports.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,IAAI,CAAA;AAClC,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AACrC,OAAO,EAAE,MAAM,EAAE,MAAM,QA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C,CAAC,CAAA;YAC/B,OAAO,MAAM,CAAC,IAAI,CAAC,CAAA;QACrB,CAAC,CAAC;aACD,IAAI,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC,CAClC,CAAA;KACF;IACD,MAAM,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;AACxB,CAAC,CAAA;AAED,gEAAgE;AAChE,MAAM,CAAC,MAAM,MAAM,GAAG,KAAK,EAAE,GAAY,EAAE,GAAW,EAAE,EAAE;IACxD,MAAM,EAAE,OAAO,EAAE,GAAG,GAAG,CAAA;IACvB,IAAI,CAAC,OAAO;QAAE,OAAM;IACpB,yCAAyC;IACzC,qBAAqB;IACrB,IAAI,CAAC,OAAO;QAAE,OAAO,GAAG,MAAM,UAAU,CAAC,OAAO,CAAC,CAAA;IACjD,oBAAoB;IACpB,OAAO,CAAC,KAAK,CAAC,4BAA4B,GAAG,EAAE,EAAE,OAAO,CAAC,CAAA;IACzD,MAAM,GAAG,GAAmB,EAAE,CAAA;IAC9B,KAAK,MAAM,CAAC,IAAI,OAAO,EAAE;QACvB,MAAM,IAAI,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC,CAAA;QAC5B,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAA;KACvB;IACD,KAAK,MAAM,CAAC,IAAI,QAAQ;QAAE,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAA;IAC7C,MAAM,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;AACxB,CAAC,CAAA","sourcesContent":["import { writeFileSync } from 'fs'\nimport { symlink } from 'fs/promises'\nimport { mkdirp } from 'mkdirp'\nimport { dirname, relative, resolve, sep } from 'path'\nimport {\n getAllConditionalValues,\n getUniqueConditionSets,\n resolveAllLocalImports,\n} from 'resolve-import'\nimport { rimraf } from 'rimraf'\nimport { fileURLToPath } from 'url'\nimport * as console from './console.js'\nimport { Package } from './types.js'\n\nconst dirsMade = new Set<string>()\n\n// write out the steps to the save file script\nexport const save = (f: string): boolean => {\n const links = [...saveSet.entries()]\n if (!links.length) return false\n const dirs = new Set<string>(links.map(([dest]) => dirname(dest)))\n console.debug('save import linker', f)\n writeFileSync(\n f,\n `import { mkdirSync } from 'node:fs'\nimport { symlink } from 'node:fs/promises'\nconst dirs = ${JSON.stringify([...dirs])}\nconst links = [\n${links.map(l => ` ${JSON.stringify(l)},\\n`).join('')}]\nconst e = (er) => { if (er.code !== 'EEXIST') throw er }\nfor (const d of dirs) mkdirSync(d, { recursive: true })\nPromise.all(links.map(([dest, src]) => symlink(src, dest).catch(e)))\n`\n )\n return true\n}\n\nlet targets: undefined | string[] = undefined\nconst getTargets = async (imports: Record<string, any>) => {\n const conds = getAllConditionalValues(imports)\n if (!conds.some(c => c.includes('*'))) {\n // fast path\n return (targets = conds.filter(c => c.startsWith('./')))\n }\n const sets = getUniqueConditionSets(imports)\n const t = new Set<string>()\n const pj = resolve('package.json')\n for (const conditions of sets) {\n const imps = await resolveAllLocalImports(pj, { conditions })\n for (const url of Object.values(imps)) {\n // node builtin\n if (typeof url === 'string') continue\n const p = fileURLToPath(url)\n const rel = relative(process.cwd(), p)\n if (!rel || rel.startsWith('..' + sep)) continue\n t.add('./' + rel.replace(/\\\\/g, '/'))\n }\n }\n return (targets = [...t])\n}\n\nconst saveSet = new Map<string, string>()\n\n// create symlinks for the package imports in the target dir\nexport const link = async (\n pkg: Package,\n dir: string,\n save = false\n) => {\n const { imports } = pkg\n if (!imports) return\n if (!targets) targets = await getTargets(imports)\n console.debug(`link import targets in ${dir}`, targets)\n const rel = relative(resolve(dir), process.cwd())\n const lps: Promise<any>[] = []\n for (const t of targets) {\n const l = t.replace(/^\\.\\//, '')\n const df = dirname(l)\n const dfrel =\n df === '.'\n ? ''\n : df\n .split('/')\n .map(() => '../')\n .join('')\n const dest = dir + '/' + l\n const src = rel + '/' + dfrel + l\n if (save) saveSet.set(dest, src)\n lps.push(\n mkdirp(dirname(dest))\n .then(d => {\n // if we aren't saving, then this is a transient link\n // save the dirs created so that we can clean them up\n if (!save && d) dirsMade.add(d)\n return rimraf(dest)\n })\n .then(() => symlink(src, dest))\n )\n }\n await Promise.all(lps)\n}\n\n// remove symlinks created for package imports in the target dir\nexport const unlink = async (pkg: Package, dir: string) => {\n const { imports } = pkg\n if (!imports) return\n // will always have targets by this point\n /* c8 ignore start */\n if (!targets) targets = await getTargets(imports)\n /* c8 ignore stop */\n console.debug(`unlink import targets in ${dir}`, targets)\n const lps: Promise<any>[] = []\n for (const t of targets) {\n const dest = resolve(dir, t)\n lps.push(rimraf(dest))\n }\n for (const d of dirsMade) lps.push(rimraf(d))\n await Promise.all(lps)\n}\n"]}
package/dist/esm/index.js CHANGED
@@ -8,6 +8,6 @@ const { exports: exp, tshy } = pkg;
8
8
  console.debug(chalk.yellow.bold('building'), process.cwd());
9
9
  console.debug(chalk.cyan.dim('tshy config'), tshy);
10
10
  console.debug(chalk.cyan.dim('exports'), exp);
11
- build();
11
+ await build();
12
12
  console.log(chalk.bold.green('success!'));
13
13
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAEA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,KAAK,OAAO,MAAM,cAAc,CAAA;AACvC,OAAO,cAAc,CAAA;AACrB,OAAO,GAAG,MAAM,cAAc,CAAA;AAC9B,OAAO,KAAK,MAAM,YAAY,CAAA;AAE9B,MAAM,EAAE,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,GAAG,CAAA;AAElC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,OAAO,CAAC,GAAG,EAAE,CAAC,CAAA;AAC3D,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,aAAa,CAAC,EAAE,IAAI,CAAC,CAAA;AAClD,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,GAAG,CAAC,CAAA;AAE7C,KAAK,EAAE,CAAA;AAEP,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAA","sourcesContent":["#!/usr/bin/env node\n\nimport chalk from 'chalk'\nimport * as console from './console.js'\nimport './exports.js'\nimport pkg from './package.js'\nimport build from './build.js'\n\nconst { exports: exp, tshy } = pkg\n\nconsole.debug(chalk.yellow.bold('building'), process.cwd())\nconsole.debug(chalk.cyan.dim('tshy config'), tshy)\nconsole.debug(chalk.cyan.dim('exports'), exp)\n\nbuild()\n\nconsole.log(chalk.bold.green('success!'))\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAEA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,KAAK,OAAO,MAAM,cAAc,CAAA;AACvC,OAAO,cAAc,CAAA;AACrB,OAAO,GAAG,MAAM,cAAc,CAAA;AAC9B,OAAO,KAAK,MAAM,YAAY,CAAA;AAE9B,MAAM,EAAE,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,GAAG,CAAA;AAElC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,OAAO,CAAC,GAAG,EAAE,CAAC,CAAA;AAC3D,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,aAAa,CAAC,EAAE,IAAI,CAAC,CAAA;AAClD,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,GAAG,CAAC,CAAA;AAE7C,MAAM,KAAK,EAAE,CAAA;AAEb,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAA","sourcesContent":["#!/usr/bin/env node\n\nimport chalk from 'chalk'\nimport * as console from './console.js'\nimport './exports.js'\nimport pkg from './package.js'\nimport build from './build.js'\n\nconst { exports: exp, tshy } = pkg\n\nconsole.debug(chalk.yellow.bold('building'), process.cwd())\nconsole.debug(chalk.cyan.dim('tshy config'), tshy)\nconsole.debug(chalk.cyan.dim('exports'), exp)\n\nawait build()\n\nconsole.log(chalk.bold.green('success!'))\n"]}
@@ -0,0 +1,4 @@
1
+ import { Package } from './types.js';
2
+ export declare const link: (pkg: Package, where: string) => void;
3
+ export declare const unlink: (pkg: Package, where: string) => void;
4
+ //# sourceMappingURL=self-dep.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"self-dep.d.ts","sourceRoot":"","sources":["../../src/self-dep.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;AAmCpC,eAAO,MAAM,IAAI,QAAS,OAAO,SAAS,MAAM,SAQ/C,CAAA;AAED,eAAO,MAAM,MAAM,QAAS,OAAO,SAAS,MAAM,SAMjD,CAAA"}
@@ -0,0 +1,55 @@
1
+ // link the package folder into ./target/node_modules/<pkgname>
2
+ import { readlinkSync, symlinkSync } from 'fs';
3
+ import { mkdirpSync } from 'mkdirp';
4
+ import { dirname, relative, resolve, sep } from 'path';
5
+ import { rimrafSync } from 'rimraf';
6
+ import { walkUp } from 'walk-up-path';
7
+ const dirsMade = new Map();
8
+ // if the cwd is in already linked to or living within node_modules,
9
+ // then skip the linking, because it's already done.
10
+ // This is typically the case in a workspaces setup, and
11
+ // creating yet *another* symlink to ourselves in src/node_modules
12
+ // will break nx's change detection logic with an ELOOP error.
13
+ let inNM = undefined;
14
+ const linkedAlready = (pkg) => {
15
+ if (inNM !== undefined) {
16
+ return inNM;
17
+ }
18
+ const cwd = process.cwd();
19
+ const p = `${sep}node_modules${sep}${pkg.name}`.toLowerCase();
20
+ if (cwd.toLowerCase().endsWith(p)) {
21
+ return (inNM = true);
22
+ }
23
+ for (const p of walkUp(cwd)) {
24
+ const link = resolve(p, 'node_modules', pkg.name);
25
+ try {
26
+ const target = resolve(dirname(link), readlinkSync(link));
27
+ if (relative(target, cwd) === '') {
28
+ return (inNM = true);
29
+ }
30
+ }
31
+ catch { }
32
+ }
33
+ return (inNM = false);
34
+ };
35
+ export const link = (pkg, where) => {
36
+ if (!pkg.name || linkedAlready(pkg))
37
+ return;
38
+ const dest = resolve(where, 'node_modules', pkg.name);
39
+ const dir = dirname(dest);
40
+ const src = relative(dir, process.cwd());
41
+ const made = mkdirpSync(dir);
42
+ if (made)
43
+ dirsMade.set(dest, made);
44
+ symlinkSync(src, dest);
45
+ };
46
+ export const unlink = (pkg, where) => {
47
+ if (!pkg.name || linkedAlready(pkg))
48
+ return;
49
+ const dest = resolve(where, 'node_modules', pkg.name);
50
+ rimrafSync(dest);
51
+ const made = dirsMade.get(dest);
52
+ if (made)
53
+ rimrafSync(made);
54
+ };
55
+ //# sourceMappingURL=self-dep.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"self-dep.js","sourceRoot":"","sources":["../../src/self-dep.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,IAAI,CAAA;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAA;AACnC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,MAAM,CAAA;AACtD,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAA;AACnC,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAGrC,MAAM,QAAQ,GAAG,IAAI,GAAG,EAAkB,CAAA;AAE1C,oEAAoE;AACpE,oDAAoD;AACpD,wDAAwD;AACxD,kEAAkE;AAClE,8DAA8D;AAC9D,IAAI,IAAI,GAAwB,SAAS,CAAA;A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,GAAG,EAAE,CAAC,CAAA;IACxC,MAAM,IAAI,GAAG,UAAU,CAAC,GAAG,CAAC,CAAA;IAC5B,IAAI,IAAI;QAAE,QAAQ,CAAC,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,CAAA;IAClC,WAAW,CAAC,GAAG,EAAE,IAAI,CAAC,CAAA;AACxB,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,GAAY,EAAE,KAAa,EAAE,EAAE;IACpD,IAAI,CAAC,GAAG,CAAC,IAAI,IAAI,aAAa,CAAC,GAAG,CAAC;QAAE,OAAM;IAC3C,MAAM,IAAI,GAAG,OAAO,CAAC,KAAK,EAAE,cAAc,EAAE,GAAG,CAAC,IAAI,CAAC,CAAA;IACrD,UAAU,CAAC,IAAI,CAAC,CAAA;IAChB,MAAM,IAAI,GAAG,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;IAC/B,IAAI,IAAI;QAAE,UAAU,CAAC,IAAI,CAAC,CAAA;AAC5B,CAAC,CAAA","sourcesContent":["// link the package folder into ./target/node_modules/<pkgname>\nimport { readlinkSync, symlinkSync } from 'fs'\nimport { mkdirpSync } from 'mkdirp'\nimport { dirname, relative, resolve, sep } from 'path'\nimport { rimrafSync } from 'rimraf'\nimport { walkUp } from 'walk-up-path'\nimport { Package } from './types.js'\n\nconst dirsMade = new Map<string, string>()\n\n// if the cwd is in already linked to or living within node_modules,\n// then skip the linking, because it's already done.\n// This is typically the case in a workspaces setup, and\n// creating yet *another* symlink to ourselves in src/node_modules\n// will break nx's change detection logic with an ELOOP error.\nlet inNM: boolean | undefined = undefined\n\nconst linkedAlready = (pkg: Package) => {\n if (inNM !== undefined) {\n return inNM\n }\n\n const cwd = process.cwd()\n const p = `${sep}node_modules${sep}${pkg.name}`.toLowerCase()\n if (cwd.toLowerCase().endsWith(p)) {\n return (inNM = true)\n }\n\n for (const p of walkUp(cwd)) {\n const link = resolve(p, 'node_modules', pkg.name)\n try {\n const target = resolve(dirname(link), readlinkSync(link))\n if (relative(target, cwd) === '') {\n return (inNM = true)\n }\n } catch {}\n }\n\n return (inNM = false)\n}\n\nexport const link = (pkg: Package, where: string) => {\n if (!pkg.name || linkedAlready(pkg)) return\n const dest = resolve(where, 'node_modules', pkg.name)\n const dir = dirname(dest)\n const src = relative(dir, process.cwd())\n const made = mkdirpSync(dir)\n if (made) dirsMade.set(dest, made)\n symlinkSync(src, dest)\n}\n\nexport const unlink = (pkg: Package, where: string) => {\n if (!pkg.name || linkedAlready(pkg)) return\n const dest = resolve(where, 'node_modules', pkg.name)\n rimrafSync(dest)\n const made = dirsMade.get(dest)\n if (made) rimrafSync(made)\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"set-folder-dialect.d.ts","sourceRoot":"","sources":["../../src/set-folder-dialect.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;gCAcb,MAAM,SAAS,OAAO;AAA7C,wBAIC"}
1
+ {"version":3,"file":"set-folder-dialect.d.ts","sourceRoot":"","sources":["../../src/set-folder-dialect.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;gCAab,MAAM,SAAS,OAAO;AAA7C,wBAIC"}
@@ -1,15 +1,21 @@
1
+ import chalk from 'chalk';
1
2
  import { writeFileSync } from 'fs';
2
3
  import { rimrafSync } from 'rimraf';
3
4
  import * as console from './console.js';
4
- import chalk from 'chalk';
5
- const writeDialectPJ = (f, mode) => mode
6
- ? writeFileSync(f, JSON.stringify({
5
+ import pkg from './package.js';
6
+ const writeDialectPJ = (d, mode) => {
7
+ if (!mode) {
8
+ return rimrafSync(`${d}/package.json`);
9
+ }
10
+ const v = {
7
11
  type: mode === 'commonjs' ? 'commonjs' : 'module',
8
- }))
9
- : rimrafSync(f);
12
+ imports: pkg.imports,
13
+ };
14
+ writeFileSync(`${d}/package.json`, JSON.stringify(v));
15
+ };
10
16
  export default (where, mode) => {
11
17
  if (mode)
12
18
  console.debug(chalk.cyan.dim('set dialect'), { where, mode });
13
- writeDialectPJ(`${where}/package.json`, mode);
19
+ writeDialectPJ(where, mode);
14
20
  };
15
21
  //# sourceMappingURL=set-folder-dialect.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"set-folder-dialect.js","sourceRoot":"","sources":["../../src/set-folder-dialect.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,IAAI,CAAA;AAClC,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAA;AAEnC,OAAO,KAAK,OAAO,MAAM,cAAc,CAAA;AACvC,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,MAAM,cAAc,GAAG,CAAC,CAAS,EAAE,IAAc,EAAE,EAAE,CACnD,IAAI;IACF,CAAC,CAAC,aAAa,CACX,CAAC,EACD,IAAI,CAAC,SAAS,CAAC;QACb,IAAI,EAAE,IAAI,KAAK,UAAU,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,QAAQ;KAClD,CAAC,CACH;IACH,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAA;AAEnB,eAAe,CAAC,KAAa,EAAE,IAAc,EAAE,EAAE;IAC/C,IAAI,IAAI;QACN,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,aAAa,CAAC,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAA;IAC/D,cAAc,CAAC,GAAG,KAAK,eAAe,EAAE,IAAI,CAAC,CAAA;AAC/C,CAAC,CAAA","sourcesContent":["import { writeFileSync } from 'fs'\nimport { rimrafSync } from 'rimraf'\nimport { Dialect } from './types.js'\nimport * as console from './console.js'\nimport chalk from 'chalk'\n\nconst writeDialectPJ = (f: string, mode?: Dialect) =>\n mode\n ? writeFileSync(\n f,\n JSON.stringify({\n type: mode === 'commonjs' ? 'commonjs' : 'module',\n })\n )\n : rimrafSync(f)\n\nexport default (where: string, mode?: Dialect) => {\n if (mode)\n console.debug(chalk.cyan.dim('set dialect'), { where, mode })\n writeDialectPJ(`${where}/package.json`, mode)\n}\n"]}
1
+ {"version":3,"file":"set-folder-dialect.js","sourceRoot":"","sources":["../../src/set-folder-dialect.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,aAAa,EAAE,MAAM,IAAI,CAAA;AAClC,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAA;AACnC,OAAO,KAAK,OAAO,MAAM,cAAc,CAAA;AACvC,OAAO,GAAG,MAAM,cAAc,CAAA;AAG9B,MAAM,cAAc,GAAG,CAAC,CAAS,EAAE,IAAc,EAAE,EAAE;IACnD,IAAI,CAAC,IAAI,EAAE;QACT,OAAO,UAAU,CAAC,GAAG,CAAC,eAAe,CAAC,CAAA;KACvC;IACD,MAAM,CAAC,GAAoD;QACzD,IAAI,EAAE,IAAI,KAAK,UAAU,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,QAAQ;QACjD,OAAO,EAAE,GAAG,CAAC,OAAO;KACrB,CAAA;IACD,aAAa,CAAC,GAAG,CAAC,eAAe,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAA;AACvD,CAAC,CAAA;AAED,eAAe,CAAC,KAAa,EAAE,IAAc,EAAE,EAAE;IAC/C,IAAI,IAAI;QACN,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,aAAa,CAAC,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAA;IAC/D,cAAc,CAAC,KAAK,EAAE,IAAI,CAAC,CAAA;AAC7B,CAAC,CAAA","sourcesContent":["import chalk from 'chalk'\nimport { writeFileSync } from 'fs'\nimport { rimrafSync } from 'rimraf'\nimport * as console from './console.js'\nimport pkg from './package.js'\nimport { Dialect } from './types.js'\n\nconst writeDialectPJ = (d: string, mode?: Dialect) => {\n if (!mode) {\n return rimrafSync(`${d}/package.json`)\n }\n const v: { type: string; imports?: Record<string, any> } = {\n type: mode === 'commonjs' ? 'commonjs' : 'module',\n imports: pkg.imports,\n }\n writeFileSync(`${d}/package.json`, JSON.stringify(v))\n}\n\nexport default (where: string, mode?: Dialect) => {\n if (mode)\n console.debug(chalk.cyan.dim('set dialect'), { where, mode })\n writeDialectPJ(where, mode)\n}\n"]}
@@ -31,6 +31,7 @@ export type Package = {
31
31
  bin?: string | Record<string, string>;
32
32
  exports?: Record<string, Export>;
33
33
  tshy?: TshyConfig;
34
+ imports?: Record<string, any>;
34
35
  [k: string]: any;
35
36
  };
36
37
  export type Export = string | {
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,UAAU,GAAG;IACvB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAA;IACpC,QAAQ,CAAC,EAAE,OAAO,EAAE,CAAA;CACrB,CAAA;AAED,MAAM,MAAM,OAAO,GAAG,UAAU,GAAG,KAAK,CAAA;AAExC,MAAM,MAAM,YAAY,GAAG;IACzB,OAAO,EAAE,MAAM,CAAA;IACf,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;CACpB,CAAA;AAED,MAAM,MAAM,UAAU,GAClB,MAAM,GACN,CAAC;IAAE,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,CACrD;IAAE,MAAM,EAAE,MAAM,CAAA;CAAE,GAClB;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,CACtB,CAAC,GACF,CAAC;IACC,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,MAAM,CAAC,EAAE,YAAY,CAAA;IACrB,OAAO,CAAC,EAAE,YAAY,CAAA;CACvB,GAAG,CAAC;IAAE,MAAM,EAAE,YAAY,CAAA;CAAE,GAA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,MAAM,GACN;QACE,KAAK,EAAE,MAAM,CAAA;QACb,OAAO,EAAE,MAAM,CAAA;KAChB,CAAA;CACN,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"","sourcesContent":["export type TshyConfig = {\n exports?: Record<string, TshyExport>\n dialects?: Dialect[]\n}\n\nexport type Dialect = 'commonjs' | 'esm'\n\nexport type ExportDetail = {\n default: string\n [k: string]: string\n}\n\nexport type TshyExport =\n | string\n | ({ types?: string; import?: string; require?: string } & (\n | { import: string }\n | { require: string }\n ))\n | ({\n types?: string\n import?: ExportDetail\n require?: ExportDetail\n } & ({ import: ExportDetail } | { require: ExportDetail }))\n\nexport type Package = {\n name: string\n version: string\n type?: 'module'\n bin?: string | Record<string, string>\n exports?: Record<string, Export>\n tshy?: TshyConfig\n [k: string]: any\n}\n\n// VERY limited subset of the datatypes \"exports\" can be\n// but we're only writing our flavor, so it's fine.\nexport type Export =\n | string\n | {\n import?: Export\n require?: Export\n types?: Export\n default?: Export\n }\n | {\n import?:\n | string\n | {\n types: string\n default: string\n }\n require?:\n | string\n | {\n types: string\n default: string\n }\n }\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"","sourcesContent":["export type TshyConfig = {\n exports?: Record<string, TshyExport>\n dialects?: Dialect[]\n}\n\nexport type Dialect = 'commonjs' | 'esm'\n\nexport type ExportDetail = {\n default: string\n [k: string]: string\n}\n\nexport type TshyExport =\n | string\n | ({ types?: string; import?: string; require?: string } & (\n | { import: string }\n | { require: string }\n ))\n | ({\n types?: string\n import?: ExportDetail\n require?: ExportDetail\n } & ({ import: ExportDetail } | { require: ExportDetail }))\n\nexport type Package = {\n name: string\n version: string\n type?: 'module'\n bin?: string | Record<string, string>\n exports?: Record<string, Export>\n tshy?: TshyConfig\n imports?: Record<string, any>\n [k: string]: any\n}\n\n// VERY limited subset of the datatypes \"exports\" can be\n// but we're only writing our flavor, so it's fine.\nexport type Export =\n | string\n | {\n import?: Export\n require?: Export\n types?: Export\n default?: Export\n }\n | {\n import?:\n | string\n | {\n types: string\n default: string\n }\n require?:\n | string\n | {\n types: string\n default: string\n }\n }\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tshy",
3
- "version": "1.0.0",
3
+ "version": "1.1.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",
@@ -13,14 +13,16 @@
13
13
  "chalk": "^5.3.0",
14
14
  "foreground-child": "^3.1.1",
15
15
  "mkdirp": "^3.0.1",
16
+ "resolve-import": "^1.4.1",
16
17
  "rimraf": "^5.0.1",
17
18
  "sync-content": "^1.0.2",
18
- "typescript": "5.2"
19
+ "typescript": "5.2",
20
+ "walk-up-path": "^3.0.1"
19
21
  },
20
22
  "scripts": {
21
23
  "postversion": "npm publish",
22
24
  "prepublishOnly": "git push origin --follow-tags",
23
- "prepare": "tsc -p tsconfig/esm.json && bash scripts/fixup.sh",
25
+ "prepare": "tsc -p .tshy/esm.json && bash scripts/fixup.sh",
24
26
  "pretest": "npm run prepare",
25
27
  "presnap": "npm run prepare",
26
28
  "format": "prettier --write . --ignore-path ./.prettierignore --cache",
@@ -46,7 +48,7 @@
46
48
  "devDependencies": {
47
49
  "@types/node": "^20.6.0",
48
50
  "prettier": "^2.8.8",
49
- "tap": "^18.0.0-26",
51
+ "tap": "^18.0.3",
50
52
  "typedoc": "^0.25.1"
51
53
  },
52
54
  "prettier": {