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

rollup-plugin-typescript2

Package Overview
Dependencies
Maintainers
1
Versions
77
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rollup-plugin-typescript2 - npm Package Compare versions

Comparing version 0.32.1 to 0.33.0

14

dist/context.d.ts

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

import { PluginContext } from "rollup";
export interface IContext {

@@ -13,2 +14,3 @@ warn(message: string | (() => string)): void;

}
/** mainly to be used in options hook, but can be used in other hooks too */
export declare class ConsoleContext implements IContext {

@@ -23,2 +25,14 @@ private verbosity;

}
/** cannot be used in options hook (which does not have this.warn and this.error), but can be in other hooks */
export declare class RollupContext implements IContext {
private verbosity;
private bail;
private context;
private prefix;
constructor(verbosity: VerbosityLevel, bail: boolean, context: PluginContext, prefix?: string);
warn(message: string | (() => string)): void;
error(message: string | (() => string)): void;
info(message: string | (() => string)): void;
debug(message: string | (() => string)): void;
}
//# sourceMappingURL=context.d.ts.map

6

dist/diagnostics-format-host.d.ts

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

/// <reference types="node" />
import * as path from "path";
import * as tsTypes from "typescript";
export declare class FormatHost implements tsTypes.FormatDiagnosticsHost {
getCurrentDirectory(): string;
getCanonicalFileName(fileName: string): string;
getNewLine(): string;
getCanonicalFileName: typeof path.normalize;
getNewLine: () => string;
}
export declare const formatHost: FormatHost;
//# sourceMappingURL=diagnostics-format-host.d.ts.map

@@ -14,20 +14,23 @@ import * as tsTypes from "typescript";

setLanguageService(service: tsTypes.LanguageService): void;
setSnapshot(fileName: string, data: string): tsTypes.IScriptSnapshot;
setSnapshot(fileName: string, source: string): tsTypes.IScriptSnapshot;
getScriptSnapshot(fileName: string): tsTypes.IScriptSnapshot | undefined;
getCurrentDirectory(): string;
getScriptFileNames: () => string[];
getScriptVersion(fileName: string): string;
getScriptFileNames(): string[];
getCompilationSettings(): tsTypes.CompilerOptions;
getDefaultLibFileName(opts: tsTypes.CompilerOptions): string;
useCaseSensitiveFileNames(): boolean;
readDirectory(path: string, extensions?: string[], exclude?: string[], include?: string[]): string[];
readFile(path: string, encoding?: string): string | undefined;
fileExists(path: string): boolean;
realpath(path: string): string;
getTypeRootsVersion(): number;
directoryExists(directoryName: string): boolean;
getDirectories(directoryName: string): string[];
getCustomTransformers(): tsTypes.CustomTransformers | undefined;
trace(line: string): void;
getCompilationSettings: () => tsTypes.CompilerOptions;
getTypeRootsVersion: () => number;
getCurrentDirectory: () => string;
useCaseSensitiveFileNames: () => boolean;
getDefaultLibFileName: typeof tsTypes.getDefaultLibFilePath;
readDirectory: (path: string, extensions?: readonly string[] | undefined, exclude?: readonly string[] | undefined, include?: readonly string[] | undefined, depth?: number | undefined) => string[];
readFile: (path: string, encoding?: string | undefined) => string | undefined;
fileExists: (path: string) => boolean;
directoryExists: (path: string) => boolean;
getDirectories: (path: string) => string[];
realpath: (path: string) => string;
trace: {
(...data: any[]): void;
(message?: any, ...optionalParams: any[]): void;
};
}
//# sourceMappingURL=host.d.ts.map
import { IContext } from "./context";
import { IDiagnostics } from "./tscache";
export declare function printDiagnostics(context: IContext, diagnostics: IDiagnostics[], pretty: boolean): void;
export declare function printDiagnostics(context: IContext, diagnostics: IDiagnostics[], pretty?: boolean): void;
//# sourceMappingURL=print-diagnostics.d.ts.map

@@ -8,31 +8,19 @@ import { ICache } from "./icache";

private cacheRoot;
private checkNewCache;
private oldCacheRoot;
private newCacheRoot;
private rolled;
/**
* @param cacheRoot: root folder for the cache
* @param checkNewCache: whether to also look in new cache when reading from cache
*/
constructor(cacheRoot: string, checkNewCache: boolean);
/**
* @returns true if name exist in old cache (or either old of new cache if checkNewCache is true)
*/
/** @param cacheRoot: root folder for the cache */
constructor(cacheRoot: string);
/** @returns true if name exists in either old cache or new cache */
exists(name: string): boolean;
path(name: string): string;
/**
* @returns true if old cache contains all names and nothing more
*/
/** @returns true if old cache contains all names and nothing more */
match(names: string[]): boolean;
/**
* @returns data for name, must exist in old cache (or either old of new cache if checkNewCache is true)
*/
/** @returns data for name, must exist in either old cache or new cache */
read(name: string): DataType | null | undefined;
write(name: string, data: DataType): void;
touch(name: string): void;
/**
* clears old cache and moves new in its place
*/
/** clears old cache and moves new in its place */
roll(): void;
}
//# sourceMappingURL=rollingcache.d.ts.map

@@ -40,3 +40,3 @@ import * as tsTypes from "typescript";

constructor(noCache: boolean, hashIgnoreUnknown: boolean, host: tsTypes.LanguageServiceHost, cacheRoot: string, options: tsTypes.CompilerOptions, rollupConfig: any, rootFilenames: string[], context: IContext);
clean(): void;
private clean;
setDependency(importee: string, importer: string): void;

@@ -50,7 +50,10 @@ walkTree(cb: (id: string) => void | false): void;

private getDiagnostics;
private getCached;
private init;
private markAsDirty;
/** @returns true if node, any of its imports, or any ambient types changed */
private isDirty;
private makeName;
/** @returns an FS-safe hash string for use as a path to the cached content */
private createHash;
}
//# sourceMappingURL=tscache.d.ts.map
{
"name": "rollup-plugin-typescript2",
"version": "0.32.1",
"version": "0.33.0",
"description": "Seamless integration between Rollup and TypeScript. Now with errors.",

@@ -38,3 +38,2 @@ "main": "dist/rollup-plugin-typescript2.cjs.js",

"fs-extra": "^10.0.0",
"resolve": "^1.20.0",
"tslib": "^2.4.0"

@@ -67,3 +66,3 @@ },

"rollup-plugin-re": "1.0.7",
"rollup-plugin-typescript2": "0.31.2",
"rollup-plugin-typescript2": "0.32.1",
"ts-jest": "^28.0.0",

@@ -70,0 +69,0 @@ "tslint": "6.1.3",

@@ -9,5 +9,5 @@ # rollup-plugin-typescript2

This is a rewrite of original rollup-plugin-typescript, starting and borrowing from [this fork](https://github.com/alexlur/rollup-plugin-typescript).
This is a rewrite of the [original](https://github.com/rollup/rollup-plugin-typescript/tree/v0.8.1) `rollup-plugin-typescript`, starting and borrowing from [this fork](https://github.com/alexlur/rollup-plugin-typescript).
This version is somewhat slower than original, but it will print out typescript syntactic and semantic diagnostic messages (the main reason for using typescript after all).
This version is somewhat slower than the original, but it will print out TypeScript syntactic and semantic diagnostic messages (the main reason for using TypeScript after all).

@@ -38,5 +38,7 @@ ## Installation

The plugin inherits all compiler options and file lists from your `tsconfig.json` file. If your tsconfig has another name or another relative path from the root directory, see `tsconfigDefaults`, `tsconfig` and `tsconfigOverride` options below. This also allows for passing in different tsconfig files depending on your build target.
This plugin inherits all compiler options and file lists from your `tsconfig.json` file.
If your `tsconfig` has another name or another relative path from the root directory, see `tsconfigDefaults`, `tsconfig`, and `tsconfigOverride` options below.
This also allows for passing in different `tsconfig` files depending on your build target.
#### Some compiler options are forced
### Some compiler options are forced

@@ -49,14 +51,14 @@ * `noEmitHelpers`: false

* `inlineSourceMap`: false (see [#71](https://github.com/ezolenko/rollup-plugin-typescript2/issues/71))
* `outDir`: `./placeholder` in cache root, see [#83](https://github.com/ezolenko/rollup-plugin-typescript2/issues/83) and [Microsoft/TypeScript#24715](https://github.com/Microsoft/TypeScript/issues/24715)
* `declarationDir`: Rollup's `output.file` or `output.dir` (*only if `useTsconfigDeclarationDir` is false in the plugin options*)
* `outDir`: `./placeholder` in cache root (see [#83](https://github.com/ezolenko/rollup-plugin-typescript2/issues/83) and [Microsoft/TypeScript#24715](https://github.com/Microsoft/TypeScript/issues/24715))
* `declarationDir`: Rollup's `output.file` or `output.dir` (*unless `useTsconfigDeclarationDir` is true in the plugin options*)
* `moduleResolution`: `node` (*`classic` is [deprecated](https://www.typescriptlang.org/docs/handbook/module-resolution.html). It also breaks this plugin, see [#12](https://github.com/ezolenko/rollup-plugin-typescript2/issues/12) and [#14](https://github.com/ezolenko/rollup-plugin-typescript2/issues/14)*)
* `allowNonTsExtensions`: true to let other plugins on the chain generate typescript, update plugin's include filter to pick them up (see [#111](https://github.com/ezolenko/rollup-plugin-typescript2/issues/111))
* `allowNonTsExtensions`: true to let other plugins on the chain generate typescript; update plugin's `include` filter to pick them up (see [#111](https://github.com/ezolenko/rollup-plugin-typescript2/issues/111))
#### Some compiler options have more than one compatible value.
### Some compiler options have more than one compatible value
* `module`: defaults to `ES2015`, other valid value is `ESNext` (required for dynamic imports, see [#54](https://github.com/ezolenko/rollup-plugin-typescript2/issues/54)).
* `module`: defaults to `ES2015`. Other valid values are `ES2020` and `ESNext` (required for dynamic imports, see [#54](https://github.com/ezolenko/rollup-plugin-typescript2/issues/54)).
#### Some options need additional configuration on plugin side
### Some options need additional configuration on plugin side
* `allowJs`: lets typescript process js files as well, if you use it, modify plugin's `include` option to add `"*.js+(|x)", "**/*.js+(|x)"` (might want to exclude node_modules, it will slow down the build significantly).
* `allowJs`: lets TypeScript process JS files as well. If you use it, modify this plugin's `include` option to add `"*.js+(|x)", "**/*.js+(|x)"` (might also want to `exclude` `"**/node_modules/**/*"`, as it can slow down the build significantly).

@@ -67,7 +69,7 @@ ### Compatibility

Must be before rollup-plugin-typescript2 in the plugin list, especially when `browser: true` option is used, see [#66](https://github.com/ezolenko/rollup-plugin-typescript2/issues/66)
Must be before `rollup-plugin-typescript2` in the plugin list, especially when the `browser: true` option is used (see [#66](https://github.com/ezolenko/rollup-plugin-typescript2/issues/66)).
#### @rollup/plugin-commonjs
See explanation for `rollupCommonJSResolveHack` option below.
See the explanation for `rollupCommonJSResolveHack` option below.

@@ -98,9 +100,10 @@ #### @rollup/plugin-babel

The current work directory, default `process.cwd()`.
The current working directory. Defaults to `process.cwd()`.
* `tsconfigDefaults`: `{}`
The object passed as `tsconfigDefaults` will be merged with loaded `tsconfig.json`. Final config passed to typescript will be the result of values in `tsconfigDefaults` replaced by values in loaded `tsconfig.json`, replaced by values in `tsconfigOverride` and then replaced by hard `compilerOptions` overrides on top of that (see above).
The object passed as `tsconfigDefaults` will be merged with the loaded `tsconfig.json`.
The final config passed to TypeScript will be the result of values in `tsconfigDefaults` replaced by values in the loaded `tsconfig.json`, replaced by values in `tsconfigOverride`, and then replaced by forced `compilerOptions` overrides on top of that (see above).
For simplicity and other tools' sake, try to minimize usage of defaults and overrides and keep everything in `tsconfig.json` file (tsconfigs can themselves be chained, so save some turtles).
For simplicity and other tools' sake, try to minimize the usage of defaults and overrides and keep everything in a `tsconfig.json` file (`tsconfig`s can themselves be chained with [`extends`](https://www.typescriptlang.org/tsconfig#extends), so save some turtles).

@@ -121,8 +124,12 @@ ```js

This is a [deep merge](https://lodash.com/docs/4.17.4#merge) (objects are merged, arrays are merged by index, primitives are replaced, etc), increase `verbosity` to 3 and look for `parsed tsconfig` if you get something unexpected.
This is a [deep merge](https://lodash.com/docs/4.17.4#merge): objects are merged, arrays are merged by index, primitives are replaced, etc.
Increase `verbosity` to `3` and look for `parsed tsconfig` if you get something unexpected.
* `tsconfig`: `undefined`
Path to `tsconfig.json`. Set this if your tsconfig has another name or relative location from the project directory. By default will try to load `./tsconfig.json`, but will not fail if file is missing unless the value is set explicitly.
Path to `tsconfig.json`.
Set this if your `tsconfig` has another name or relative location from the project directory.
By default, will try to load `./tsconfig.json`, but will not fail if the file is missing, unless the value is explicitly set.
* `tsconfigOverride`: `{}`

@@ -135,2 +142,3 @@

Set to false to avoid doing any diagnostic checks on the code.
Setting to false is sometimes referred to as `transpileOnly` by other TypeScript integrations.

@@ -146,11 +154,13 @@ * `verbosity`: 1

Set to true for clean build (wipes out cache on every build).
Set to true to disable the cache and do a clean build.
This also wipes any existing cache.
* `cacheRoot`: `node_modules/.cache/rollup-plugin-typescript2`
Path to cache. Defaults to a folder in node_modules.
Path to cache.
Defaults to a folder in `node_modules`.
* `include`: `[ "*.ts+(|x)", "**/*.ts+(|x)" ]`
By default passes all .ts files through typescript compiler.
By default compiles all `.ts` and `.tsx` files with TypeScript.

@@ -163,31 +173,38 @@ * `exclude`: `[ "*.d.ts", "**/*.d.ts" ]`

Bail out on first syntactic or semantic error. In some cases setting this to false will result in exception in rollup itself (for example for unresolvable imports).
Bail out on first syntactic or semantic error.
In some cases, setting this to false will result in an exception in Rollup itself (for example, unresolvable imports).
* `rollupCommonJSResolveHack`: false
On windows typescript resolver favors POSIX path, while commonjs plugin (and maybe others?) uses native path as module id. This can result in `namedExports` being ignored if rollup happened to use typescript's resolution. Set to true to pass resolved module path through `resolve()` to match up with `rollup-plugin-commonjs`.
_Deprecated_. OS native paths are now _always_ used since [`0.30.0`](https://github.com/ezolenko/rollup-plugin-typescript2/releases/0.30.0) (see [#251](https://github.com/ezolenko/rollup-plugin-typescript2/pull/251)), so this no longer has any effect -- as if it is always `true`.
`rollup-plugin-commonjs` fixed this in `10.1.0`, so projects using this option who update to new version will be broken again.
* `objectHashIgnoreUnknownHack`: false
This also works around the similar bug affecting code splitting (see [rollup/rollup#3094](https://github.com/rollup/rollup/issues/3094)).
The plugin uses your Rollup config as part of its cache key.
`object-hash` is used to generate a hash, but it can have trouble with some uncommon types of elements.
Setting this option to true will make `object-hash` ignore unknowns, at the cost of not invalidating the cache if ignored elements are changed.
* `objectHashIgnoreUnknownHack`: false
Only enable this option if you need it (e.g. if you get `Error: Unknown object type "xxx"`) and make sure to run with `clean: true` once in a while and definitely before a release.
(See [#105](https://github.com/ezolenko/rollup-plugin-typescript2/issues/105) and [#203](https://github.com/ezolenko/rollup-plugin-typescript2/pull/203))
The plugin uses rollup config as part of cache key. `object-hash` is used to generate a hash, but it can have trouble with some uncommon types of elements. Setting this option to true will make `object-hash` ignore unknowns, at the cost of not invalidating the cache if ignored elements are changed. Only enable this if you need it (`Error: Unknown object type "xxx"` for example) and make sure to run with `clean: true` once in a while and definitely before a release. (See [#105](https://github.com/ezolenko/rollup-plugin-typescript2/issues/105) and [#203](https://github.com/ezolenko/rollup-plugin-typescript2/pull/203))
* `useTsconfigDeclarationDir`: false
If true, declaration files will be emitted in the directory given in the tsconfig. If false, the declaration files will be placed inside the destination directory given in the Rollup configuration.
If true, declaration files will be emitted in the [`declarationDir`](https://www.typescriptlang.org/tsconfig#declarationDir) given in the `tsconfig`.
If false, declaration files will be placed inside the destination directory given in the Rollup configuration.
Set to false if any other rollup plugins need access to declaration files.
Set to false if any other Rollup plugins need access to declaration files.
* `typescript`: peerDependency
If you'd like to use a different version of TS than the peerDependency, you can import a different TypeScript module and pass it in as `typescript: require("path/to/other/typescript")`. Must be TS 2.0+, things might break if transpiler interfaces changed enough from what the plugin was built against.
If you'd like to use a different version of TS than the peerDependency, you can import a different TypeScript module and pass it in as `typescript: require("path/to/other/typescript")`.
You can also use an alternative TypeScript implementation, such as [`ttypescript`](https://github.com/cevek/ttypescript), with this option.
Must be TS 2.0+; things might break if the compiler interfaces changed enough from what the plugin was built against.
* `transformers`: `undefined`
**experimental**, typescript 2.4.1+
**experimental**, TypeScript 2.4.1+
Transformers will likely be available in tsconfig eventually, so this is not a stable interface, see [Microsoft/TypeScript#14419](https://github.com/Microsoft/TypeScript/issues/14419).
Transformers will likely be available in `tsconfig` eventually, so this is not a stable interface (see [Microsoft/TypeScript#14419](https://github.com/Microsoft/TypeScript/issues/14419)).

@@ -211,8 +228,18 @@ For example, integrating [kimamula/ts-transformer-keys](https://github.com/kimamula/ts-transformer-keys):

This plugin respects `declaration: true` in your `tsconfig.json` file. When set, it will emit `*.d.ts` files for your bundle. The resulting file(s) can then be used with the `types` property in your `package.json` file as described [here](https://www.typescriptlang.org/docs/handbook/declaration-files/publishing.html).
By default, the declaration files will be located in the same directory as the generated Rollup bundle. If you want to override this behavior and instead use the declarationDir set `useTsconfigDeclarationDir` to `true` in the plugin options.
This plugin respects [`declaration: true`](https://www.typescriptlang.org/tsconfig#declaration) in your `tsconfig.json` file.
When set, it will emit `*.d.ts` files for your bundle.
The resulting file(s) can then be used with the `types` property in your `package.json` file as described [here](https://www.typescriptlang.org/docs/handbook/declaration-files/publishing.html).<br />
By default, the declaration files will be located in the same directory as the generated Rollup bundle.
If you want to override this behavior and instead use [`declarationDir`](https://www.typescriptlang.org/tsconfig#declarationDir), set `useTsconfigDeclarationDir: true` in the plugin options.
The above also applies to [`declarationMap: true`](https://www.typescriptlang.org/tsconfig#declarationMap) and `*.d.ts.map` files for your bundle.
This plugin also respects [`emitDeclarationOnly: true`](https://www.typescriptlang.org/tsconfig#emitDeclarationOnly) and will only emit declarations (and declaration maps, if enabled) if set in your `tsconfig.json`.
If you use `emitDeclarationOnly`, you will need another plugin to compile any TypeScript sources, such as `@rollup/plugin-babel`, `rollup-plugin-esbuild`, `rollup-plugin-swc`, etc.
When composing Rollup plugins this way, `rollup-plugin-typescript2` will perform type-checking and declaration generation, while another plugin performs the TypeScript to JavaScript compilation.<br />
Some scenarios where this can be particularly useful: you want to use Babel plugins on TypeScript source, or you want declarations and type-checking for your Vite builds (**NOTE**: this space has not been fully explored yet).
### Watch mode
The way typescript handles type-only imports and ambient types effectively hides them from rollup watch, because import statements are not generated and changing them doesn't trigger a rebuild.
The way TypeScript handles type-only imports and ambient types effectively hides them from Rollup's watch mode, because import statements are not generated and changing them doesn't trigger a rebuild.

@@ -223,5 +250,5 @@ Otherwise the plugin should work in watch mode. Make sure to run a normal build after watch session to catch any type errors.

TypeScript `2.4+`
Rollup `1.26.3+`
Node `6.4.0+` (basic es6 support)
* TypeScript `2.4+`
* Rollup `1.26.3+`
* Node `6.4.0+` (basic ES6 support)

@@ -228,0 +255,0 @@ ### Reporting bugs and Contributing

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 too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

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