diff --git a/README.md b/README.md index 526d6e164ed..303e43db255 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/docs/00-introduction.md b/docs/00-introduction.md index a05623b2567..838f44ffb6d 100755 --- a/docs/00-introduction.md +++ b/docs/00-introduction.md @@ -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 diff --git a/docs/01-command-line-reference.md b/docs/01-command-line-reference.md index 84692c63a7a..3d67e9b49b8 100755 --- a/docs/01-command-line-reference.md +++ b/docs/01-command-line-reference.md @@ -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. diff --git a/docs/04-tutorial.md b/docs/04-tutorial.md index ec4061266d8..34febe4b35d 100755 --- a/docs/04-tutorial.md +++ b/docs/04-tutorial.md @@ -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: @@ -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.) @@ -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', @@ -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 { diff --git a/docs/06-faqs.md b/docs/06-faqs.md index eaa8142bac4..d582ce2e4df 100755 --- a/docs/06-faqs.md +++ b/docs/06-faqs.md @@ -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? diff --git a/docs/07-tools.md b/docs/07-tools.md index e284f0842c9..73216284885 100755 --- a/docs/07-tools.md +++ b/docs/07-tools.md @@ -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… @@ -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 @@ -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', @@ -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 { @@ -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({ @@ -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({ diff --git a/docs/08-troubleshooting.md b/docs/08-troubleshooting.md index ac4f35679cb..07066415bf0 100644 --- a/docs/08-troubleshooting.md +++ b/docs/08-troubleshooting.md @@ -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" @@ -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). diff --git a/docs/999-big-list-of-options.md b/docs/999-big-list-of-options.md index 49ef0472435..0059c5841d0 100755 --- a/docs/999-big-list-of-options.md +++ b/docs/999-big-list-of-options.md @@ -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'; @@ -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: { diff --git a/src/Module.ts b/src/Module.ts index 6124b2dce5d..bf8b3531edc 100644 --- a/src/Module.ts +++ b/src/Module.ts @@ -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)'; } diff --git a/test/function/samples/error-parse-json/_config.js b/test/function/samples/error-parse-json/_config.js index e9a3c2fe6a6..62dbc19fa45 100644 --- a/test/function/samples/error-parse-json/_config.js +++ b/test/function/samples/error-parse-json/_config.js @@ -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,