Security News
RubyGems.org Adds New Maintainer Role
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
@wessberg/rollup-plugin-ts
Advanced tools
@wessberg/rollup-plugin-ts
A Rollup plugin for Typescript that respects Browserslists
This is a Rollup plugin that enables integration between Typescript and Rollup. In comparison with the official plugin, this one has several improvements:
.d.ts
) are supported$ npm install @wessberg/rollup-plugin-ts
$ yarn add @wessberg/rollup-plugin-ts
$ npx @wessberg/rollup-plugin-ts
Using the plugin is dead-simple. Here's an example:
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.
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 for more details. (Default: undefined
)babel
: An object of supported configuration options to pass on to Babel (See this section for more details.) (Default: undefined
)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 for more details. (Default: false
)These options will be passed on to Babel. Note that you MUST also include a browserslist
to the plugin in order for Babel to handle transpilation.
additionalPresets
: Code will additionally be run through the babel presets provided here. (Default: undefined
)additionalPlugins
: Code will additionally be run through the babel plugins provided here. (Default: undefined
)And all of the options listed in the Code generator options section for Babel.
Yup. Those work. If declaration
is true
in your tsconfig
, Declaration files following the original folder structure will be generated inside the output directories.
If you want to let a 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:
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.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:import tsPlugin from "@wessberg/rollup-plugin-ts";
export default {
// ...
plugins: [
tsPlugin({
// ...
browserslist: ["last 2 versions"]
})
]
};
Do you want to contribute? Awesome! Please follow these recommendations.
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.
Yes! And I would encourage you to use it.
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:
// Inside a library: 'my-library'
export type Foo = {
/* Something */
};
And you then re-export it:
// 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.
Become a backer and get your name, logo, and link to your site listed here.
MIT © Frederik Wessberg
FAQs
A TypeScript Rollup plugin that bundles declarations, respects Browserslists, and enables seamless integration with transpilers such as babel and swc
The npm package @wessberg/rollup-plugin-ts receives a total of 832 weekly downloads. As such, @wessberg/rollup-plugin-ts popularity was classified as not popular.
We found that @wessberg/rollup-plugin-ts demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.
Security News
Research
Socket's threat research team has detected five malicious npm packages targeting Roblox developers, deploying malware to steal credentials and personal data.