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

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.0.0-1 to 1.0.0-2

dist/esm/resolve-export.d.ts

2

dist/esm/build.js

@@ -47,3 +47,3 @@ import chalk from 'chalk';

const stemFrom = resolve('.tshy-build-tmp/commonjs', relative(resolve('src'), resolve(f))).replace(/\.cts$/, '');
const stemTo = resolve('.tshy-build-tmp/commonjs', relative(resolve('src'), resolve(t))).replace(/\.ts$/, '');
const stemTo = resolve('.tshy-build-tmp/commonjs', relative(resolve('src'), resolve(t))).replace(/\.tsx?$/, '');
renameSync(`${stemFrom}.cjs`, `${stemTo}.js`);

@@ -50,0 +50,0 @@ renameSync(`${stemFrom}.d.cts`, `${stemTo}.d.ts`);

@@ -9,2 +9,13 @@ // get the config and package and stuff

const validDialects = (d) => !!d && Array.isArray(d) && !d.some(d => !isDialect(d));
const validExternalExport = (exp) => {
const i = resolveExport(exp, 'import');
const r = resolveExport(exp, 'require');
if (!i && !r)
return false;
if (i && join(i).startsWith('src/'))
return false;
if (r && join(r).startsWith('src/'))
return false;
return true;
};
const validExports = (e) => {

@@ -20,2 +31,3 @@ if (!e)

}
// just a module. either a built export, or a simple unbuilt export
if (typeof exp === 'string') {

@@ -30,27 +42,15 @@ e[sub] = addDot(exp);

}
const { import: i, require: r } = exp;
if (!i && !e) {
fail(`tshy.exports ${sub} needs require or import, ` +
// can be:
// "./sub": "./unbuilt.js"
// "./sub": { require: "./unbuilt.js", types: "./unbuilt.d.ts" }
// "./sub": {require:"./u.cjs",import:"./u.cjs",types:"./u.dts"}
// "./sub": {import:{types:"u.d.ts",default:"u.js"},require:{types:"u.d.cts", default:"u.cjs"}}
// Just verify that import and require resolutions are not in src
if (!validExternalExport(exp)) {
fail(`tshy.exports ${sub} unbuilt exports must not be in ./src, ` +
`and exports in src must be string values. ` +
`got: ${JSON.stringify(exp)}`);
process.exit(1);
}
if ((i !== undefined && typeof i !== 'string') ||
(r !== undefined && typeof r !== 'string')) {
fail(`tshy.exports ${sub} import/require must be strings, ` +
`got: ${JSON.stringify(exp)}`);
process.exit(1);
}
if ((i !== undefined && join(i).startsWith('src/')) ||
(r !== undefined && join(r).startsWith('src/'))) {
fail(`tshy.exports ${sub} in src/ must be string paths, ` +
`got: ${JSON.stringify(exp)}`);
process.exit(1);
}
e[sub] = {};
if (e[sub].types)
e[sub].types = addDot(e[sub].types);
if (e[sub].import)
e[sub].types = addDot(e[sub].import);
if (e[sub].require)
e[sub].types = addDot(e[sub].require);
e[sub] = exp;
}

@@ -86,4 +86,5 @@ if (e.dialects) {

import sources from './sources.js';
import { resolveExport } from './resolve-export.js';
const config = getConfig(pkg, sources);
export default config;
//# sourceMappingURL=config.js.map
import { relative, resolve } from 'node:path/posix';
import config from './config.js';
import dialects from './dialects.js';
import { fail } from './fail.js';
import pkg from './package.js';
import polyfills from './polyfills.js';
import { resolveExport } from './resolve-export.js';
const getImpTarget = (s) => {

@@ -17,3 +20,3 @@ if (s === undefined)

if (s && typeof s === 'object') {
return getImpTarget(s.import);
return resolveExport(s, 'import');
}

@@ -33,3 +36,3 @@ };

if (s && typeof s === 'object') {
return getReqTarget(s.require, polyfills);
return getReqTarget(resolveExport(s, 'require'), polyfills);
}

@@ -46,28 +49,10 @@ };

const reqTarget = getReqTarget(s, polyfills);
// only possible for exports outside of ./src
const types = typeof s !== 'string' && s.types;
// external export, not built by us
if (typeof s !== 'string' || !s.startsWith('./src/')) {
if (impTarget === reqTarget) {
if (impTarget === undefined)
continue;
if (types) {
e[sub] = {
import: impTarget,
require: reqTarget,
types,
};
}
else if (impTarget !== undefined)
e[sub] = impTarget;
continue;
}
if (types) {
e[sub] = {
types,
import: impTarget,
require: reqTarget,
};
continue;
}
// already been validated, just accept as-is
e[sub] = s;
continue;
}
if (!impTarget && !reqTarget)
continue;
const exp = (e[sub] = {});

@@ -89,5 +74,7 @@ if (impTarget) {

};
import { fail } from './fail.js';
import pkg from './package.js';
// These are all defined by exports, so it's just confusing otherwise
delete pkg.module;
delete pkg.main;
delete pkg.types;
export default pkg.exports = getExports(config, polyfills);
//# sourceMappingURL=exports.js.map
// the modules like -cjs.cts that override a module at .ts
import chalk from 'chalk';
import sources from './sources.js';
const target = (f, sources) => {
const ts = f.replace(/\-cjs\.cts$/, '.ts');
const tsx = f.replace(/\-cjs\.cts$/, '.tsx');
return sources.has(ts) ? ts : sources.has(tsx) ? tsx : undefined;
};
const getPolyfills = (sources) => new Map([...sources]
.filter(f => f.endsWith('-cjs.cts') &&
(sources.has(f.replace(/-cjs\.cts$/, '.ts')) ||
sources.has(f.replace(/-cjs\.cts$/, '.tsx'))))
.map(f => [f, f.replace(/-cjs\.cts$/, '.ts')]));
.filter(f => f.endsWith('-cjs.cts'))
.map(f => [f, target(f, sources)])
.filter(([_, target]) => !!target));
const polyfills = getPolyfills(sources);

@@ -10,0 +14,0 @@ if (polyfills.size) {

@@ -8,9 +8,11 @@ import chalk from 'chalk';

compilerOptions: {
jsx: 'react',
declaration: true,
declarationMap: true,
inlineSources: true,
esModuleInterop: true,
forceConsistentCasingInFileNames: true,
inlineSources: true,
jsx: 'react',
module: 'nodenext',
moduleResolution: 'nodenext',
noUncheckedIndexedAccess: true,
resolveJsonModule: true,

@@ -21,3 +23,2 @@ skipLibCheck: true,

target: 'es2022',
module: 'nodenext',
},

@@ -37,3 +38,3 @@ };

include: ['../src/**/*.ts', '../src/**/*.cts', '../src/**/*.tsx'],
exclude: [...polyfills.values()].map(f => `.${f}`),
exclude: ['../src/**/*.mts', ...polyfills.values()].map(f => `.${f}`),
compilerOptions: {

@@ -45,3 +46,3 @@ outDir: '../.tshy-build-tmp/commonjs',

extends: './build.json',
include: ['../src/**/*.ts', '../src/**/*.cts', '../src/**/*.tsx'],
include: ['../src/**/*.ts', '../src/**/*.mts', '../src/**/*.tsx'],
compilerOptions: {

@@ -48,0 +49,0 @@ outDir: '../.tshy-build-tmp/esm',

@@ -6,2 +6,6 @@ export type TshyConfig = {

export type Dialect = 'commonjs' | 'esm';
export type ExportDetail = {
default: string;
[k: string]: string;
};
export type TshyExport = string | ({

@@ -15,2 +19,10 @@ types?: string;

require: string;
})) | ({
types?: string;
import?: ExportDetail;
require?: ExportDetail;
} & ({
import: ExportDetail;
} | {
require: ExportDetail;
}));

@@ -27,5 +39,6 @@ export type Package = {

export type Export = string | {
import?: string;
require?: string;
types?: string;
import?: Export;
require?: Export;
types?: Export;
default?: Export;
} | {

@@ -32,0 +45,0 @@ import?: string | {

import { writeFileSync } from 'fs';
import pkg from './package.js';
export default () => {
writeFileSync('package.json', JSON.stringify(pkg, null, 2) + '\n');
};
export default () => writeFileSync('package.json', JSON.stringify(pkg, null, 2) + '\n');
//# sourceMappingURL=write-package.js.map
{
"name": "tshy",
"version": "1.0.0-1",
"version": "1.0.0-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)",

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

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

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