Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/stdin' into stdin
Browse files Browse the repository at this point in the history
  • Loading branch information
lukastaegert committed Jan 1, 2020
2 parents 78484a9 + 7979ef6 commit 2ae5484
Show file tree
Hide file tree
Showing 55 changed files with 222 additions and 278 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG.md
@@ -1,5 +1,17 @@
# rollup changelog

## 1.27.14
*2019-12-22*

### Bug Fixes
* Update references to official rollup plugins in error messages (#3297, #3298)

### Pull Requests
* [#3286](https://github.com/rollup/rollup/pull/3286): Update link to JavaScript API documentation (@romankaravia)
* [#3294](https://github.com/rollup/rollup/pull/3294): Update deprecated references to the node-resolve plugin in the documentation (@Vlad-Shcherbina)
* [#3297](https://github.com/rollup/rollup/pull/3297): Update references to rollup-plugin-json (@cprecioso)
* [#3298](https://github.com/rollup/rollup/pull/3298): Update references to official rollup plugins (@cprecioso)

## 1.27.13
*2019-12-14*

Expand Down
4 changes: 2 additions & 2 deletions README.md
Expand Up @@ -34,7 +34,7 @@ Rollup is a module bundler for JavaScript which compiles small pieces of code in

## Quick Start Guide

Install with `npm install --global rollup`. Rollup can be used either through a [command line interface](https://rollupjs.org/#command-line-reference) with an optional configuration file, or else through its [JavaScript API](https://rollupjs.org/#javascript-api). Run `rollup --help` to see the available options and parameters. The starter project templates, [rollup-starter-lib](https://github.com/rollup/rollup-starter-lib) and [rollup-starter-app](https://github.com/rollup/rollup-starter-app), demonstrate common configuration options, and more detailed instructions are available throughout the [user guide](https://rollupjs.org/).
Install with `npm install --global rollup`. Rollup can be used either through a [command line interface](https://rollupjs.org/#command-line-reference) with an optional configuration file, or else through its [JavaScript API](https://rollupjs.org/guide/en/#javascript-api). Run `rollup --help` to see the available options and parameters. The starter project templates, [rollup-starter-lib](https://github.com/rollup/rollup-starter-lib) and [rollup-starter-app](https://github.com/rollup/rollup-starter-app), demonstrate common configuration options, and more detailed instructions are available throughout the [user guide](https://rollupjs.org/).

### Commands

Expand Down Expand Up @@ -97,7 +97,7 @@ Because Rollup includes the bare minimum, it results in lighter, faster, and les

### Importing CommonJS

Rollup can import existing CommonJS modules [through a plugin](https://github.com/rollup/rollup-plugin-commonjs).
Rollup can import existing CommonJS modules [through a plugin](https://github.com/rollup/plugins/tree/master/packages/commonjs).

### Publishing ES Modules

Expand Down
4 changes: 2 additions & 2 deletions browser/path.ts
Expand Up @@ -28,7 +28,7 @@ export function dirname(path: string) {
}

export function extname(path: string) {
const match = /\.[^.]+$/.exec(basename(path) as string);
const match = /\.[^.]+$/.exec(basename(path)!);
if (!match) return '';
return match[0];
}
Expand Down Expand Up @@ -58,7 +58,7 @@ export function relative(from: string, to: string) {
}

export function resolve(...paths: string[]) {
let resolvedParts = (paths.shift() as string).split(/[/\\]/);
let resolvedParts = paths.shift()!.split(/[/\\]/);

paths.forEach(path => {
if (isAbsolute(path)) {
Expand Down
6 changes: 3 additions & 3 deletions cli/logging.ts
Expand Up @@ -15,8 +15,8 @@ export function handleError(err: RollupError, recover = false) {
let description = err.message || err;
if (err.name) description = `${err.name}: ${description}`;
const message =
((err as { plugin?: string }).plugin
? `(plugin ${(err as { plugin?: string }).plugin}) ${description}`
(err.plugin
? `(plugin ${(err).plugin}) ${description}`
: description) || err;

stderr(tc.bold.red(`[!] ${tc.bold(message.toString())}`));
Expand All @@ -26,7 +26,7 @@ export function handleError(err: RollupError, recover = false) {
}

if (err.loc) {
stderr(`${relativeId((err.loc.file || err.id) as string)} (${err.loc.line}:${err.loc.column})`);
stderr(`${relativeId((err.loc.file || err.id)!)} (${err.loc.line}:${err.loc.column})`);
} else if (err.id) {
stderr(relativeId(err.id));
}
Expand Down
13 changes: 6 additions & 7 deletions cli/run/build.ts
@@ -1,7 +1,7 @@
import ms from 'pretty-ms';
import tc from 'turbocolor';
import * as rollup from '../../src/node-entry';
import { InputOptions, OutputOptions, RollupBuild, SourceMap } from '../../src/rollup/types';
import { InputOptions, OutputOptions, RollupBuild } from '../../src/rollup/types';
import relativeId from '../../src/utils/relativeId';
import { handleError, stderr } from '../logging';
import SOURCEMAPPING_URL from '../sourceMappingUrl';
Expand All @@ -19,9 +19,9 @@ export default function build(
const start = Date.now();
const files = useStdout
? ['stdout']
: outputOptions.map(t => relativeId(t.file || (t.dir as string)));
: outputOptions.map(t => relativeId(t.file || t.dir!));
if (!silent) {
let inputFiles: string = undefined as any;
let inputFiles: string | undefined;
if (typeof inputOptions.input === 'string') {
inputFiles = inputOptions.input;
} else if (inputOptions.input instanceof Array) {
Expand All @@ -31,7 +31,7 @@ export default function build(
.map(name => (inputOptions.input as Record<string, string>)[name])
.join(', ');
}
stderr(tc.cyan(`\n${tc.bold(inputFiles)}${tc.bold(files.join(', '))}...`));
stderr(tc.cyan(`\n${tc.bold(inputFiles!)}${tc.bold(files.join(', '))}...`));
}

return rollup
Expand All @@ -54,8 +54,7 @@ export default function build(
} else {
source = file.code;
if (output.sourcemap === 'inline') {
source += `\n//# ${SOURCEMAPPING_URL}=${(file
.map as SourceMap).toUrl()}\n`;
source += `\n//# ${SOURCEMAPPING_URL}=${file.map!.toUrl()}\n`;
}
}
if (outputs.length > 1)
Expand All @@ -66,7 +65,7 @@ export default function build(
});
}

return Promise.all(outputOptions.map(output => bundle.write(output) as Promise<any>)).then(
return Promise.all(outputOptions.map(output => bundle.write(output))).then(
() => bundle
);
})
Expand Down
4 changes: 3 additions & 1 deletion docs/00-introduction.md
Expand Up @@ -12,6 +12,8 @@ Rollup is a module bundler for JavaScript which compiles small pieces of code in
npm install --global rollup
```

⚠️ If you are using TypeScript, we recommend you explicitly list the `@types` packages you want to use using the [`types` property in the "tsconfig.json" file](https://www.typescriptlang.org/docs/handbook/tsconfig-json.html#types-typeroots-and-types), or set it to `[]`. Rollup has a dependency on `@types/node`, which means (without this change) these types will automatically be available in your app even when some of them should not be available based on the `target` you are using.

### Quick start

Rollup can be used either through a [command line interface](guide/en/#command-line-reference) with an optional configuration file, or else through its [JavaScript API](guide/en/#javascript-api). Run `rollup --help` to see the available options and parameters.
Expand Down Expand Up @@ -80,7 +82,7 @@ Because Rollup includes the bare minimum, it results in lighter, faster, and les

#### Importing CommonJS

Rollup can import existing CommonJS modules [through a plugin](https://github.com/rollup/rollup-plugin-commonjs).
Rollup can import existing CommonJS modules [through a plugin](https://github.com/rollup/plugins/tree/master/packages/commonjs).

#### Publishing ES Modules

Expand Down
2 changes: 1 addition & 1 deletion docs/01-command-line-reference.md
Expand Up @@ -155,7 +155,7 @@ export default Promise.all([
You *must* use a configuration file in order to do any of the following:

- bundle one project into multiple output files
- use Rollup plugins, such as [rollup-plugin-node-resolve](https://github.com/rollup/rollup-plugin-node-resolve) and [rollup-plugin-commonjs](https://github.com/rollup/rollup-plugin-commonjs) which let you load CommonJS modules from the Node.js ecosystem
- use Rollup plugins, such as [@rollup/plugin-node-resolve](https://github.com/rollup/plugins/tree/master/packages/node-resolve) and [@rollup/plugin-commonjs](https://github.com/rollup/plugins/tree/master/packages/commonjs) which let you load CommonJS modules from the Node.js ecosystem

To use Rollup with a configuration file, pass the `--config` or `-c` flags.

Expand Down
10 changes: 5 additions & 5 deletions docs/04-tutorial.md
Expand Up @@ -173,7 +173,7 @@ So far, we've created a simple bundle from an entry point and a module imported

For that, we use *plugins*, which change the behaviour of Rollup at key points in the bundling process. A list of awesome plugins is maintained on [the Rollup Awesome List](https://github.com/rollup/awesome).

For this tutorial, we'll use [rollup-plugin-json](https://github.com/rollup/rollup-plugin-json), which allows Rollup to import data from a JSON file.
For this tutorial, we'll use [@rollup/plugin-json](https://github.com/rollup/plugins/tree/master/packages/json), which allows Rollup to import data from a JSON file.

Create a file in the project root called `package.json`, and add the following content:

Expand All @@ -187,10 +187,10 @@ Create a file in the project root called `package.json`, and add the following c
}
```

Install rollup-plugin-json as a development dependency:
Install @rollup/plugin-json as a development dependency:

```
npm install --save-dev rollup-plugin-json
npm install --save-dev @rollup/plugin-json
```

(We're using `--save-dev` rather than `--save` because our code doesn't actually depend on the plugin when it runs – only when we're building the bundle.)
Expand All @@ -210,7 +210,7 @@ Edit your `rollup.config.js` file to include the JSON plugin:

```js
// rollup.config.js
import json from 'rollup-plugin-json';
import json from '@rollup/plugin-json';

export default {
input: 'src/main.js',
Expand Down Expand Up @@ -252,7 +252,7 @@ Edit your `rollup.config.js` file to add a second minified output. As format, we

```js
// rollup.config.js
import json from 'rollup-plugin-json';
import json from '@rollup/plugin-json';
import {terser} from 'rollup-plugin-terser';

export default {
Expand Down
2 changes: 1 addition & 1 deletion docs/06-faqs.md
Expand Up @@ -12,7 +12,7 @@ Tree-shaking, also known as "live code inclusion," is the process of eliminating

#### How do I use Rollup in Node.js with CommonJS modules?

Rollup strives to implement the specification for ES modules, not necessarily the behaviors of Node.js, NPM, `require()`, and CommonJS. Consequently, loading of CommonJS modules and use of Node's module location resolution logic are both implemented as optional plugins, not included by default in the Rollup core. Just `npm install` the [commonjs](https://github.com/rollup/rollup-plugin-commonjs) and [node-resolve](https://github.com/rollup/rollup-plugin-node-resolve) plugins and then enable them using a `rollup.config.js` file and you should be all set. If the modules import JSON files, you will also need the [json](https://github.com/rollup/rollup-plugin-json) plugin.
Rollup strives to implement the specification for ES modules, not necessarily the behaviors of Node.js, NPM, `require()`, and CommonJS. Consequently, loading of CommonJS modules and use of Node's module location resolution logic are both implemented as optional plugins, not included by default in the Rollup core. Just `npm install` the [commonjs](https://github.com/rollup/plugins/tree/master/packages/commonjs) and [node-resolve](https://github.com/rollup/plugins/tree/master/packages/node-resolve) plugins and then enable them using a `rollup.config.js` file and you should be all set. If the modules import JSON files, you will also need the [json](https://github.com/rollup/plugins/tree/master/packages/json) plugin.

#### Why isn't node-resolve a built-in feature?

Expand Down
24 changes: 12 additions & 12 deletions docs/07-tools.md
Expand Up @@ -41,19 +41,19 @@ the-answer (imported by main.js)
The resulting `bundle.js` will still work in Node.js, because the `import` declaration gets turned into a CommonJS `require` statement, but `the-answer` does *not* get included in the bundle. For that, we need a plugin.


#### rollup-plugin-node-resolve
#### @rollup/plugin-node-resolve

The [rollup-plugin-node-resolve](https://github.com/rollup/rollup-plugin-node-resolve) plugin teaches Rollup how to find external modules. Install it…
The [@rollup/plugin-node-resolve](https://github.com/rollup/plugins/tree/master/packages/node-resolve) plugin teaches Rollup how to find external modules. Install it…

```
npm install --save-dev rollup-plugin-node-resolve
npm install --save-dev @rollup/plugin-node-resolve
```

…and add it to your config file:

```js
// rollup.config.js
import resolve from 'rollup-plugin-node-resolve';
import resolve from '@rollup/plugin-node-resolve';

export default {
input: 'src/main.js',
Expand All @@ -68,13 +68,13 @@ export default {
This time, when you `npm run build`, no warning is emitted — the bundle contains the imported module.


#### rollup-plugin-commonjs
#### @rollup/plugin-commonjs

Some libraries expose ES modules that you can import as-is — `the-answer` is one such module. But at the moment, the majority of packages on NPM are exposed as CommonJS modules instead. Until that changes, we need to convert CommonJS to ES2015 before Rollup can process them.

The [rollup-plugin-commonjs](https://github.com/rollup/rollup-plugin-commonjs) plugin does exactly that.
The [@rollup/plugin-commonjs](https://github.com/rollup/plugins/tree/master/packages/commonjs) plugin does exactly that.

Note that `rollup-plugin-commonjs` should go *before* other plugins that transform your modules — this is to prevent other plugins from making changes that break the CommonJS detection.
Note that `@rollup/plugin-commonjs` should go *before* other plugins that transform your modules — this is to prevent other plugins from making changes that break the CommonJS detection.


### Peer dependencies
Expand All @@ -92,7 +92,7 @@ Here is the config file:

```js
// rollup.config.js
import resolve from 'rollup-plugin-node-resolve';
import resolve from '@rollup/plugin-node-resolve';

export default {
input: 'src/main.js',
Expand Down Expand Up @@ -138,14 +138,14 @@ Many developers use [Babel](https://babeljs.io/) in their projects in order to u
The easiest way to use both Babel and Rollup is with [rollup-plugin-babel](https://github.com/rollup/rollup-plugin-babel). First, install the plugin:

```
npm i -D rollup-plugin-babel rollup-plugin-node-resolve
npm i -D rollup-plugin-babel @rollup/plugin-node-resolve
```

Add it to `rollup.config.js`:

```js
// rollup.config.js
import resolve from 'rollup-plugin-node-resolve';
import resolve from '@rollup/plugin-node-resolve';
import babel from 'rollup-plugin-babel';

export default {
Expand Down Expand Up @@ -221,7 +221,7 @@ The syntax is very similar to the configuration file, but the properties are spl
```js
const gulp = require('gulp');
const rollup = require('rollup');
const rollupTypescript = require('rollup-plugin-typescript');
const rollupTypescript = require('@rollup/plugin-typescript');

gulp.task('build', () => {
return rollup.rollup({
Expand All @@ -245,7 +245,7 @@ You may also use the `async/await` syntax:
```js
const gulp = require('gulp');
const rollup = require('rollup');
const rollupTypescript = require('rollup-plugin-typescript');
const rollupTypescript = require('@rollup/plugin-typescript');

gulp.task('build', async function () {
const bundle = await rollup.rollup({
Expand Down
4 changes: 2 additions & 2 deletions docs/08-troubleshooting.md
Expand Up @@ -52,7 +52,7 @@ Occasionally you will see an error message like this:
Import declarations must have corresponding export declarations in the imported module. For example, if you have `import a from './a.js'` in a module, and a.js doesn't have an `export default` declaration, or `import {foo} from './b.js'`, and b.js doesn't export `foo`, Rollup cannot bundle the code.

This error frequently occurs with CommonJS modules converted by [rollup-plugin-commonjs](https://github.com/rollup/rollup-plugin-commonjs), which makes a reasonable attempt to generate named exports from the CommonJS code but won't always succeed, because the freewheeling nature of CommonJS is at odds with the rigorous approach we benefit from in JavaScript modules. It can be solved by using the [namedExports](https://github.com/rollup/rollup-plugin-commonjs#custom-named-exports) option, which allows you to manually fill in the information gaps.
This error frequently occurs with CommonJS modules converted by [@rollup/plugin-commonjs](https://github.com/rollup/plugins/tree/master/packages/commonjs), which makes a reasonable attempt to generate named exports from the CommonJS code but won't always succeed, because the freewheeling nature of CommonJS is at odds with the rigorous approach we benefit from in JavaScript modules. It can be solved by using the [namedExports](https://github.com/rollup/plugins/tree/master/packages/commonjs#custom-named-exports) option, which allows you to manually fill in the information gaps.


### Error: "this is undefined"
Expand Down Expand Up @@ -89,6 +89,6 @@ export default {
};
```

If you *do* want to include the module in your bundle, you need to tell Rollup how to find it. In most cases, this is a question of using [rollup-plugin-node-resolve](https://github.com/rollup/rollup-plugin-node-resolve).
If you *do* want to include the module in your bundle, you need to tell Rollup how to find it. In most cases, this is a question of using [@rollup/plugin-node-resolve](https://github.com/rollup/plugins/tree/master/packages/node-resolve).

Some modules, like `events` or `util`, are built in to Node.js. If you want to include those (for example, so that your bundle runs in the browser), you may need to include [rollup-plugin-node-builtins](https://github.com/calvinmetcalf/rollup-plugin-node-builtins).
6 changes: 3 additions & 3 deletions docs/999-big-list-of-options.md
Expand Up @@ -262,8 +262,8 @@ See [Using plugins](guide/en/#using-plugins) for more information on how to use

```js
// rollup.config.js
import resolve from 'rollup-plugin-node-resolve';
import commonjs from 'rollup-plugin-commonjs';
import resolve from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';

const isProduction = process.env.NODE_ENV === 'production';

Expand Down Expand Up @@ -325,7 +325,7 @@ Type: `{ [chunkAlias: string]: string[] } | ((id: string) => string | void)`

Allows the creation of custom shared common chunks. When using the object form, each property represents a chunk that contains the listed modules and all their dependencies if they are part of the module graph unless they are already in another manual chunk. The name of the chunk will be determined by the property key.

Note that it is not necessary for the listed modules themselves to be be part of the module graph, which is useful if you are working with `rollup-plugin-node-resolve` and use deep imports from packages. For instance
Note that it is not necessary for the listed modules themselves to be be part of the module graph, which is useful if you are working with `@rollup/plugin-node-resolve` and use deep imports from packages. For instance

```
manualChunks: {
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "rollup",
"version": "1.27.13",
"version": "1.27.14",
"description": "Next-generation ES module bundler",
"main": "dist/rollup.js",
"module": "dist/rollup.es.js",
Expand Down

0 comments on commit 2ae5484

Please sign in to comment.