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

[docs] Revert upgrade to next 9 #16755

Merged
merged 4 commits into from
Jul 26, 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,8 @@ steps:
artifactName: 'canaries'
targetPath: 'material-ui-core.tgz'

- bash: |
set -o pipefail
mkdir -p scripts/sizeSnapshot/build
yarn docs:build | tee scripts/sizeSnapshot/build/docs.next
set +o pipefail
- script: |
yarn docs:build
displayName: 'build docs'

- script: |
Expand Down
2 changes: 1 addition & 1 deletion docs/babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const alias = {
};

module.exports = {
presets: ['next/babel'],
presets: ['next/babel', '@zeit/next-typescript/babel'],
plugins: [
'babel-plugin-optimize-clsx',
// for IE 11 support
Expand Down
2 changes: 0 additions & 2 deletions docs/next-env.d.ts

This file was deleted.

11 changes: 9 additions & 2 deletions docs/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@ const webpack = require('webpack');
const pkg = require('../package.json');
const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');
const { findPages } = require('./src/modules/utils/find');
const withTypescript = require('@zeit/next-typescript');
const path = require('path');

const LANGUAGES = ['en', 'zh', 'ru', 'pt', 'fr', 'es', 'de'];

const workspaceRoot = path.join(__dirname, '../');

module.exports = {
module.exports = withTypescript({
webpack: (config, options) => {
const plugins = config.plugins.concat([
new webpack.DefinePlugin({
Expand Down Expand Up @@ -150,4 +151,10 @@ module.exports = {

return map;
},
};
onDemandEntries: {
// Period (in ms) where the server will keep pages in the buffer
maxInactiveAge: 120 * 1e3, // default 25s
// Number of pages that should be kept simultaneously without being disposed
pagesBufferLength: 3, // default 2
},
});
3 changes: 2 additions & 1 deletion docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"@types/react-virtualized": "^9.21.4",
"@types/react-window": "^1.7.0",
"@types/styled-components": "4.1.12",
"@zeit/next-typescript": "^1.1.1",
"address": "^1.0.3",
"ast-types": "^0.13.2",
"autoprefixer": "^9.6.1",
Expand All @@ -61,7 +62,7 @@
"markdown-to-jsx": "^6.10.2",
"material-table": "^1.40.1",
"material-ui-popup-state": "^1.4.0",
"next": "^9.0.2",
"next": "8.1.0",
"notistack": "^0.8.9",
"postcss": "^7.0.0",
"raw-loader": "^1.0.0",
Expand Down
5 changes: 1 addition & 4 deletions docs/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@
"include": ["types", "src/pages/**/*"],
"compilerOptions": {
"allowJs": false,
"isolatedModules": true,
"noUnusedLocals": true,
"resolveJsonModule": true,
"skipLibCheck": false
"noUnusedLocals": true
}
}
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"@babel/core": "^7.5.5",
"@babel/node": "^7.5.5",
"@babel/plugin-proposal-class-properties": "^7.5.5",
"@babel/plugin-proposal-object-rest-spread": "^7.4.4",
"@babel/plugin-proposal-object-rest-spread": "^7.5.5",
"@babel/plugin-transform-object-assign": "^7.2.0",
"@babel/plugin-transform-runtime": "~7.5.5",
"@babel/preset-env": "^7.5.5",
Expand Down Expand Up @@ -135,10 +135,12 @@
"resolutions": {
"**/@babel/core": "^7.5.5",
"**/@babel/plugin-proposal-class-properties": "^7.5.5",
"**/@babel/plugin-proposal-object-rest-spread": "^7.4.4",
"**/@babel/plugin-proposal-object-rest-spread": "^7.5.5",
"**/@babel/plugin-transform-runtime": "~7.5.5",
"**/@babel/preset-env": "^7.5.5",
"**/@babel/preset-react": "^7.0.0",
"**/@babel/runtime-corejs2": "^7.4.4",
"**/@babel/runtime": "^7.4.4",
"**/hoist-non-react-statics": "^3.2.1",
"**/next/terser": "^4.1.2"
},
Expand Down
61 changes: 0 additions & 61 deletions scripts/sizeSnapshot/create.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,73 +48,12 @@ async function getWebpackSizes() {
});
}

// waiting for String.prototype.matchAll in node 10
function* matchAll(string, regex) {
let match = null;
do {
match = regex.exec(string);
if (match !== null) {
yield match;
}
} while (match !== null);
}

/**
* Inverse to `pretty-bytes`
*
* @param {string} n
* @param {'B', 'kB' | 'mB' | 'gB' | 'tB' | 'pB'} unit
* @returns {number}
*/
function prettyBytesInverse(n, unit) {
const metrixPrefix = unit.length < 2 ? '' : unit[0];
const metricPrefixes = ['', 'k', 'm', 'g', 't', 'p'];
const metrixPrefixIndex = metricPrefixes.indexOf(metrixPrefix);
if (metrixPrefixIndex === -1) {
throw new TypeError(
`unrecognized metric prefix '${metrixPrefix}' in unit '${unit}'. only '${metricPrefixes.join(
"', '",
)}' are allowed`,
);
}

const power = metrixPrefixIndex * 3;
return n * 10 ** power;
}

/**
* parses output from next build to size snapshot format
* @returns {[string, { gzip: number, files: number, packages: number }][]}
*/
async function getNextPagesSize() {
const consoleOutput = await fse.readFile(path.join(__dirname, 'build/docs.next'), {
encoding: 'utf8',
});
const pageRegex = /^(?<treeViewPresentation>┌|├|└)\s*(?<fileType>σ|⚡|)\s*(?<pageUrl>[^\s]+)\s*(?<sizeFormatted>[0-9.]+)\s*(?<sizeUnit>\w+)\s*(?<files>\d+)\s*(?<packages>\d+)/gm;

return Array.from(matchAll(consoleOutput, pageRegex), match => {
const { pageUrl, sizeFormatted, sizeUnit, files, packages } = match.groups;

const snapshotId = `docs: ${pageUrl}`;
return [
snapshotId,
{
parsed: prettyBytesInverse(sizeFormatted, sizeUnit),
gzip: -1,
files: +files,
packages: +packages,
},
];
});
}

async function run() {
const rollupBundles = [path.join(workspaceRoot, 'packages/material-ui/size-snapshot.json')];

const bundleSizes = lodash.fromPairs([
...(await getWebpackSizes()),
...lodash.flatten(await Promise.all(rollupBundles.map(getRollupSize))),
...(await getNextPagesSize()),
]);

await fse.writeJSON(snapshotDestPath, bundleSizes, { spaces: 2 });
Expand Down
5 changes: 2 additions & 3 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
{
"compilerOptions": {
"module": "esnext",
"module": "commonjs",
"target": "es5",
"lib": ["es6", "dom"],
"jsx": "preserve",
"jsx": "react",
"moduleResolution": "node",
"forceConsistentCasingInFileNames": true,
"strict": true,
"noEmit": true,
"experimentalDecorators": true,
"baseUrl": "./",
"allowSyntheticDefaultImports": true,
"esModuleInterop": true,
"noErrorTruncation": true,
"allowJs": true,
"paths": {
Expand Down
Loading