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

Add new mermaid graphs #230

Merged
merged 8 commits into from Aug 16, 2021
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
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -4,6 +4,7 @@ node_modules
.vscode
/export
.idea
static/graphs

# Needs to be taken from the main rollup repo
guide/en
1 change: 1 addition & 0 deletions .nvmrc
@@ -0,0 +1 @@
14
3 changes: 3 additions & 0 deletions mermaid.config.json
@@ -0,0 +1,3 @@
{
"themeCSS": "span.edgeLabel { background-color: #fff } path.LS-parallel,path.LS-sequential,path.LS-legend { stroke: none }"
}
5,087 changes: 4,215 additions & 872 deletions package-lock.json

Large diffs are not rendered by default.

49 changes: 26 additions & 23 deletions package.json
Expand Up @@ -3,49 +3,52 @@
"author": "Rich Harris",
"version": "1.0.0",
"devDependencies": {
"@babel/core": "^7.14.3",
"@babel/core": "^7.15.0",
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
"@babel/plugin-transform-runtime": "^7.14.3",
"@babel/preset-env": "^7.14.2",
"@babel/plugin-transform-runtime": "^7.15.0",
"@babel/preset-env": "^7.15.0",
"@mermaid-js/mermaid-cli": "^8.11.4",
"@rollup/plugin-babel": "^5.3.0",
"@rollup/plugin-commonjs": "^19.0.0",
"@rollup/plugin-node-resolve": "^13.0.0",
"@rollup/plugin-replace": "^2.4.2",
"@rollup/plugin-url": "^6.0.0",
"husky": "^6.0.0",
"lint-staged": "^11.0.0",
"prettier": "^2.3.0",
"prettier-plugin-svelte": "^2.3.0",
"rollup": "^2.49.0",
"@rollup/plugin-commonjs": "^20.0.0",
"@rollup/plugin-node-resolve": "^13.0.4",
"@rollup/plugin-replace": "^3.0.0",
"@rollup/plugin-url": "^6.1.0",
"husky": "^7.0.1",
"lint-staged": "^11.1.2",
"prettier": "^2.3.2",
"prettier-plugin-svelte": "^2.3.1",
"rollup": "^2.56.2",
"rollup-plugin-svelte": "^7.1.0",
"rollup-plugin-terser": "^7.0.2",
"sapper": "^0.29.1",
"sapper": "^0.29.2",
"shx": "^0.3.3",
"sirv-cli": "^1.0.12",
"svelte": "^3.38.2"
"sirv": "^1.0.14",
"sirv-cli": "^1.0.14",
"svelte": "^3.42.1",
"zx": "^2.1.0"
},
"scripts": {
"dev": "sapper dev",
"build": "npm run clean && npm run update-guide && sapper export --legacy && cp -r __sapper__/export export",
"build": "npm run clean && npm run update-guide && npm run generate-graphs && sapper export --legacy && cp -r __sapper__/export export",
"start": "sirv export",
"update-guide": "git submodule update --init --recursive && shx rm -rf guide/en && shx cp -r rollup-submodule/docs/ guide/en",
"publish-updated-guide": "git pull && git submodule update --init --recursive && cd rollup-submodule && git checkout master && git pull && cd .. && npm test && git add rollup-submodule && git commit -m \"Update guide\" && git push",
"clean": "rm -rf export/ && rm -rf __sapper__/",
"lint": "prettier --write src/**/*.{js,html,svelte} test/**/*.js",
"generate-graphs": "zx scripts/generate-graphs.mjs",
"stage": "netlify deploy --dir=export",
"deploy": "netlify deploy --dir=export --prod",
"prestage": "npm run build",
"predeploy": "npm run build",
"test": "npx rollup test/verify-guide-links.js -f cjs --silent | node",
"test": "npx rollup scripts/verify-guide-links.js -f cjs --silent | node",
"postinstall": "husky install"
},
"dependencies": {
"@babel/runtime": "^7.14.0",
"codemirror": "^5.61.1",
"@babel/runtime": "^7.15.3",
"codemirror": "^5.62.2",
"compression": "^1.7.4",
"highlight.js": "^10.7.2",
"marked": "^2.0.5",
"polka": "^0.5.2",
"sirv": "^1.0.12"
"highlight.js": "^11.2.0",
"marked": "^2.1.3",
"polka": "^0.5.2"
}
}
2 changes: 1 addition & 1 deletion rollup-submodule
Submodule rollup-submodule updated 99 files
+2 −7 .github/ISSUE_TEMPLATE/SUPPORT.md
+6 −2 .github/PULL_REQUEST_TEMPLATE.md
+2 −0 .prettierignore
+0 −7 .prettierrc
+17 −0 .prettierrc.json
+3,362 −2,256 CHANGELOG.md
+10 −10 CODE_OF_CONDUCT.md
+7 −20 CONTRIBUTING.md
+3 −15 LICENSE-CORE.md
+2 −12 README.md
+5 −8 docs/00-introduction.md
+41 −37 docs/01-command-line-reference.md
+20 −20 docs/02-javascript-api.md
+5 −8 docs/03-es-module-syntax.md
+24 −20 docs/04-tutorial.md
+137 −174 docs/05-plugin-development.md
+3 −1 docs/06-faqs.md
+33 −46 docs/07-tools.md
+9 −15 docs/08-troubleshooting.md
+343 −379 docs/999-big-list-of-options.md
+59 −0 docs/build-hooks.mmd
+17 −0 docs/hooks-legend.html
+80 −0 docs/output-generation-hooks.mmd
+1 −165 package-lock.json
+4 −5 package.json
+1 −8 src/Chunk.ts
+3 −3 src/ModuleLoader.ts
+44 −27 src/ast/nodes/AssignmentExpression.ts
+2 −4 src/ast/nodes/BinaryExpression.ts
+2 −3 src/ast/nodes/CallExpression.ts
+2 −3 src/ast/nodes/ClassExpression.ts
+3 −6 src/ast/nodes/ConditionalExpression.ts
+1 −2 src/ast/nodes/ExportDefaultDeclaration.ts
+2 −3 src/ast/nodes/FunctionExpression.ts
+5 −3 src/ast/nodes/ImportExpression.ts
+3 −4 src/ast/nodes/LogicalExpression.ts
+1 −6 src/ast/nodes/MemberExpression.ts
+3 −4 src/ast/nodes/ObjectExpression.ts
+6 −10 src/ast/nodes/SequenceExpression.ts
+19 −33 src/ast/nodes/UpdateExpression.ts
+50 −26 src/ast/nodes/VariableDeclaration.ts
+1 −1 src/ast/nodes/VariableDeclarator.ts
+5 −11 src/finalisers/system.ts
+6 −2 src/utils/renderHelpers.ts
+83 −17 src/utils/systemJsRendering.ts
+2 −2 test/chunking-form/samples/chunk-live-bindings/_expected/system/generated-dep1.js
+1 −1 test/chunking-form/samples/deprecated/preserve-modules-export-alias/_expected/system/dep.js
+1 −1 test/chunking-form/samples/preserve-modules-export-alias/_expected/system/dep.js
+1 −276 test/chunking-form/samples/sanitize-internal-exports/_expected/system/main.js
+1 −1 test/form/samples/assignment-to-exports-class-declaration/_expected/system.js
+8 −15 test/form/samples/assignment-to-exports/_expected/system.js
+3 −3 test/form/samples/compact-named-export/_expected/system.js
+1 −1 test/form/samples/deconflict-format-specific-exports/_expected/system.js
+1 −1 test/form/samples/deconflict-format-specific-globals/_expected/system.js
+1 −1 test/form/samples/default-export-live-binding/_expected/system.js
+2 −2 test/form/samples/export-live-bindings/_expected/system.js
+1 −1 test/form/samples/modify-export-semi/_expected/system.js
+3 −8 test/form/samples/override-external-namespace/_expected/system.js
+2 −2 test/form/samples/reassigned-exported-functions-and-classes/_expected/system.js
+4 −11 test/form/samples/render-declaration-semicolons/_expected/system.js
+8 −17 test/form/samples/render-named-export-declarations/_expected/system.js
+4 −0 test/form/samples/simplified-initializer/_config.js
+13 −0 test/form/samples/simplified-initializer/_expected/amd.js
+11 −0 test/form/samples/simplified-initializer/_expected/cjs.js
+5 −0 test/form/samples/simplified-initializer/_expected/es.js
+16 −0 test/form/samples/simplified-initializer/_expected/iife.js
+12 −0 test/form/samples/simplified-initializer/_expected/system.js
+17 −0 test/form/samples/simplified-initializer/_expected/umd.js
+3 −0 test/form/samples/simplified-initializer/main.js
+3 −2 test/form/samples/system-comments/_expected.js
+0 −3 test/form/samples/system-export-compact/_expected.js
+0 −5 test/form/samples/system-export-compact/main.js
+8 −0 test/form/samples/system-export-declarations/_config.js
+30 −0 test/form/samples/system-export-declarations/_expected.js
+27 −0 test/form/samples/system-export-declarations/main.js
+0 −8 test/form/samples/system-export-destructuring-assignment/_config.js
+0 −19 test/form/samples/system-export-destructuring-assignment/_expected.js
+0 −4 test/form/samples/system-export-destructuring-assignment/main.js
+3 −1 test/form/samples/system-export-destructuring-declaration/_expected.js
+2 −0 test/form/samples/system-export-destructuring-declaration/main.js
+1 −1 test/form/samples/system-export-rendering-compact/_config.js
+55 −0 test/form/samples/system-export-rendering-compact/_expected.js
+56 −0 test/form/samples/system-export-rendering-compact/main.js
+8 −0 test/form/samples/system-export-rendering/_config.js
+64 −0 test/form/samples/system-export-rendering/_expected.js
+56 −0 test/form/samples/system-export-rendering/main.js
+9 −9 test/form/samples/system-multiple-export-bindings/_expected.js
+3 −6 test/form/samples/system-uninitialized/_expected.js
+13 −13 test/form/samples/updating-assignments/_expected/system.js
+8 −9 test/function/samples/function-expressions-simplified-to-statement/main.js
+1 −0 test/function/samples/max-parallel-file-reads-with-plugin/1.js
+1 −0 test/function/samples/max-parallel-file-reads-with-plugin/2.js
+1 −0 test/function/samples/max-parallel-file-reads-with-plugin/3.js
+1 −0 test/function/samples/max-parallel-file-reads-with-plugin/4.js
+1 −0 test/function/samples/max-parallel-file-reads-with-plugin/5.js
+36 −0 test/function/samples/max-parallel-file-reads-with-plugin/_config.js
+5 −0 test/function/samples/max-parallel-file-reads-with-plugin/main.js
+3 −0 test/function/samples/simplify-with-destructuring/_config.js
+7 −0 test/function/samples/simplify-with-destructuring/main.js
15 changes: 15 additions & 0 deletions scripts/generate-graphs.mjs
@@ -0,0 +1,15 @@
#!/usr/bin/env zx

import path from 'path';

const mermaidFiles = await globby('guide/en/*.mmd');
await fs.ensureDir('static/graphs');
await Promise.all(
mermaidFiles.map(
file =>
$`npx mmdc -c mermaid.config.json -i "${file}" -o "static/graphs/${path.basename(
file,
'.mmd'
)}.svg"`
)
);
File renamed without changes.
7 changes: 0 additions & 7 deletions src/components/Guide.svelte
Expand Up @@ -246,13 +246,6 @@
top: -0.1em;
}

.content :global(p),
.content :global(ol) {
margin: 0 0 1em 0;
color: #181818;
line-height: 1.5;
}

.content :global(a) {
border-bottom: 1px solid #e3d9d9;
}
Expand Down
18 changes: 17 additions & 1 deletion src/helpers/createGuide.js
Expand Up @@ -66,7 +66,11 @@ function create_guide(lang) {
.replace(/<p>@@(\d+)<\/p>/g, (match, id) => {
return `<pre><code>${highlighted[id]}</code></pre>`;
})
.replace(/^\t+/gm, match => match.split('\t').join(' '));
.replace(/^\t+/gm, match => match.split('\t').join(' '))
.replace(/<!-- html:([\w.-]+) -->/g, (_, fileName) =>
fs.readFileSync(`guide/en/${fileName}`, 'utf8')
)
.replace(/<!-- mermaid:([\w.-]+)\.mmd -->/g, (_, fileName) => getSvgGraph(fileName));

const subsections = [];
const pattern = /<h3 id="(.+?)">(.+?)<\/h3>/g;
Expand Down Expand Up @@ -95,3 +99,15 @@ function create_guide(lang) {
};
});
}

// This will avoid a layout shift and wrong anchor positions by making sure the
// element has the correct size before the file is loaded
function getSvgGraph(fileName) {
const fileContent = fs.readFileSync(`static/graphs/${fileName}.svg`, 'utf8');
const [, width, height] = fileContent.match(/viewBox="0 0 ([\d.]+) ([\d.]+)"/);
return `
<object
data="graphs/${fileName}.svg"
type="image/svg+xml"
style="max-width:80vw; height:min(${height}px,calc(80vw * ${height / width}))"></object>`;
}
31 changes: 26 additions & 5 deletions static/global.css
Expand Up @@ -24,8 +24,9 @@
body {
margin: 0;
background: #fff;
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
color: #555;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif,
'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol';
color: #181818;
line-height: 1.5;
-webkit-font-smoothing: antialiased;
}
Expand All @@ -35,7 +36,8 @@ main {
overflow-x: hidden;
}

code, pre {
code,
pre {
font-family: 'Inconsolata', monospace;
font-weight: 400;
line-height: 1.2;
Expand All @@ -45,15 +47,17 @@ pre {
overflow-x: auto;
}

h1, h2, h3 {
h1,
h2,
h3 {
margin: 0;
font-weight: 300;
line-height: 1.2;
}

a {
text-decoration: none;
color: rgb(170,30,30);
color: rgb(170, 30, 30);
}

strong {
Expand Down Expand Up @@ -127,3 +131,20 @@ strong {
.hljs-meta-string {
color: #555;
}

.legend-grid {
display: grid;
grid-template-columns: max-content max-content;
grid-column-gap: 16px;
}

.legend-rect {
display: inline-block;
width: 16px;
height: 16px;
border-radius: 5px;
border: 1px solid #000;
vertical-align: middle;
margin-right: 5px;
background: #fff;
}