Socket
Socket
Sign inDemoInstall

tshy

Package Overview
Dependencies
Maintainers
1
Versions
39
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tshy - npm Package Compare versions

Comparing version 1.2.1 to 1.2.2

26

dist/esm/exports.js

@@ -8,3 +8,2 @@ import { relative, resolve } from 'node:path/posix';

import { resolveExport } from './resolve-export.js';
import { isDialect } from './valid-dialects.js';
export const getImpTarget = (s) => {

@@ -76,19 +75,14 @@ if (s === undefined)

export const setMain = (c, pkg) => {
if (c?.main !== undefined) {
if (!isDialect(c.main)) {
fail(`config.main must be 'commonjs' or 'esm', got: ${c.main}`);
return process.exit(1);
}
const m = c.main === 'commonjs' ? 'require' : 'import';
const mod = resolveExport(pkg.exports['.'], [m]);
if (!!c?.main) {
c.main = true;
const mod = resolveExport(pkg.exports['.'], ['require']);
if (!mod) {
fail(`could not resolve exports['.'] for tshy.main '${m}'`);
fail(`could not resolve exports['.'] for tshy.main 'require'`);
return process.exit(1);
}
const types = resolveExport(pkg.exports['.'], [m, 'types']);
const types = resolveExport(pkg.exports['.'], [
'require',
'types',
]);
pkg.main = mod;
if (c.main === 'esm')
pkg.type = 'module';
else
delete pkg.type;
if (types && types !== mod)

@@ -100,6 +94,8 @@ pkg.types = types;

else {
pkg.type = 'module';
if (c)
delete c.main;
delete pkg.main;
delete pkg.types;
}
pkg.type = 'module';
};

@@ -106,0 +102,0 @@ // These are all defined by exports, so it's just confusing otherwise

@@ -5,3 +5,3 @@ export type TshyConfig = {

selfLink?: boolean;
main?: Dialect;
main?: boolean;
};

@@ -8,0 +8,0 @@ export type Dialect = 'commonjs' | 'esm';

{
"name": "tshy",
"version": "1.2.1",
"version": "1.2.2",
"description": "TypeScript HYbridizer - Hybrid (CommonJS/ESM) TypeScript node package builder",

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

@@ -167,14 +167,20 @@ # tshy - TypeScript HYbridizer

this affordance for versions of node that met their end of life
more than a year ago. However, some tools still rely on `main`
and have not been updated to read the package entry points via
`exports`.
long ago. However, some tools still rely on `main` and have not
been updated to read the package entry points via `exports`.
**Warning: this will likely cause incorrect types to be loaded in
some scenarios.**
Use with extreme caution. It's almost always better to _not_
define top-level `main` and `types` fields if you are shipping a
hybrid module. Users will need to update their `module` and
`moduleResolution` tsconfigs appropriately. **That is a good
thing, and will save them future headaches.**
You can tell tshy to export a top-level `main` and `types` field
by setting `main` to either `commonjs` or `esm`. If `main` is set
to `"commonjs"`, then the package will not have `"type":
"module"` set.
by setting `main` to `true`.
If the specified dialect is not built, or if a `"."` export is
If the `commonjs` dialect is not built, or if a `"."` export is
not created, or if the `"."` export does not support the
specified dialect, then the build will fail.
`commonjs` dialect, then the build will fail.

@@ -189,3 +195,3 @@ For example, this config:

},
"main": "commonjs"
"main": true
}

@@ -201,2 +207,3 @@ }

"types": "./dist/commonjs/index.d.ts",
"type": "module",
"exports": {

@@ -203,0 +210,0 @@ ".": {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc