Socket
Socket
Sign inDemoInstall

@wessberg/rollup-plugin-ts

Package Overview
Dependencies
Maintainers
1
Versions
185
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@wessberg/rollup-plugin-ts - npm Package Compare versions

Comparing version 0.0.3 to 0.0.4

9

CHANGELOG.md

@@ -0,1 +1,10 @@

<a name="0.0.4"></a>
## <small>0.0.4 (2018-03-29)</small>
* 0.0.4 ([fe16f03](https://github.com/wessberg/rollup-plugin-ts/commit/fe16f03))
* Bumped version ([5d2542f](https://github.com/wessberg/rollup-plugin-ts/commit/5d2542f))
* Fixed a few bugs ([1b6930e](https://github.com/wessberg/rollup-plugin-ts/commit/1b6930e))
<a name="0.0.3"></a>

@@ -2,0 +11,0 @@ ## <small>0.0.3 (2018-03-29)</small>

28

dist/cjs/index.js

@@ -43,2 +43,7 @@ "use strict";

const filter = rollup_pluginutils_1.createFilter(include, exclude);
/**
* The file names that has been passed through Rollup and into this plugin
* @type {Set<string>}
*/
const transformedFileNames = new Set();
return {

@@ -57,9 +62,14 @@ name: "Typescript Rollup Plugin",

const generatedIds = new Set(outputOptions.bundle.modules.map(module => helpers_1.ensureRelative(root, module.id)));
// Clear all file names from the Set of transformed file names that has since been removed from Rollup compilation
const removedFileNames = new Set();
for (const fileName of transformedFileNames) {
if (!generatedIds.has(fileName)) {
removedFileNames.add(fileName);
transformedFileNames.delete(fileName);
}
}
// Remove all removed filenames from the LanguageService
removedFileNames.forEach(fileName => languageServiceHost.removeFile(fileName));
// Take all file names from the language service
const languageServiceFileNames = languageServiceHost.getScriptFileNames();
// Remove all filenames from the LanguageService that isn't part of the generated ids for the bundle
for (const filename of languageServiceFileNames) {
if (!generatedIds.has(filename))
languageServiceHost.removeFile(filename);
}
if (formatHost != null) {

@@ -93,2 +103,4 @@ helpers_1.printDiagnostics(languageServiceHost.getAllDiagnostics(), formatHost);

async transform(code, file) {
// Convert the file into a relative path
const relativePath = helpers_1.ensureRelative(root, file);
// Assert that the file passes the filter

@@ -98,2 +110,4 @@ if (!filter(file) || !file.endsWith(constants_1.TYPESCRIPT_EXTENSION)) {

}
// Add the file name to the Set of files that has been passed through this plugin
transformedFileNames.add(relativePath);
// Make sure that the compiler options are in fact defined

@@ -105,7 +119,5 @@ if (typescriptOptions == null) {

if (languageServiceHost == null) {
languageServiceHost = new typescript_language_service_host_1.TypescriptLanguageServiceHost(typescriptOptions);
languageServiceHost = new typescript_language_service_host_1.TypescriptLanguageServiceHost(root, typescriptOptions);
formatHost = new format_host_1.FormatHost(languageServiceHost, root);
}
// Convert the file into a relative path
const relativePath = helpers_1.ensureRelative(root, file);
// Add the file to the LanguageServiceHost

@@ -112,0 +124,0 @@ languageServiceHost.addFile({ fileName: relativePath, text: code });

@@ -9,2 +9,3 @@ import { ITypescriptLanguageServiceEmitResult } from "./i-typescript-language-service-emit-result";

export declare class TypescriptLanguageServiceHost implements ITypescriptLanguageServiceHost {
private readonly appRoot;
private typescriptOptions;

@@ -21,3 +22,3 @@ /**

private readonly files;
constructor(typescriptOptions: ParsedCommandLine);
constructor(appRoot: string, typescriptOptions: ParsedCommandLine);
/**

@@ -24,0 +25,0 @@ * Gets the CompilerOptions

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const helpers_1 = require("./helpers");
const i_typescript_language_service_emit_result_1 = require("./i-typescript-language-service-emit-result");

@@ -10,3 +11,4 @@ const typescript_1 = require("typescript");

class TypescriptLanguageServiceHost {
constructor(typescriptOptions) {
constructor(appRoot, typescriptOptions) {
this.appRoot = appRoot;
this.typescriptOptions = typescriptOptions;

@@ -33,2 +35,10 @@ /**

this.typescriptOptions = options;
// Add all of the fileNames from the options. These may not come from Rollup since Rollup won't
// necessarily pass all matched files through the plugin (if the files contain only types)
this.typescriptOptions.fileNames.forEach(fileName => {
const relative = helpers_1.ensureRelative(this.appRoot, fileName);
if (!this.files.has(relative) && typescript_1.sys.fileExists(fileName)) {
this.addFile({ fileName: relative, text: typescript_1.sys.readFile(fileName) });
}
});
}

@@ -35,0 +45,0 @@ /**

@@ -41,2 +41,7 @@ // tslint:disable:no-any

const filter = createFilter(include, exclude);
/**
* The file names that has been passed through Rollup and into this plugin
* @type {Set<string>}
*/
const transformedFileNames = new Set();
return {

@@ -55,9 +60,14 @@ name: "Typescript Rollup Plugin",

const generatedIds = new Set(outputOptions.bundle.modules.map(module => ensureRelative(root, module.id)));
// Clear all file names from the Set of transformed file names that has since been removed from Rollup compilation
const removedFileNames = new Set();
for (const fileName of transformedFileNames) {
if (!generatedIds.has(fileName)) {
removedFileNames.add(fileName);
transformedFileNames.delete(fileName);
}
}
// Remove all removed filenames from the LanguageService
removedFileNames.forEach(fileName => languageServiceHost.removeFile(fileName));
// Take all file names from the language service
const languageServiceFileNames = languageServiceHost.getScriptFileNames();
// Remove all filenames from the LanguageService that isn't part of the generated ids for the bundle
for (const filename of languageServiceFileNames) {
if (!generatedIds.has(filename))
languageServiceHost.removeFile(filename);
}
if (formatHost != null) {

@@ -91,2 +101,4 @@ printDiagnostics(languageServiceHost.getAllDiagnostics(), formatHost);

async transform(code, file) {
// Convert the file into a relative path
const relativePath = ensureRelative(root, file);
// Assert that the file passes the filter

@@ -96,2 +108,4 @@ if (!filter(file) || !file.endsWith(TYPESCRIPT_EXTENSION)) {

}
// Add the file name to the Set of files that has been passed through this plugin
transformedFileNames.add(relativePath);
// Make sure that the compiler options are in fact defined

@@ -103,7 +117,5 @@ if (typescriptOptions == null) {

if (languageServiceHost == null) {
languageServiceHost = new TypescriptLanguageServiceHost(typescriptOptions);
languageServiceHost = new TypescriptLanguageServiceHost(root, typescriptOptions);
formatHost = new FormatHost(languageServiceHost, root);
}
// Convert the file into a relative path
const relativePath = ensureRelative(root, file);
// Add the file to the LanguageServiceHost

@@ -110,0 +122,0 @@ languageServiceHost.addFile({ fileName: relativePath, text: code });

@@ -9,2 +9,3 @@ import { ITypescriptLanguageServiceEmitResult } from "./i-typescript-language-service-emit-result";

export declare class TypescriptLanguageServiceHost implements ITypescriptLanguageServiceHost {
private readonly appRoot;
private typescriptOptions;

@@ -21,3 +22,3 @@ /**

private readonly files;
constructor(typescriptOptions: ParsedCommandLine);
constructor(appRoot: string, typescriptOptions: ParsedCommandLine);
/**

@@ -24,0 +25,0 @@ * Gets the CompilerOptions

@@ -0,1 +1,2 @@

import { ensureRelative } from "./helpers";
import { TypescriptLanguageServiceEmitResultKind } from "./i-typescript-language-service-emit-result";

@@ -8,3 +9,4 @@ import { createLanguageService, createDocumentRegistry, ScriptSnapshot, sys, getDefaultLibFilePath, createProgram, getPreEmitDiagnostics } from "typescript";

export class TypescriptLanguageServiceHost {
constructor(typescriptOptions) {
constructor(appRoot, typescriptOptions) {
this.appRoot = appRoot;
this.typescriptOptions = typescriptOptions;

@@ -31,2 +33,10 @@ /**

this.typescriptOptions = options;
// Add all of the fileNames from the options. These may not come from Rollup since Rollup won't
// necessarily pass all matched files through the plugin (if the files contain only types)
this.typescriptOptions.fileNames.forEach(fileName => {
const relative = ensureRelative(this.appRoot, fileName);
if (!this.files.has(relative) && sys.fileExists(fileName)) {
this.addFile({ fileName: relative, text: sys.readFile(fileName) });
}
});
}

@@ -33,0 +43,0 @@ /**

{
"name": "@wessberg/rollup-plugin-ts",
"version": "0.0.3",
"version": "0.0.4",
"description": "A Rollup plugin for Typescript",

@@ -5,0 +5,0 @@ "scripts": {

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