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 4.1.2 to 5.0.0

12

CHANGELOG.md
# @rollup/plugin-typescript ChangeLog
## v5.0.0
_2020-06-22_
### Breaking Changes
- fix!: sync rollup and typescript file watch (#425)
### Bugfixes
- fix: Fix peer dep version (#461)
## v4.1.2

@@ -4,0 +16,0 @@

92

dist/index.es.js
import { resolve, dirname, relative, win32, posix } from 'path';
import { createFilter } from '@rollup/pluginutils';
import * as defaultTs from 'typescript';
import { DiagnosticCategory } from 'typescript';
import resolveId from 'resolve';

@@ -423,3 +424,76 @@ import { readFileSync } from 'fs';

// @see https://github.com/microsoft/TypeScript/blob/master/src/compiler/diagnosticMessages.json
var DiagnosticCode;
(function (DiagnosticCode) {
DiagnosticCode[DiagnosticCode["FILE_CHANGE_DETECTED"] = 6032] = "FILE_CHANGE_DETECTED";
DiagnosticCode[DiagnosticCode["FOUND_1_ERROR_WATCHING_FOR_FILE_CHANGES"] = 6193] = "FOUND_1_ERROR_WATCHING_FOR_FILE_CHANGES";
DiagnosticCode[DiagnosticCode["FOUND_N_ERRORS_WATCHING_FOR_FILE_CHANGES"] = 6194] = "FOUND_N_ERRORS_WATCHING_FOR_FILE_CHANGES";
})(DiagnosticCode || (DiagnosticCode = {}));
function createDeferred(timeout) {
let promise;
let resolve = () => { };
if (timeout) {
promise = Promise.race([
new Promise(r => setTimeout(r, timeout, true)),
new Promise(r => resolve = r)
]);
}
else {
promise = new Promise(r => resolve = r);
}
return { promise, resolve };
}
/**
* Typescript watch program helper to sync Typescript watch status with Rollup hooks.
*/
class WatchProgramHelper {
constructor() {
this._startDeferred = null;
this._finishDeferred = null;
}
watch(timeout = 1000) {
// Race watcher start promise against a timeout in case Typescript and Rollup change detection is not in sync.
this._startDeferred = createDeferred(timeout);
this._finishDeferred = createDeferred();
}
handleStatus(diagnostic) {
// Fullfil deferred promises by Typescript diagnostic message codes.
if (diagnostic.category === DiagnosticCategory.Message) {
switch (diagnostic.code) {
case DiagnosticCode.FILE_CHANGE_DETECTED:
this.resolveStart();
break;
case DiagnosticCode.FOUND_1_ERROR_WATCHING_FOR_FILE_CHANGES:
case DiagnosticCode.FOUND_N_ERRORS_WATCHING_FOR_FILE_CHANGES:
this.resolveFinish();
break;
}
}
}
resolveStart() {
if (this._startDeferred) {
this._startDeferred.resolve(false);
this._startDeferred = null;
}
}
resolveFinish() {
if (this._finishDeferred) {
this._finishDeferred.resolve();
this._finishDeferred = null;
}
}
async wait() {
var _a;
if (this._startDeferred) {
const timeout = await this._startDeferred.promise;
// If there is no file change detected by Typescript skip deferred promises.
if (timeout) {
this._startDeferred = null;
this._finishDeferred = null;
}
await ((_a = this._finishDeferred) === null || _a === void 0 ? void 0 : _a.promise);
}
}
}
/**
* Create a language service host to use with the Typescript compiler & type checking APIs.

@@ -430,7 +504,5 @@ * Typescript hosts are used to represent the user's system,

*/
function createWatchHost(ts, context, { formatHost, parsedOptions, writeFile, resolveModule }) {
function createWatchHost(ts, context, { formatHost, parsedOptions, writeFile, status, resolveModule }) {
const createProgram = ts.createEmitAndSemanticDiagnosticsBuilderProgram;
const baseHost = ts.createWatchCompilerHost(parsedOptions.fileNames, parsedOptions.options, ts.sys, createProgram, buildDiagnosticReporter(ts, context, formatHost),
// Ignore watch status changes
() => { }, parsedOptions.projectReferences);
const baseHost = ts.createWatchCompilerHost(parsedOptions.fileNames, parsedOptions.options, ts.sys, createProgram, buildDiagnosticReporter(ts, context, formatHost), status, parsedOptions.projectReferences);
return Object.assign(Object.assign({}, baseHost), {

@@ -456,2 +528,3 @@ /** Override the created program so an in-memory emit is used */

const emittedFiles = new Map();
const watchProgramHelper = new WatchProgramHelper();
const parsedOptions = parseTypescriptConfig(ts, tsconfig, compilerOptions);

@@ -477,2 +550,5 @@ parsedOptions.fileNames = parsedOptions.fileNames.filter(filter);

emittedFiles.set(fileName, data);
},
status(diagnostic) {
watchProgramHelper.handleStatus(diagnostic);
}

@@ -482,2 +558,7 @@ });

},
watchChange(id) {
if (!filter(id))
return;
watchProgramHelper.watch();
},
buildEnd() {

@@ -511,5 +592,6 @@ var _a;

},
load(id) {
async load(id) {
if (!filter(id))
return null;
await watchProgramHelper.wait();
const output = findTypescriptOutput(ts, parsedOptions, id, emittedFiles);

@@ -516,0 +598,0 @@ return output.code ? output : null;

@@ -427,3 +427,76 @@ 'use strict';

// @see https://github.com/microsoft/TypeScript/blob/master/src/compiler/diagnosticMessages.json
var DiagnosticCode;
(function (DiagnosticCode) {
DiagnosticCode[DiagnosticCode["FILE_CHANGE_DETECTED"] = 6032] = "FILE_CHANGE_DETECTED";
DiagnosticCode[DiagnosticCode["FOUND_1_ERROR_WATCHING_FOR_FILE_CHANGES"] = 6193] = "FOUND_1_ERROR_WATCHING_FOR_FILE_CHANGES";
DiagnosticCode[DiagnosticCode["FOUND_N_ERRORS_WATCHING_FOR_FILE_CHANGES"] = 6194] = "FOUND_N_ERRORS_WATCHING_FOR_FILE_CHANGES";
})(DiagnosticCode || (DiagnosticCode = {}));
function createDeferred(timeout) {
let promise;
let resolve = () => { };
if (timeout) {
promise = Promise.race([
new Promise(r => setTimeout(r, timeout, true)),
new Promise(r => resolve = r)
]);
}
else {
promise = new Promise(r => resolve = r);
}
return { promise, resolve };
}
/**
* Typescript watch program helper to sync Typescript watch status with Rollup hooks.
*/
class WatchProgramHelper {
constructor() {
this._startDeferred = null;
this._finishDeferred = null;
}
watch(timeout = 1000) {
// Race watcher start promise against a timeout in case Typescript and Rollup change detection is not in sync.
this._startDeferred = createDeferred(timeout);
this._finishDeferred = createDeferred();
}
handleStatus(diagnostic) {
// Fullfil deferred promises by Typescript diagnostic message codes.
if (diagnostic.category === defaultTs.DiagnosticCategory.Message) {
switch (diagnostic.code) {
case DiagnosticCode.FILE_CHANGE_DETECTED:
this.resolveStart();
break;
case DiagnosticCode.FOUND_1_ERROR_WATCHING_FOR_FILE_CHANGES:
case DiagnosticCode.FOUND_N_ERRORS_WATCHING_FOR_FILE_CHANGES:
this.resolveFinish();
break;
}
}
}
resolveStart() {
if (this._startDeferred) {
this._startDeferred.resolve(false);
this._startDeferred = null;
}
}
resolveFinish() {
if (this._finishDeferred) {
this._finishDeferred.resolve();
this._finishDeferred = null;
}
}
async wait() {
var _a;
if (this._startDeferred) {
const timeout = await this._startDeferred.promise;
// If there is no file change detected by Typescript skip deferred promises.
if (timeout) {
this._startDeferred = null;
this._finishDeferred = null;
}
await ((_a = this._finishDeferred) === null || _a === void 0 ? void 0 : _a.promise);
}
}
}
/**
* Create a language service host to use with the Typescript compiler & type checking APIs.

@@ -434,7 +507,5 @@ * Typescript hosts are used to represent the user's system,

*/
function createWatchHost(ts, context, { formatHost, parsedOptions, writeFile, resolveModule }) {
function createWatchHost(ts, context, { formatHost, parsedOptions, writeFile, status, resolveModule }) {
const createProgram = ts.createEmitAndSemanticDiagnosticsBuilderProgram;
const baseHost = ts.createWatchCompilerHost(parsedOptions.fileNames, parsedOptions.options, ts.sys, createProgram, buildDiagnosticReporter(ts, context, formatHost),
// Ignore watch status changes
() => { }, parsedOptions.projectReferences);
const baseHost = ts.createWatchCompilerHost(parsedOptions.fileNames, parsedOptions.options, ts.sys, createProgram, buildDiagnosticReporter(ts, context, formatHost), status, parsedOptions.projectReferences);
return Object.assign(Object.assign({}, baseHost), {

@@ -460,2 +531,3 @@ /** Override the created program so an in-memory emit is used */

const emittedFiles = new Map();
const watchProgramHelper = new WatchProgramHelper();
const parsedOptions = parseTypescriptConfig(ts, tsconfig, compilerOptions);

@@ -481,2 +553,5 @@ parsedOptions.fileNames = parsedOptions.fileNames.filter(filter);

emittedFiles.set(fileName, data);
},
status(diagnostic) {
watchProgramHelper.handleStatus(diagnostic);
}

@@ -486,2 +561,7 @@ });

},
watchChange(id) {
if (!filter(id))
return;
watchProgramHelper.watch();
},
buildEnd() {

@@ -515,5 +595,6 @@ var _a;

},
load(id) {
async load(id) {
if (!filter(id))
return null;
await watchProgramHelper.wait();
const output = findTypescriptOutput(ts, parsedOptions, id, emittedFiles);

@@ -520,0 +601,0 @@ return output.code ? output : null;

4

package.json
{
"name": "@rollup/plugin-typescript",
"version": "4.1.2",
"version": "5.0.0",
"publishConfig": {

@@ -49,3 +49,3 @@ "access": "public"

"tslib": "*",
"typescript": ">=2.1.0"
"typescript": ">=3.4.0"
},

@@ -52,0 +52,0 @@ "dependencies": {

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