@wessberg/rollup-plugin-ts
Advanced tools
Comparing version 0.0.35 to 0.0.36
160
package.json
{ | ||
"name": "@wessberg/rollup-plugin-ts", | ||
"version": "0.0.35", | ||
"description": "A Rollup plugin for Typescript", | ||
"scripts": { | ||
"changelog:generate": "conventional-changelog --outfile CHANGELOG.md --release-count 0", | ||
"readme:badges": "node node_modules/@wessberg/ts-config/readme/badge/helper/add-badges.js", | ||
"readme:refresh": "npm run changelog:generate && npm run readme:badges", | ||
"commit:readme": "npm run readme:refresh && git commit -am \"Bumped version\" --no-verify || true", | ||
"clean:dist": "rm -r -f dist", | ||
"clean:compiled": "rm -r -f compiled", | ||
"clean": "npm run clean:dist && npm run clean:compiled", | ||
"tsc:dist:cjs": "tsc --module commonjs --outDir dist/cjs -p tsconfig.dist.json", | ||
"tsc:dist:es2015": "tsc --module es2015 --outDir dist/es2015 -p tsconfig.dist.json", | ||
"tsc:test": "tsc --module commonjs --target es2017 --sourceMap", | ||
"build:cjs": "npm run tsc:dist:cjs", | ||
"build:es2015": "npm run tsc:dist:es2015", | ||
"prebuild": "npm run clean", | ||
"build": "npm run build:cjs & npm run build:es2015", | ||
"tslint": "tslint -c tslint.json -p tsconfig.json", | ||
"validate": "npm run tslint && npm run test", | ||
"pretest": "npm run clean:compiled && npm run tsc:test", | ||
"test": "NODE_ENV=TEST echo \"skipping tests...\"", | ||
"posttest": "npm run clean:compiled", | ||
"prepublishOnly": "NODE_ENV=production npm run validate && NODE_ENV=production npm run build", | ||
"precommit": "npm run tslint && exit 0", | ||
"prepush": "npm run validate && exit 0", | ||
"publish:major": "npm version major && npm run commit:readme && git push --no-verify && npm publish", | ||
"publish:minor": "npm version minor && npm run commit:readme && git push --no-verify && npm publish", | ||
"publish:patch": "npm version patch && npm run commit:readme && git push --no-verify && npm publish" | ||
}, | ||
"keywords": [], | ||
"author": { | ||
"name": "Frederik Wessberg", | ||
"email": "frederikwessberg@hotmail.com", | ||
"url": "https://github.com/wessberg" | ||
}, | ||
"license": "MIT", | ||
"devDependencies": { | ||
"@wessberg/ts-config": "^0.0.27", | ||
"conventional-changelog-cli": "^2.0.1", | ||
"husky": "latest", | ||
"tslint": "^5.11.0", | ||
"typescript": "^3.0.1" | ||
}, | ||
"dependencies": { | ||
"@babel/core": "^7.0.0-rc.1", | ||
"@babel/plugin-proposal-decorators": "^7.0.0-rc.1", | ||
"@babel/plugin-proposal-async-generator-functions": "^7.0.0-rc.1", | ||
"@babel/plugin-proposal-class-properties": "^7.0.0-rc.1", | ||
"@babel/plugin-proposal-object-rest-spread": "^7.0.0-rc.1", | ||
"@babel/plugin-proposal-optional-catch-binding": "^7.0.0-rc.1", | ||
"@babel/plugin-syntax-dynamic-import": "^7.0.0-rc.1", | ||
"@babel/preset-env": "^7.0.0-rc.1", | ||
"@types/node": "^10.5.7", | ||
"chalk": "^2.4.1", | ||
"rollup": "^0.64.1", | ||
"rollup-pluginutils": "^2.3.1", | ||
"tslib": "^1.9.3" | ||
}, | ||
"main": "./dist/cjs/index.js", | ||
"module": "./dist/es2015/index.js", | ||
"browser": "./dist/es2015/index.js", | ||
"types": "./dist/es2015/index.d.ts", | ||
"typings": "./dist/es2015/index.d.ts", | ||
"es2015": "./dist/es2015/index.js", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/wessberg/rollup-plugin-ts.git" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/wessberg/rollup-plugin-ts/issues" | ||
}, | ||
"engines": { | ||
"node": ">=9.0.0" | ||
} | ||
"name": "@wessberg/rollup-plugin-ts", | ||
"version": "0.0.36", | ||
"description": "A Rollup plugin for Typescript that respects Browserslists", | ||
"scripts": { | ||
"generate:readme": "scaffold readme", | ||
"generate:license": "scaffold license", | ||
"generate:contributing": "scaffold contributing", | ||
"generate:coc": "scaffold coc", | ||
"generate:all": "npm run generate:license & npm run generate:contributing & npm run generate:coc & npm run generate:readme", | ||
"update": "ncu -ua && npm update && npm install", | ||
"lint": "tsc --noEmit && tslint -c tslint.json --project tsconfig.json", | ||
"clean": "rm -rf dist", | ||
"tsc:cjs": "tsc --module commonjs --outDir dist/cjs -p tsconfig.dist.json", | ||
"tsc:esm": "tsc --module es2015 --outDir dist/esm -p tsconfig.dist.json", | ||
"prebuild": "npm run clean", | ||
"build": "npm run tsc:cjs & npm run tsc:esm", | ||
"prepare": "npm run build", | ||
"prepublish:patch": "NODE_ENV=production npm run lint && NODE_ENV=production npm run prepare && npm run generate:all && git commit -am \"Bumped version\" || true", | ||
"publish:patch": "npm version patch && git push && npm publish" | ||
}, | ||
"keywords": [ | ||
"rollup", | ||
"typescript", | ||
"plugin", | ||
"babel", | ||
"browserslist" | ||
], | ||
"author": { | ||
"name": "Frederik Wessberg", | ||
"email": "frederikwessberg@hotmail.com", | ||
"url": "https://github.com/wessberg" | ||
}, | ||
"license": "MIT", | ||
"devDependencies": { | ||
"@wessberg/ts-config": "^0.0.27", | ||
"@wessberg/scaffold": "^1.0.0", | ||
"npm-check-updates": "^2.14.2", | ||
"conventional-changelog-cli": "^2.0.1", | ||
"husky": "latest", | ||
"tslint": "^5.11.0", | ||
"typescript": "^3.0.1" | ||
}, | ||
"dependencies": { | ||
"@babel/core": "^7.0.0-rc.1", | ||
"@babel/plugin-proposal-decorators": "^7.0.0-rc.1", | ||
"@babel/plugin-proposal-async-generator-functions": "^7.0.0-rc.1", | ||
"@babel/plugin-proposal-class-properties": "^7.0.0-rc.1", | ||
"@babel/plugin-proposal-object-rest-spread": "^7.0.0-rc.1", | ||
"@babel/plugin-proposal-optional-catch-binding": "^7.0.0-rc.1", | ||
"@babel/plugin-syntax-dynamic-import": "^7.0.0-rc.1", | ||
"@babel/preset-env": "^7.0.0-rc.1", | ||
"@types/node": "^10.7.0", | ||
"chalk": "^2.4.1", | ||
"rollup": "^0.64.1", | ||
"rollup-pluginutils": "^2.3.1", | ||
"tslib": "^1.9.3" | ||
}, | ||
"main": "./dist/cjs/index.js", | ||
"module": "./dist/esm/index.js", | ||
"browser": "./dist/esm/index.js", | ||
"types": "./dist/esm/index.d.ts", | ||
"typings": "./dist/esm/index.d.ts", | ||
"es2015": "./dist/esm/index.js", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/wessberg/rollup-plugin-ts.git" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/wessberg/rollup-plugin-ts/issues" | ||
}, | ||
"engines": { | ||
"node": ">=9.0.0" | ||
}, | ||
"scaffold": { | ||
"patreonUserId": "11315442", | ||
"contributorMeta": { | ||
"Frederik Wessberg": { | ||
"imageUrl": "https://avatars2.githubusercontent.com/u/20454213?s=460&v=4", | ||
"role": "Maintainer", | ||
"twitterHandle": "FredWessberg", | ||
"isCocEnforcer": true | ||
} | ||
}, | ||
"backers": [] | ||
} | ||
} |
166
README.md
@@ -1,48 +0,150 @@ | ||
# @wessberg/rollup-plugin-ts | ||
[![NPM version][npm-version-image]][npm-version-url] | ||
[![License-mit][license-mit-image]][license-mit-url] | ||
<a href="https://npmcharts.com/compare/@wessberg/rollup-plugin-ts?minimal=true"><img alt="Downloads per month" src="https://img.shields.io/npm/dm/%40wessberg%2Frollup-plugin-ts.svg" height="20"></img></a> | ||
<a href="https://david-dm.org/wessberg/rollup-plugin-ts"><img alt="Dependencies" src="https://img.shields.io/david/wessberg/rollup-plugin-ts.svg" height="20"></img></a> | ||
<a href="https://www.npmjs.com/package/@wessberg/rollup-plugin-ts"><img alt="NPM Version" src="https://badge.fury.io/js/%40wessberg%2Frollup-plugin-ts.svg" height="20"></img></a> | ||
<a href="https://github.com/wessberg/rollup-plugin-ts/graphs/contributors"><img alt="Contributors" src="https://img.shields.io/github/contributors/wessberg%2Frollup-plugin-ts.svg" height="20"></img></a> | ||
<a href="https://opensource.org/licenses/MIT"><img alt="MIT License" src="https://img.shields.io/badge/License-MIT-yellow.svg" height="20"></img></a> | ||
<a href="https://www.patreon.com/bePatron?u=11315442"><img alt="Support on Patreon" src="https://c5.patreon.com/external/logo/become_a_patron_button@2x.png" height="20"></img></a> | ||
[license-mit-url]: https://opensource.org/licenses/MIT | ||
# `@wessberg/rollup-plugin-ts` | ||
[license-mit-image]: https://img.shields.io/badge/License-MIT-yellow.svg | ||
> A Rollup plugin for Typescript that respects Browserslists | ||
[npm-version-url]: https://www.npmjs.com/package/@wessberg/rollup-plugin-ts | ||
## Description | ||
[npm-version-image]: https://badge.fury.io/js/%40wessberg%2Frollup-plugin-ts.svg | ||
This is a Rollup plugin that enables integration between Typescript and Rollup. | ||
In comparison with the [official plugin](https://github.com/rollup/rollup-plugin-typescript), this one has several improvements: | ||
This is a simple Rollup Plugin that can transform Typescript files. | ||
It can generate declaration files and prints diagnostics. | ||
- Compiler diagnostics are correctly emitted and brought into the Rollup build lifecycle | ||
- [Emit-less types](https://github.com/rollup/rollup-plugin-typescript/issues/28) are correctly handled | ||
- Generation of Definition files (`.d.ts`) are supported | ||
- A [Browserslist](https://github.com/browserslist/browserslist) can be provided instead of a target version of ECMAScript such that your code is transpiled in relation to the baseline of browsers defined in your Browserslist instead. | ||
## Installation | ||
## Install | ||
You can install this plugin from NPM: | ||
### NPM | ||
```text | ||
npm install @wessberg/rollup-plugin-ts | ||
``` | ||
``` | ||
$ npm install @wessberg/rollup-plugin-ts | ||
``` | ||
### Yarn | ||
``` | ||
$ yarn add @wessberg/rollup-plugin-ts | ||
``` | ||
### Run once with NPX | ||
``` | ||
$ npx @wessberg/rollup-plugin-ts | ||
``` | ||
## Usage | ||
Add the plugin to your Rollup plugins: | ||
Using the plugin is dead-simple. Here's an example: | ||
```javascript | ||
import typescriptRollupPlugin from "@wessberg/rollup-plugin-ts"; | ||
import tsPlugin from "@wessberg/rollup-plugin-ts"; | ||
export default { | ||
// The entry point of your app or library | ||
input: "src/index.ts", | ||
output: [ | ||
/* ... */ | ||
], | ||
plugins: [ | ||
tsPlugin({ | ||
/* Plugin options */ | ||
}) | ||
] | ||
}; | ||
``` | ||
// ... | ||
The options provided in your `tsconfig.json` will be seamlessly merged with those provided by Rollup. | ||
### Plugin options | ||
- `tsconfig`: The relative path from the current working directory to the Typescript config file to use. (Default: `tsconfig.json). | ||
- `root`: The current working directory. (Default: `process.cwd()`) | ||
- `include`: A filter for the files that should be passed through the plugin. (Default: `[]`), | ||
- `exclude`: A filter for the files that should be excluded from being passed through the plugin. (Default: `[]`) | ||
- `browserslist`: A Browserslist config that should be compiled against, rather than relying on the `target` provided in the `tsconfig`. Please see [this section](#using-browserslists) for more details. (Default: `undefined`) | ||
- `additionalBabelPresets`: **Only applicable when providing a value for the `browserslist` option**. Code will additionally be run through the babel presets provided here. (Default: `[]`) | ||
- `additionalBabelPlugins`: **Only applicable when providing a value for the `browserslist` option**. Code will additionally be run through the babel plugins provided here. (Default: `[]`) | ||
- `parseExternalModules`: If false, no external modules (e.g. those coming from `node_modules`) will be parsed by Typescript which may result in the unwanted preservation of exported types from other libraries in the compiled output. Please see [this section](#rollup-complains-about-an-import-for-something-that-isnt-exported-by-a-module) for more details. (Default: `false`) | ||
### Declarations | ||
Yup. Those work. If `declaration` is `true` in your `tsconfig`, Declaration files following the original folder structure will be generated inside the output directories. | ||
### Using Browserslists | ||
If you want to let a [Browserslist](https://github.com/browserslist/browserslist) decide which transformations to apply to your code, rather than a simple ECMAScript target version, | ||
please know that the compilation phase will be two-fold: | ||
1. The Typescript compiler will compile with `ESNext` as the `ECMAScript` target version. This basically amounts to stripping away types as well as transforming Typescript specific run-time functionality such as `enum`s and decorators. | ||
2. Babel will perform the remaining transpilation with respect to your browserslist through `babel-preset-env`, some baked-in plugins representing features that are in stage 3 in TC39, as well as any presets and/or plugins you provide. | ||
In order to do so, all you have to do is simply provide a `browserslist` in the options provided to the plugin. For example: | ||
```javascript | ||
import tsPlugin from "@wessberg/rollup-plugin-ts"; | ||
export default { | ||
// ... | ||
plugins: [ | ||
// ... | ||
typescriptRollupPlugin({ | ||
// The path to the tsconfig.json file to use | ||
tsconfig: "path_to_tsconfig.json", // default: "tsconfig.json", | ||
// The path to the project root | ||
root: "path_to_root", // default: process.cwd(), | ||
// If true, no files will be emitted, even though 'declaration' is true in the tsconfig.json file | ||
include: [], // The file paths to include, | ||
exclude: [] // The file paths to exclude | ||
}) | ||
] | ||
} | ||
``` | ||
// ... | ||
plugins: [ | ||
tsPlugin({ | ||
// ... | ||
browserslist: ["last 2 versions"] | ||
}) | ||
] | ||
}; | ||
``` | ||
## Contributing | ||
Do you want to contribute? Awesome! Please follow [these recommendations](./CONTRIBUTING.md). | ||
## Maintainers | ||
- <a href="https://github.com/wessberg"><img alt="Frederik Wessberg" src="https://avatars2.githubusercontent.com/u/20454213?s=460&v=4" height="11"></img></a> [Frederik Wessberg](https://github.com/wessberg): _Maintainer_ | ||
## FAQ | ||
### How are Typescript config options merged with the Rollup options? | ||
The plugin attempts to make it as seamless as intuitive as possible. Whenever conflicts arise (which is almost exclusively related to output options), Rollup has the last word. | ||
For example, Rollup decides which output formats to compile for, and which folders to place the generated assets in, rather than Typescript, since this is configured in the Rollup | ||
output options. | ||
### Does this plugin work with Code Splitting? | ||
Yes! And I would encourage you to use it. | ||
### Rollup complains about an import for something that isn't exported by a module | ||
You may want to set the plugin option `parseExternalModules` to `true`. | ||
By default, this option is false, and as a consequence, no external modules (e.g. those coming from `node_modules`) will be parsed by Typescript which may result in the unwanted preservation of exported types from other libraries in the compiled output. | ||
For example, if you are depending on a type from a library like this: | ||
```typescript | ||
// Inside a library: 'my-library' | ||
export type Foo = { | ||
/* Something */ | ||
}; | ||
``` | ||
And you then re-export it: | ||
```typescript | ||
// Inside your app or library | ||
export {Foo} from "my-library"; | ||
``` | ||
Then it won't be stripped away by Typescript from the compiled Javascript Output if this option is `false`, | ||
This option is `false` by default since it may lead to significant improvements to compilation time, but please toggle this option 'on' if you run into issues like this. | ||
## Backers 🏅 | ||
[Become a backer](https://www.patreon.com/bePatron?u=11315442) and get your name, logo, and link to your site listed here. | ||
## License 📄 | ||
MIT © [Frederik Wessberg](https://github.com/wessberg) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
182422
85
151
7
1
Updated@types/node@^10.7.0