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

@rollup/plugin-typescript

Package Overview
Dependencies
Maintainers
4
Versions
47
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@rollup/plugin-typescript - npm Package Compare versions

Comparing version 8.2.4 to 8.2.5

8

CHANGELOG.md
# @rollup/plugin-typescript ChangeLog
## v8.2.5
_2021-07-30_
### Bugfixes
- fix: incremental typescript cache (#963)
## v8.2.4

@@ -4,0 +12,0 @@

63

dist/index.es.js

@@ -6,3 +6,3 @@ import path, { resolve as resolve$1, dirname, relative, win32, posix, normalize } from 'path';

import resolve from 'resolve';
import fs, { readFileSync } from 'fs';
import fs, { readFileSync, promises } from 'fs';

@@ -116,3 +116,3 @@ /**

const getPluginOptions = (options) => {
const { cacheDir, exclude, include, transformers, tsconfig, tslib, typescript } = options, compilerOptions = __rest(options, ["cacheDir", "exclude", "include", "transformers", "tsconfig", "tslib", "typescript"]);
const { cacheDir, exclude, include, transformers, tsconfig, tslib, typescript, outputToFilesystem } = options, compilerOptions = __rest(options, ["cacheDir", "exclude", "include", "transformers", "tsconfig", "tslib", "typescript", "outputToFilesystem"]);
const filter = createFilter(include || ['*.ts+(|x)', '**/*.ts+(|x)'], exclude);

@@ -126,3 +126,4 @@ return {

tslib: tslib || getTsLibPath(),
transformers
transformers,
outputToFilesystem
};

@@ -354,3 +355,3 @@ };

*/
function validatePaths(ts, context, compilerOptions, outputOptions) {
function validatePaths(context, compilerOptions, outputOptions) {
if (compilerOptions.out) {

@@ -371,13 +372,2 @@ context.error(`@rollup/plugin-typescript: Deprecated Typescript compiler option 'out' is not supported. Use 'outDir' instead.`);

}
const tsBuildInfoPath = ts.getTsBuildInfoEmitOutputFilePath(compilerOptions);
if (tsBuildInfoPath && compilerOptions.incremental) {
if (!outputOptions.dir) {
context.error(`@rollup/plugin-typescript: Rollup 'dir' option must be used when Typescript compiler options 'tsBuildInfoFile' or 'incremental' are specified.`);
}
// Checks if the given path lies within Rollup output dir
const fromRollupDirToTs = relative(outputOptions.dir, tsBuildInfoPath);
if (fromRollupDirToTs.startsWith('..')) {
context.error(`@rollup/plugin-typescript: Path of Typescript compiler option 'tsBuildInfoFile' must be located inside Rollup 'dir' option.`);
}
}
if (compilerOptions.declaration || compilerOptions.declarationMap || compilerOptions.composite) {

@@ -438,2 +428,30 @@ if (DIRECTORY_PROPS.every((dirProperty) => !compilerOptions[dirProperty])) {

}
function normalizePath(fileName) {
return fileName.split(win32.sep).join(posix.sep);
}
async function emitFile({ dir }, outputToFilesystem, context, filePath, fileSource) {
const normalizedFilePath = normalizePath(filePath);
// const normalizedPath = normalizePath(filePath);
// Note: `dir` can be a value like `dist` in which case, `path.relative` could result in a value
// of something like `'../.tsbuildinfo'. Our else-case below needs to mimic `path.relative`
// returning a dot-notated relative path, so the first if-then branch is entered into
const relativePath = dir ? relative(dir, normalizedFilePath) : '..';
// legal paths do not start with . nor .. : https://github.com/rollup/rollup/issues/3507#issuecomment-616495912
if (relativePath.startsWith('..')) {
if (outputToFilesystem == null) {
context.warn(`@rollup/plugin-typescript: outputToFilesystem option is defaulting to true.`);
}
if (outputToFilesystem !== false) {
await promises.mkdir(dirname(normalizedFilePath), { recursive: true });
await promises.writeFile(normalizedFilePath, fileSource);
}
}
else {
context.emitFile({
type: 'asset',
fileName: relativePath,
source: fileSource
});
}
}

@@ -679,3 +697,3 @@ const pluginName = '@rollup/plugin-typescript';

function typescript(options = {}) {
const { cacheDir, compilerOptions, filter, transformers, tsconfig, tslib, typescript: ts } = getPluginOptions(options);
const { cacheDir, compilerOptions, filter, transformers, tsconfig, tslib, typescript: ts, outputToFilesystem } = getPluginOptions(options);
const tsCache = new TSCache(cacheDir);

@@ -689,5 +707,2 @@ const emittedFiles = new Map();

let program = null;
function normalizePath(fileName) {
return fileName.split(win32.sep).join(posix.sep);
}
return {

@@ -735,3 +750,3 @@ name: 'typescript',

validateSourceMap(this, parsedOptions.options, outputOptions, parsedOptions.autoSetSourceMap);
validatePaths(ts, this, parsedOptions.options, outputOptions);
validatePaths(this, parsedOptions.options, outputOptions);
},

@@ -766,3 +781,3 @@ resolveId(importee, importer) {

},
generateBundle(outputOptions) {
async generateBundle(outputOptions) {
parsedOptions.fileNames.forEach((fileName) => {

@@ -790,7 +805,3 @@ const output = findTypescriptOutput(ts, parsedOptions, fileName, emittedFiles, tsCache);

if (tsBuildInfoSource) {
this.emitFile({
type: 'asset',
fileName: normalizePath(relative(outputOptions.dir, tsBuildInfoPath)),
source: tsBuildInfoSource
});
await emitFile(outputOptions, outputToFilesystem, this, tsBuildInfoPath, tsBuildInfoSource);
}

@@ -797,0 +808,0 @@ }

@@ -143,3 +143,3 @@ 'use strict';

const getPluginOptions = (options) => {
const { cacheDir, exclude, include, transformers, tsconfig, tslib, typescript } = options, compilerOptions = __rest(options, ["cacheDir", "exclude", "include", "transformers", "tsconfig", "tslib", "typescript"]);
const { cacheDir, exclude, include, transformers, tsconfig, tslib, typescript, outputToFilesystem } = options, compilerOptions = __rest(options, ["cacheDir", "exclude", "include", "transformers", "tsconfig", "tslib", "typescript", "outputToFilesystem"]);
const filter = pluginutils.createFilter(include || ['*.ts+(|x)', '**/*.ts+(|x)'], exclude);

@@ -153,3 +153,4 @@ return {

tslib: tslib || getTsLibPath(),
transformers
transformers,
outputToFilesystem
};

@@ -381,3 +382,3 @@ };

*/
function validatePaths(ts, context, compilerOptions, outputOptions) {
function validatePaths(context, compilerOptions, outputOptions) {
if (compilerOptions.out) {

@@ -398,13 +399,2 @@ context.error(`@rollup/plugin-typescript: Deprecated Typescript compiler option 'out' is not supported. Use 'outDir' instead.`);

}
const tsBuildInfoPath = ts.getTsBuildInfoEmitOutputFilePath(compilerOptions);
if (tsBuildInfoPath && compilerOptions.incremental) {
if (!outputOptions.dir) {
context.error(`@rollup/plugin-typescript: Rollup 'dir' option must be used when Typescript compiler options 'tsBuildInfoFile' or 'incremental' are specified.`);
}
// Checks if the given path lies within Rollup output dir
const fromRollupDirToTs = path.relative(outputOptions.dir, tsBuildInfoPath);
if (fromRollupDirToTs.startsWith('..')) {
context.error(`@rollup/plugin-typescript: Path of Typescript compiler option 'tsBuildInfoFile' must be located inside Rollup 'dir' option.`);
}
}
if (compilerOptions.declaration || compilerOptions.declarationMap || compilerOptions.composite) {

@@ -465,2 +455,30 @@ if (DIRECTORY_PROPS.every((dirProperty) => !compilerOptions[dirProperty])) {

}
function normalizePath(fileName) {
return fileName.split(path.win32.sep).join(path.posix.sep);
}
async function emitFile({ dir }, outputToFilesystem, context, filePath, fileSource) {
const normalizedFilePath = normalizePath(filePath);
// const normalizedPath = normalizePath(filePath);
// Note: `dir` can be a value like `dist` in which case, `path.relative` could result in a value
// of something like `'../.tsbuildinfo'. Our else-case below needs to mimic `path.relative`
// returning a dot-notated relative path, so the first if-then branch is entered into
const relativePath = dir ? path.relative(dir, normalizedFilePath) : '..';
// legal paths do not start with . nor .. : https://github.com/rollup/rollup/issues/3507#issuecomment-616495912
if (relativePath.startsWith('..')) {
if (outputToFilesystem == null) {
context.warn(`@rollup/plugin-typescript: outputToFilesystem option is defaulting to true.`);
}
if (outputToFilesystem !== false) {
await fs.promises.mkdir(path.dirname(normalizedFilePath), { recursive: true });
await fs.promises.writeFile(normalizedFilePath, fileSource);
}
}
else {
context.emitFile({
type: 'asset',
fileName: relativePath,
source: fileSource
});
}
}

@@ -706,3 +724,3 @@ const pluginName = '@rollup/plugin-typescript';

function typescript(options = {}) {
const { cacheDir, compilerOptions, filter, transformers, tsconfig, tslib, typescript: ts } = getPluginOptions(options);
const { cacheDir, compilerOptions, filter, transformers, tsconfig, tslib, typescript: ts, outputToFilesystem } = getPluginOptions(options);
const tsCache = new TSCache(cacheDir);

@@ -716,5 +734,2 @@ const emittedFiles = new Map();

let program = null;
function normalizePath(fileName) {
return fileName.split(path.win32.sep).join(path.posix.sep);
}
return {

@@ -762,3 +777,3 @@ name: 'typescript',

validateSourceMap(this, parsedOptions.options, outputOptions, parsedOptions.autoSetSourceMap);
validatePaths(ts, this, parsedOptions.options, outputOptions);
validatePaths(this, parsedOptions.options, outputOptions);
},

@@ -793,3 +808,3 @@ resolveId(importee, importer) {

},
generateBundle(outputOptions) {
async generateBundle(outputOptions) {
parsedOptions.fileNames.forEach((fileName) => {

@@ -817,7 +832,3 @@ const output = findTypescriptOutput(ts, parsedOptions, fileName, emittedFiles, tsCache);

if (tsBuildInfoSource) {
this.emitFile({
type: 'asset',
fileName: normalizePath(path.relative(outputOptions.dir, tsBuildInfoPath)),
source: tsBuildInfoSource
});
await emitFile(outputOptions, outputToFilesystem, this, tsBuildInfoPath, tsBuildInfoSource);
}

@@ -824,0 +835,0 @@ }

{
"name": "@rollup/plugin-typescript",
"version": "8.2.4",
"version": "8.2.5",
"publishConfig": {

@@ -5,0 +5,0 @@ "access": "public"

@@ -72,2 +72,7 @@ /* eslint-disable no-use-before-define */

transformers?: CustomTransformerFactories;
/**
* When set to false, force non-cached files to always be emitted in the output directory.output
* If not set, will default to true with a warning.
*/
outputToFilesystem?: boolean;
}

@@ -74,0 +79,0 @@

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