diff --git a/notNeededPackages.json b/notNeededPackages.json index a698b68ff3..0da7de39e9 100644 --- a/notNeededPackages.json +++ b/notNeededPackages.json @@ -1218,6 +1218,12 @@ "sourceRepoURL": "https://github.com/EnoF/rest-io", "asOfVersion": "4.1.0" }, + { + "libraryName": "rollup", + "typingsPackageName": "rollup", + "sourceRepoURL": "https://github.com/rollup/rollup", + "asOfVersion": "0.54.0" + }, { "libraryName": "route-recognizer", "typingsPackageName": "route-recognizer", diff --git a/types/rollup/package.json b/types/rollup-plugin-json/package.json similarity index 63% rename from types/rollup/package.json rename to types/rollup-plugin-json/package.json index 100334a89f..60161a270c 100644 --- a/types/rollup/package.json +++ b/types/rollup-plugin-json/package.json @@ -1,6 +1,6 @@ { "private": true, "dependencies": { - "source-map": "^0.6.1" + "rollup": "^0.54.0" } } diff --git a/types/rollup/index.d.ts b/types/rollup/index.d.ts deleted file mode 100644 index fcd5f799c3..0000000000 --- a/types/rollup/index.d.ts +++ /dev/null @@ -1,220 +0,0 @@ -// Type definitions for rollup 0.51 -// Project: https://github.com/rollup/rollup -// Definitions by: Philipp A. , Christian Svensson -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - -import { RawSourceMap } from 'source-map' -import * as acorn from 'acorn' - -export type Format = 'amd' | 'cjs' | 'es' | 'iife' | 'umd' -export const VERSION: string - -export interface SourceMap extends RawSourceMap { - toString(): string - toUrl(): string -} - -// https://github.com/rollup/rollup/wiki/JavaScript-API -export interface Warning { - code: string - message: string - loc?: { file: string, line: number, column: number } - frame?: string -} - -export interface BundleOptions { - /** The format of the generated bundle. */ - format: Format - /** What export mode to use. Defaults to auto, which guesses your intentions based on what the `entry` module exports. */ - exports?: 'auto' | 'default' | 'named' | 'none' - /** An ID to use for AMD/UMD bundles. */ - moduleId?: string - /** The name to use for the module for UMD/IIFE bundles (required for bundles with exports). */ - name?: string - /** Mapping of IDs → global variable names. Used for UMD/IIFE bundles. */ - globals?: ((id: string) => string) | { [id: string]: string } - /** - * Function that takes an ID and returns a path, or Object of id: path pairs. - * Where supplied, these paths will be used in the generated bundle instead of the module ID, allowing you to (for example) load dependencies from a CDN. - */ - paths?: ((id: string) => string) | { [id: string]: string } - /** - * The indent string to use, for formats that require code to be indented (AMD, IIFE, UMD). - * Can also be false (no indent), or true (the default – auto-indent) - */ - indent?: string | boolean - /** - * Whether or not to add an 'interop block'. By default (interop: true). - * For safety's sake, Rollup will assign any external dependencies' default exports to a separate variable if it's necessary to distinguish between default and named exports. - * This generally only applies if your external dependencies were transpiled (for example with Babel) – if you're sure you don't need it, you can save a few bytes with interop: false. - */ - interop?: boolean - /** A string to prepend to the bundle. */ - banner?: string - /** A string to append to the bundle. */ - footer?: string - /** A string prepended to the code inside of the format-specific wrapper */ - intro?: string - /** A string appended to the code inside of the format-specific wrapper */ - outro?: string - /** - * Whether to include the 'use strict' pragma at the top of generated non-ES6 bundles. - * Strictly-speaking (geddit?), ES6 modules are always in strict mode, so you shouldn't disable this without good reason. - */ - strict?: boolean -} - -export interface GenerateOptions extends BundleOptions { - /** Whether to generate a sourcemap. If true, the return value from `bundle.generate(...)` will include a map property */ - sourcemap?: boolean - /** - * The location of the generated bundle. If this is an absolute path, all the sources paths in the sourcemap will be relative to it. - * The map.file property is the basename of sourcemapFile, as the location of the sourcemap is assumed to be adjacent to the bundle. - */ - sourcemapFile?: string -} - -export interface WriteOptions extends BundleOptions { - /** The file to write to. If `options.sourcemap === true`, two files will be created – `file` and `file + '.map`. */ - file: string - /** If `true`, a separate sourcemap file will be created. If `'inline'`, the sourcemap will be appended to the resulting file as a data URI. */ - sourcemap?: boolean | 'inline' - /** This option is unnecessary, as it defaults to the value of file. */ - sourcemapFile?: string -} - -export interface Bundle { - /** Generate bundled code as an object */ - generate(options: GenerateOptions): Promise<{ code: string, map: SourceMap | null }> - /** writes the file (and accompanying sourcemap file, if appropriate) to the file system. */ - write(options: WriteOptions): Promise -} - -export interface Options { - /** The bundle's entry point (e.g. your `main.js` or `app.js` or `index.js`) */ - input: string - /** A previous bundle. Use it to speed up subsequent bundles :) */ - cache?: Bundle - /** - * Function that returns if an ID is external or array of IDs of modules that should remain external to the bundle. - * The IDs should be either the name of an external dependency or a resolved ID (like an absolute path to a file) - */ - external?: ((id: string) => boolean) | string[] - /** Function that will intercept warning messages. If not supplied, warnings will be deduplicated and printed to the console. */ - onwarn?(warning: Warning): void - /** Array of plugin objects or a single plugin object */ - plugins?: Plugin | Plugin[] - /** - * Whether or not to apply tree-shaking. (Default: true) - * It's recommended that you omit this option, unless you discover a bug caused by the tree-shaking algorithm in which case use treeshake: false once you've filed an issue! - */ - treeshake?: boolean - /** Any options that should be passed through to Acorn. */ - acorn?: acorn.Options - /** By default, the context of a module – i.e., the value of `this` at the top level – is `undefined`. In rare cases you might need to change this to something else, like `'window'`. */ - context?: any - /** Same as `options.context`, but per-module. */ - moduleContext?: ((id: string) => any) | { [id: string]: any } - /** Adds support for very old environments like IE8, at the cost of some extra code. */ - legacy?: boolean -} - -export interface ConfigFileOptions extends Options { - output: WriteOptions | WriteOptions[] -} - -// https://github.com/rollup/rollup/wiki/Plugins#creating-plugins -export interface Plugin { - /** The name of the plugin, for use in error messages and warnings */ - name?: string - /** A function that replaces or manipulates the options object passed to rollup.rollup */ - options?(options: Options): Options - /** A custom loader. Returning null or undefined defers to other load functions (and eventually the default behavior of loading from the file system). */ - load?(id: string): string | null | undefined - /** - * Custom resolver (useful for e.g. locating third-party dependencies). - * Returning null or undefined defers to other resolveId functions (and eventually the default resolution behavior); - * returning any other falsy value signals that importee should be treated as an external module and not included in the bundle. - */ - resolveId?(importee: string, importer: string | undefined): string | null | undefined | false | 0 | '' - /** A module transformer function */ - transform?(this: TransformContext, source: string, id: string): TransformResult | Promise - /** A bundle transformer function */ - transformBundle?(source: string, options: { format: Format }): TransformResult | Promise - /** Function hook called when bundle.generate() is being executed. */ - ongenerate?(options: GenerateOptions, bundle: Bundle): void - /** Function hook called when bundle.write() is being executed, after the file has been written to disk. */ - onwrite?(options: WriteOptions, bundle: Bundle): void - /** A function for generating intro text */ - intro?(): string - /** A function for generating outro text */ - outro?(): string - /** Prepend to the bundle. */ - banner?: string | (() => string) - /** Apppend to the bundle. */ - footer?: string | (() => string) -} - -// See https://github.com/rollup/rollup/wiki/Plugins#warnings-and-errors -export interface TransformContext { - /** Emit warnings to Rollup which will be logged during bundling */ - warn(message: string | { message: string }, pos?: number | { line: number, column: number }): void - /** Emit an error, which will abort the bundling process */ - error(message: string | { message: string }, pos?: number | { line: number, column: number }): void -} - -export type TransformResult = string | null | undefined | { code: string, map: SourceMap } - -/** Returns a Promise that resolves with a bundle */ -export function rollup(options: Options): Promise - -export interface WatchOptions extends ConfigFileOptions { - watch?: { - /** - * If set to true, will use chokidar for file watching (requires installation). - * If set to object, the settings are passed on to chokidar - */ - chokidar?: boolean | { [key: string]: any }; - /** Limit the file-watching to certain files, e.g. 'src/**' */ - include?: string; - /** Prevent files from being watched, e.g. 'node_modules/**' */ - exclude?: string; - } -} - -export interface StartEvent { - code: 'START' -} -export interface EndEvent { - code: 'END' -} -export interface ErrorEvent { - code: 'ERROR' - error: Error -} -export interface FatalEvent { - code: 'FATAL' - error: Error -} -export interface BundleStartEvent { - code: 'BUNDLE_START' - input: string - output: string[] -} -export interface BundleEndEvent { - code: 'BUNDLE_END' - input: string - output: string[] - duration: number -} -export type WatchEvent = StartEvent | EndEvent | ErrorEvent | FatalEvent | BundleStartEvent | BundleEndEvent - -export class Watcher { - /** Listen to the events that are emitted by rollup during watching */ - on(type: 'event', callback: (e: WatchEvent) => void): void - /** Stop watching for file changes */ - close(): void -} - -/** Starts rollup in watch mode. Returns a watcher instance for closing or listening to events */ -export function watch(options: WatchOptions): Watcher diff --git a/types/rollup/rollup-tests.ts b/types/rollup/rollup-tests.ts deleted file mode 100644 index e2b18d6109..0000000000 --- a/types/rollup/rollup-tests.ts +++ /dev/null @@ -1,174 +0,0 @@ -import { rollup, watch, Bundle, Plugin, ConfigFileOptions } from 'rollup' - -declare const console: { log(...messages: any[]): void, warn(message: string): void } - -let cache: Bundle | undefined -const plugin: Plugin = { - name: 'test-plugin', - resolveId(importee, importer) { - if (importer === undefined) { - return 'custom/entry/point.js' - } - return importer.trim() - }, - transform(source, id) { - if (id === 'rxjs') { - this.error(new Error(`Don't import this directly`)) - return null - } - const indexOfQuote = source.indexOf('"') - if (indexOfQuote >= 0) { - this.warn(`Prefer ' over " for strings`, indexOfQuote) - return undefined - } - if (id === 'foo') { - return Promise.resolve(source) - } - return source - }, - transformBundle(source, options) { - if (options.format === 'iife') { - return `window.nonModule = true\n${source}` - } else if (options.format === 'cjs') { - return null - } - if (options.format !== 'es') { - return Promise.resolve(source) - } - return undefined - } -} - -async function main() { - const bundle = await rollup({ - input: 'main.js', - external: ['external-module'], - plugins: [plugin], - onwarn: ({ code, frame, loc, message }) => { - if (loc) { - const { file, line, column } = loc - console.log(`[${code}] - ${file}(${line},${column}): ${message}`) - } else { - console.log(`[${code}] - ${message}`) - } - - if (frame) console.warn(frame) - }, - cache, - }) - - const bundle2 = await rollup({ - input: 'main.js', - external: id => /^rxjs/.test(id), - plugins: plugin - }) - - const { code, map } = await bundle.generate({ - format: 'cjs', - indent: false, - sourcemap: true, - }) - - console.log(code, map) - - cache = bundle - - await bundle.write({ - format: 'cjs', - file: 'bundle.js', - name: 'myLib', - interop: false, - globals: { - jquery: '$', - lodash: '_', - }, - banner: '/* Banner */', - footer: '/* Footer */', - intro: 'var ENV = "production";', - outro: 'var VERSION = "1.0.0";', - indent: ' ', - sourcemap: 'inline', - sourcemapFile: 'bundle.js.map', - strict: true, - }) - - await bundle.write({ - format: 'cjs', - file: 'bundle.js', - name: 'myLib', - interop: false, - globals: (x: string) => x.replace("", "/"), - banner: '/* Banner */', - footer: '/* Footer */', - intro: 'var ENV = "production";', - outro: 'var VERSION = "1.0.0";', - indent: ' ', - sourcemap: 'inline', - sourcemapFile: 'bundle.js.map', - strict: true, - }) - - const watcher = watch({ - input: 'main.js', - output: { - file: 'bundle.js', - format: 'es' - }, - watch: { - chokidar: true - } - }) - - watcher.on('event', e => { - switch (e.code) { - case 'START': - console.log(`We're rolling!`) - return - case 'END': - console.log(`We're all rolled up!`) - return - case 'ERROR': - case 'FATAL': - console.log(e.error.message) - return - case 'BUNDLE_START': - console.log(`Bundling: ${e.input}`) - return - case 'BUNDLE_END': - console.log(`Bundling: ${e.input}`) - return - } - - assertNever(e) - }) - - watcher.close() -} - -main() - -export const defaultConfig: ConfigFileOptions = { - input: 'main.js', - output: { - file: 'bundle.js', - format: 'iife', - } -} - -export const multiConfig: ConfigFileOptions = { - input: 'main.js', - output: [ - { - file: 'bundle.esm.js', - format: 'es', - }, - { - file: 'bundle.cjs.js', - format: 'cjs', - } - ] -} - -function assertNever(nope: never) { - throw new Error('Oh no!') -} diff --git a/types/rollup/tsconfig.json b/types/rollup/tsconfig.json deleted file mode 100644 index 2fad31b1b1..0000000000 --- a/types/rollup/tsconfig.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "compilerOptions": { - "module": "commonjs", - "target": "es6", - "lib": [ - "es6" - ], - "noImplicitAny": true, - "noImplicitThis": true, - "strictNullChecks": true, - "strictFunctionTypes": true, - "baseUrl": "../", - "typeRoots": [ - "../" - ], - "types": [], - "noEmit": true, - "forceConsistentCasingInFileNames": true - }, - "files": [ - "index.d.ts", - "rollup-tests.ts" - ] -} \ No newline at end of file diff --git a/types/rollup/tslint.json b/types/rollup/tslint.json deleted file mode 100644 index ba7f6bc7ae..0000000000 --- a/types/rollup/tslint.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "extends": "dtslint/dt.json", - "rules": { - "semicolon": [true, "never"] - } -}