Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

tshy

Package Overview
Dependencies
Maintainers
0
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.18.0 to 2.0.0

34

dist/esm/exports.js

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

export const getReqTarget = (s, polyfills = new Map()) => getTargetForDialectCondition(s, 'commonjs', 'require', 'commonjs', polyfills);
const getExports = (c) => {
const getExports = (c, pkgType) => {
// by this time it always exports, will get the default if missing

@@ -68,9 +68,11 @@ /* c8 ignore start */

{
source,
...getSourceDialects(source, c),
...(pkgType === 'commonjs' ?
getSourceDialects(source, c)
: {}),
default: target,
}
: {
source,
...getSourceDialects(source, c),
...(pkgType === 'commonjs' ?
getSourceDialects(source, c)
: {}),
types: target.replace(/\.js$/, '.d.ts'),

@@ -90,9 +92,11 @@ default: target,

{
source,
...getSourceDialects(source, c),
...(pkgType === 'module' ?
getSourceDialects(source, c)
: {}),
default: target,
}
: {
source,
...getSourceDialects(source, c),
...(pkgType === 'module' ?
getSourceDialects(source, c)
: {}),
types: target.replace(/\.js$/, '.d.ts'),

@@ -109,7 +113,7 @@ default: target,

{
source: s,
...(pkgType === 'module' ? getSourceDialects(s, c) : {}),
default: impTarget,
}
: {
source: s,
...(pkgType === 'module' ? getSourceDialects(s, c) : {}),
types: impTarget.replace(/\.(m?)js$/, '.d.$1ts'),

@@ -123,7 +127,7 @@ default: impTarget,

{
source: s,
...(pkgType === 'commonjs' ? getSourceDialects(s, c) : {}),
default: reqTarget,
}
: {
source: s,
...(pkgType === 'commonjs' ? getSourceDialects(s, c) : {}),
types: reqTarget.replace(/\.(c?)js$/, '.d.$1ts'),

@@ -143,2 +147,3 @@ default: reqTarget,

export const setMain = (c, pkg) => {
pkg.type = pkg.type === 'commonjs' ? 'commonjs' : 'module';
const mod = resolveExport(pkg.exports['.'], ['require']);

@@ -167,3 +172,2 @@ const main = c?.main ?? !!mod;

}
pkg.type = pkg.type === 'commonjs' ? 'commonjs' : 'module';
// Set the package module to exports["."]

@@ -185,5 +189,5 @@ const importMod = resolveExport(pkg.exports['.'], ['import']);

};
pkg.exports = getExports(config);
pkg.exports = getExports(config, pkg.type);
setMain(config, pkg);
export default pkg.exports;
//# sourceMappingURL=exports.js.map
import { Package } from './types.js';
declare const _default: Package;
declare const _default: Package & {
type: "commonjs" | "module";
};
export default _default;
//# sourceMappingURL=package.d.ts.map

@@ -9,4 +9,7 @@ // get the package.json data for the cwd

const res = parse(readFileSync('package.json', 'utf8'));
if (isPackage(res))
return res;
if (isPackage(res)) {
return Object.assign(res, {
type: res.type === 'commonjs' ? 'commonjs' : 'module'
});
}
throw new Error('Invalid package.json contents: ' + stringify(res));

@@ -13,0 +16,0 @@ }

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

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

}
}
},
"module": "./dist/esm/index.js"
}

@@ -918,14 +918,10 @@ # tshy - TypeScript HYbridizer

Note that `sourceDialects` are _only_ added to exports whose type
matches the top-level `package.json` `type` field. For example,
if the `package.json` includes `"type": "module"`, then
`sourceDialects` export conditions will only be added for the
`import` condition, not the `require` condition.
See also: "Live Dev", above.
#### Why not just use `"source"` as the target?
Tshy always builds the `"source"` target referencing the location
of the TypeScript file that was built. However, this can cause
problems if tools use this to resolve into dependencies, which
may not ship their TypeScript source.
But if you can configure your tools to _only_ use this import
condition outside of `node_modules`, then it's safe to use.
### Custom `project`

@@ -932,0 +928,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

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