Skip to content

Commit 52fc969

Browse files
authored
Rewrite website in Vitepress and merge it into the main repository (#4807)
* Initial setup with REPL * Require Rollup >= 1 * Support for local development * Unify rollup and request stores * Refine query handling for local Rollup * Improve styling * Start migrating links * Add mermaid support (note that we are stuck at 9.1.7 for now due to a bug) * Fix vulnerabilities (we need to stick to a slightly older mermaid version) * Use /repl/ links for the repl to remain compatible with the existing URLs * Improve folder structure * Fix remaining links * Handle legacy slugs * Start to improve REPL styling * Extract anchor verification logic * Display Rollup logo in production * Display Rollup version in interface * Make entry modules nicer * Remove default button color * Make select nicer * Fix display of options * Add outline + TOC to all pages + decrease heading levels * Change type to shell for shell scripts * Improve styles * Merge input and output modules * Extract OptionsSelect * Refine styling * Make REPL modules responsive * Finalize REPL styling * Add all examples * Use shorter line length in markdown To avoid scroll bars in code boxes * Improve REPL highlighting * Update anchor mapping * Handle missing Rollup version * Fix tests * Automatically verify slugs in mermaid graphs * Add favicon + sharing options * Support HMR for Rollup * Extract all Rollup urls to separate file * Verify URLs referenced in Rollup * Refine home page text * Prevent input zoom in REPL on iOS * Automatically deploy documentation on release per tag * Update CONTRIBUTING.md
1 parent 635e2b9 commit 52fc969

File tree

194 files changed

+11055
-3498
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

194 files changed

+11055
-3498
lines changed

.eslintrc.js

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,11 @@ module.exports = {
1919
'perf',
2020
'tmp',
2121
'_tmp',
22+
'cache',
2223
'/test/*/samples/**/*.*',
2324
'!/test/*/samples/**/_config.js',
24-
'!/test/*/samples/**/rollup.config.js'
25+
'!/test/*/samples/**/rollup.config.js',
26+
'!.vitepress'
2527
],
2628
overrides: [
2729
{
@@ -46,6 +48,23 @@ module.exports = {
4648
rules: {
4749
'sort-keys': 'off'
4850
}
51+
},
52+
{
53+
extends: [
54+
'plugin:vue/vue3-essential',
55+
'@vue/eslint-config-typescript/recommended',
56+
'@vue/eslint-config-prettier'
57+
],
58+
files: ['*.vue']
59+
},
60+
{
61+
files: ['docs/repl/examples/**/*.js'],
62+
rules: {
63+
'import/namespace': 'off',
64+
'import/no-unresolved': 'off',
65+
'no-undef': 'off',
66+
'unicorn/prevent-abbreviations': 'off'
67+
}
4968
}
5069
],
5170
parser: '@typescript-eslint/parser',
@@ -80,7 +99,7 @@ module.exports = {
8099
'error',
81100
{
82101
// 'fsevents' is only available on macOS, and not installed on linux/windows
83-
ignore: ['fsevents', 'help.md', 'is-reference', 'package.json', 'types']
102+
ignore: ['fsevents', 'help.md', 'is-reference', 'package.json', 'types', 'examples.json']
84103
}
85104
],
86105
'import/order': ['error', { alphabetize: { order: 'asc' } }],

.github/workflows/deploy-website.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: Deploy rollupjs.org
2+
3+
on:
4+
push:
5+
tags:
6+
- documentation-published
7+
8+
permissions:
9+
contents: read
10+
11+
jobs:
12+
deploy:
13+
name: 'Deploy to Netlify'
14+
steps:
15+
- uses: jsmrcaga/[email protected]
16+
with:
17+
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
18+
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
19+
NETLIFY_DEPLOY_TO_PROD: true
20+
build_directory: docs/.vitepress/dist/
21+
build_command: npm run build:docs

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
.DS_Store
22
/node_modules
33
.gobble*
4+
cache
45
dist
56
_actual
67
_actual.js
@@ -15,3 +16,4 @@ test/typescript/typings
1516
perf/
1617
.nyc_output/
1718
.github_token
19+
.temp

.prettierrc.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
"useTabs": true,
77
"overrides": [
88
{
9-
"files": "*.md",
9+
"files": "**/*.md",
1010
"options": {
11-
"useTabs": false,
11+
"printWidth": 76,
1212
"tabWidth": 2,
1313
"proseWrap": "never"
1414
}

CONTRIBUTING.md

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,31 @@ Working on your first Pull Request? You can learn how from this _free_ course, [
1818

1919
### How to run one test on your local machine
2020

21-
you can set up `solo:true` in `_config.js` in one test and run `npm run test`.
21+
With `npm run test` you can run all tests together.
22+
23+
To save time for quick iterations, you can add `solo:true` to the `_config.js` file of any given test to run just this one test. To further speed up rebuilds, note that most tests just need the CommonJS build of Rollup.
24+
25+
For those tests, it is enough to run
26+
27+
```shell
28+
npm run build:cjs
29+
npm run test:quick
30+
31+
```
32+
33+
Note that this does not run the browser tests and a few CLI tests will fail.
34+
35+
### Developing with the website
36+
37+
Running
38+
39+
```shell
40+
npm run dev
41+
```
42+
43+
will start the website locally in development mode via Vite. This will give you a live preview of the documentation. It will also verify that the documentation does not contain any dead links.
44+
45+
A special feature of the website is that the REPL at `http://localhost:5173/repl/` is directly using the browser build of your local copy of Rollup created via Vite. It even supports full hot module replacement, which means that when you change anything within Rollup, the REPL will automatically rebundle the current code using your latest changes. This can come in very handy when working on a bug or tree-shaking improvement to allow extremely fast iterations.
2246

2347
## Submitting code
2448

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ Rollup is a module bundler for JavaScript which compiles small pieces of code in
3535

3636
## Quick Start Guide
3737

38-
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/).
38+
Install with `npm install --global rollup`. Rollup can be used either through a [command line interface](https://rollupjs.org/command-line-interface/) 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/introduction/).
3939

4040
### Commands
4141

build-plugins/aliases.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { fileURLToPath } from 'node:url';
2+
3+
export const moduleAliases = {
4+
entries: {
5+
acorn: fileURLToPath(new URL('../node_modules/acorn/dist/acorn.mjs', import.meta.url)),
6+
'help.md': fileURLToPath(new URL('../cli/help.md', import.meta.url)),
7+
'package.json': fileURLToPath(new URL('../package.json', import.meta.url))
8+
},
9+
resolve: ['.js', '.json', '.md']
10+
};

build-plugins/replace-browser-modules.ts

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1-
import { dirname, join, resolve } from 'node:path';
1+
import { dirname, join } from 'node:path';
2+
import { fileURLToPath } from 'node:url';
23
import type { Plugin } from 'rollup';
34

4-
const resolutions = {
5+
const resolve = (path: string) => fileURLToPath(new URL(`../${path}`, import.meta.url));
6+
7+
export const resolutions = {
58
[resolve('src/utils/crypto')]: resolve('browser/src/crypto.ts'),
69
[resolve('src/utils/fs')]: resolve('browser/src/fs.ts'),
710
[resolve('src/utils/hookActions')]: resolve('browser/src/hookActions.ts'),
@@ -11,12 +14,16 @@ const resolutions = {
1114
[resolve('src/utils/resolveId')]: resolve('browser/src/resolveId.ts')
1215
};
1316

17+
for (const key of Object.keys(resolutions)) {
18+
resolutions[`${key}.ts`] = resolutions[key];
19+
}
20+
1421
export default function replaceBrowserModules(): Plugin {
1522
return {
1623
name: 'replace-browser-modules',
17-
resolveId(source, importee) {
18-
if (importee && source[0] === '.') {
19-
const resolved = join(dirname(importee), source);
24+
resolveId(source, importer) {
25+
if (importer && source[0] === '.') {
26+
const resolved = join(dirname(importer), source);
2027
if (resolutions[resolved]) {
2128
return resolutions[resolved];
2229
}

cli/run/batchWarnings.ts

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,16 @@ import { bold, gray, yellow } from '../../src/utils/colors';
33
import { getNewArray, getOrCreate } from '../../src/utils/getOrCreate';
44
import { printQuotedStringList } from '../../src/utils/printStringList';
55
import relativeId from '../../src/utils/relativeId';
6+
import { getRollupUrl } from '../../src/utils/url';
7+
import {
8+
URL_AVOIDING_EVAL,
9+
URL_NAME_IS_NOT_EXPORTED,
10+
URL_OUTPUT_EXPORTS,
11+
URL_OUTPUT_GLOBALS,
12+
URL_SOURCEMAP_IS_LIKELY_TO_BE_INCORRECT,
13+
URL_THIS_IS_UNDEFINED,
14+
URL_TREATING_MODULE_AS_EXTERNAL_DEPENDENCY
15+
} from '../../src/utils/urls';
616
import { stderr } from '../logging';
717

818
export interface BatchWarnings {
@@ -113,13 +123,13 @@ const deferredHandlers: {
113123

114124
EVAL(warnings) {
115125
title('Use of eval is strongly discouraged');
116-
info('https://rollupjs.org/guide/en/#avoiding-eval');
126+
info(getRollupUrl(URL_AVOIDING_EVAL));
117127
showTruncatedWarnings(warnings);
118128
},
119129

120130
MISSING_EXPORT(warnings) {
121131
title('Missing exports');
122-
info('https://rollupjs.org/guide/en/#error-name-is-not-exported-by-module');
132+
info(getRollupUrl(URL_NAME_IS_NOT_EXPORTED));
123133

124134
for (const warning of warnings) {
125135
stderr(bold(relativeId(warning.id!)));
@@ -130,7 +140,7 @@ const deferredHandlers: {
130140

131141
MISSING_GLOBAL_NAME(warnings) {
132142
title(`Missing global variable ${warnings.length > 1 ? 'names' : 'name'}`);
133-
info('https://rollupjs.org/guide/en/#outputglobals');
143+
info(getRollupUrl(URL_OUTPUT_GLOBALS));
134144
stderr(
135145
`Use "output.globals" to specify browser global variable names corresponding to external modules:`
136146
);
@@ -141,7 +151,7 @@ const deferredHandlers: {
141151

142152
MIXED_EXPORTS(warnings) {
143153
title('Mixing named and default exports');
144-
info(`https://rollupjs.org/guide/en/#outputexports`);
154+
info(getRollupUrl(URL_OUTPUT_EXPORTS));
145155
stderr(bold('The following entry modules are using named and default exports together:'));
146156
warnings.sort((a, b) => (a.id! < b.id! ? -1 : 1));
147157
const displayedWarnings = warnings.length > 5 ? warnings.slice(0, 3) : warnings;
@@ -198,7 +208,7 @@ const deferredHandlers: {
198208

199209
SOURCEMAP_BROKEN(warnings) {
200210
title(`Broken sourcemap`);
201-
info('https://rollupjs.org/guide/en/#warning-sourcemap-is-likely-to-be-incorrect');
211+
info(getRollupUrl(URL_SOURCEMAP_IS_LIKELY_TO_BE_INCORRECT));
202212

203213
const plugins = [...new Set(warnings.map(({ plugin }) => plugin).filter(Boolean))] as string[];
204214
stderr(
@@ -210,13 +220,13 @@ const deferredHandlers: {
210220

211221
THIS_IS_UNDEFINED(warnings) {
212222
title('"this" has been rewritten to "undefined"');
213-
info('https://rollupjs.org/guide/en/#error-this-is-undefined');
223+
info(getRollupUrl(URL_THIS_IS_UNDEFINED));
214224
showTruncatedWarnings(warnings);
215225
},
216226

217227
UNRESOLVED_IMPORT(warnings) {
218228
title('Unresolved dependencies');
219-
info('https://rollupjs.org/guide/en/#warning-treating-module-as-external-dependency');
229+
info(getRollupUrl(URL_TREATING_MODULE_AS_EXTERNAL_DEPENDENCY));
220230

221231
const dependencies = new Map<string, string[]>();
222232
for (const warning of warnings) {

docs/.vitepress/config.ts

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
import { defineConfig } from 'vitepress';
2+
import { withMermaid } from 'vitepress-plugin-mermaid';
3+
import '../declarations.d';
4+
import { buildEnd, callback, transformPageData } from './verify-anchors';
5+
6+
export default withMermaid(
7+
defineConfig({
8+
buildEnd,
9+
description: 'compile JS code',
10+
head: [
11+
['link', { href: '/favicon.png', rel: 'icon', type: 'image/png' }],
12+
['link', { href: '/favicon.png', rel: 'apple-touch-icon', sizes: '128x128' }],
13+
['link', { href: '/manifest.json', rel: 'manifest' }],
14+
['meta', { content: '#333333', name: 'theme-color' }],
15+
['meta', { content: 'yes', name: 'mobile-web-app-capable' }],
16+
['meta', { content: 'default', name: 'apple-mobile-web-app-status-bar-style' }],
17+
['meta', { content: 'summary_large_image', name: 'twitter:card' }],
18+
['meta', { content: '@rollupjs', name: 'twitter:site' }],
19+
['meta', { content: '@rollupjs', name: 'twitter:creator' }],
20+
['meta', { content: 'Rollup', name: 'twitter:title' }],
21+
['meta', { content: 'The JavaScript module bundler', name: 'twitter:description' }],
22+
['meta', { content: 'https://rollupjs.org/twitter-card.jpg', name: 'twitter:image' }]
23+
],
24+
markdown: {
25+
anchor: {
26+
callback,
27+
level: 2
28+
},
29+
linkify: false,
30+
toc: {
31+
level: [2, 3, 4]
32+
}
33+
},
34+
themeConfig: {
35+
editLink: {
36+
pattern: 'https://github.com/rollup/rollup/edit/master/docs/:path',
37+
text: 'Edit this page on GitHub'
38+
},
39+
footer: {
40+
copyright: 'Copyright © 2015-present Rollup contributors',
41+
message: 'Released under the MIT License.'
42+
},
43+
logo: '/rollup-logo.svg',
44+
nav: [
45+
{ link: '/introduction/', text: 'guide' },
46+
{ link: '/repl/', text: 'repl' },
47+
{ link: 'https://is.gd/rollup_chat', text: 'chat' },
48+
{ link: 'https://opencollective.com/rollup', text: 'opencollective' }
49+
],
50+
outline: 'deep',
51+
sidebar: [
52+
{
53+
items: [
54+
{
55+
link: '/introduction/',
56+
text: 'Introduction'
57+
},
58+
{
59+
link: '/command-line-interface/',
60+
text: 'Command Line Interface'
61+
},
62+
{
63+
link: '/javascript-api/',
64+
text: 'Javascript API'
65+
}
66+
],
67+
text: 'Getting started'
68+
},
69+
{
70+
items: [
71+
{
72+
link: '/tutorial/',
73+
text: 'Tutorial'
74+
},
75+
{
76+
link: '/es-module-syntax/',
77+
text: 'ES Module Syntax'
78+
},
79+
{
80+
link: '/faqs/',
81+
text: 'Frequently Asked Questions'
82+
},
83+
{
84+
link: '/troubleshooting/',
85+
text: 'Troubleshooting'
86+
},
87+
{
88+
link: '/migration/',
89+
text: 'Migrating to Rollup 3'
90+
},
91+
{
92+
link: '/tools/',
93+
text: 'Other Tools'
94+
}
95+
],
96+
text: 'More info'
97+
},
98+
{
99+
items: [
100+
{
101+
link: '/configuration-options/',
102+
text: 'Configuration Options'
103+
},
104+
{
105+
link: '/plugin-development/',
106+
text: 'Plugin Development'
107+
}
108+
],
109+
text: 'API'
110+
}
111+
],
112+
socialLinks: [{ icon: 'github', link: 'https://github.com/rollup/rollup' }]
113+
},
114+
title: 'Rollup',
115+
transformPageData
116+
})
117+
);

0 commit comments

Comments
 (0)