Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update references to official rollup plugins #3298

Merged
merged 2 commits into from Dec 22, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
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
2 changes: 1 addition & 1 deletion docs/00-introduction.md
Expand Up @@ -80,7 +80,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
18 changes: 9 additions & 9 deletions docs/07-tools.md
Expand Up @@ -41,7 +41,7 @@ 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/plugins/tree/master/packages/node-resolve) plugin teaches Rollup how to find external modules. Install it…

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 src/Module.ts
Expand Up @@ -131,7 +131,7 @@ function tryParse(module: Module, Parser: typeof acorn.Parser, acornOptions: aco
} catch (err) {
let message = err.message.replace(/ \(\d+:\d+\)$/, '');
if (module.id.endsWith('.json')) {
message += ' (Note that you need rollup-plugin-json to import JSON files)';
message += ' (Note that you need @rollup/plugin-json to import JSON files)';
} else if (!module.id.endsWith('.js')) {
message += ' (Note that you need plugins to import files that are not JavaScript)';
}
Expand Down
2 changes: 1 addition & 1 deletion test/function/samples/error-parse-json/_config.js
Expand Up @@ -5,7 +5,7 @@ module.exports = {
'throws with an extended error message when failing to parse a file with ".json" extension',
error: {
code: 'PARSE_ERROR',
message: 'Unexpected token (Note that you need rollup-plugin-json to import JSON files)',
message: 'Unexpected token (Note that you need @rollup/plugin-json to import JSON files)',
parserError: {
loc: {
column: 8,
Expand Down