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

esbuild-plugin-tsc

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

esbuild-plugin-tsc - npm Package Compare versions

Comparing version 0.0.1 to 0.0.2

2

package.json
{
"name": "esbuild-plugin-tsc",
"version": "0.0.1",
"version": "0.0.2",
"description": "An esbuild plugin which uses tsc to compile typescript files.",

@@ -5,0 +5,0 @@ "main": "src/index.js",

const fs = require('fs').promises;
const path = require('path');
const typescript = require('typescript');

@@ -36,36 +37,36 @@ const stripComments = require('strip-comments');

module.exports = (
options = { tsconfigPath: './tsconfig.json', force: false, tsx: true }
) => ({
module.exports = (options = {}) => ({
name: 'tsc',
setup(build) {
const tsconfigPath =
options.tsconfigPath ?? path.join(process.cwd(), './tsconfig.json');
const forceTsc = options.force ?? false;
const tsx = options.tsx ?? true;
let tsconfigRaw = null;
build.onLoad(
{ filter: options.tsx ? /\.tsx?$/ : /\.ts$/ },
async (args) => {
if (!tsconfigRaw) {
tsconfigRaw = JSON.parse(
stripComments(await fs.readFile(tsconfigPath, 'utf8')) || null
);
if (tsconfigRaw.sourcemap) {
tsconfigRaw.sourcemap = false;
tsconfigRaw.inlineSources = true;
tsconfigRaw.inlineSourceMap = true;
}
build.onLoad({ filter: tsx ? /\.tsx?$/ : /\.ts$/ }, async (args) => {
if (!tsconfigRaw) {
tsconfigRaw = JSON.parse(
stripComments(await fs.readFile(tsconfigPath, 'utf8')) || null
);
if (tsconfigRaw.sourcemap) {
tsconfigRaw.sourcemap = false;
tsconfigRaw.inlineSources = true;
tsconfigRaw.inlineSourceMap = true;
}
}
const ts = await fs.readFile(args.path, 'utf8');
if (
options.force ||
(tsconfigRaw.compilerOptions &&
tsconfigRaw.compilerOptions.emitDecoratorMetadata &&
hasDecorator(ts))
) {
const program = typescript.transpileModule(ts, tsconfigRaw);
return { contents: program.outputText };
}
const ts = await fs.readFile(args.path, 'utf8');
if (
forceTsc ||
(tsconfigRaw.compilerOptions &&
tsconfigRaw.compilerOptions.emitDecoratorMetadata &&
hasDecorator(ts))
) {
const program = typescript.transpileModule(ts, tsconfigRaw);
return { contents: program.outputText };
}
);
});
},
});
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