Skip to content

Commit b6182ce

Browse files
authored
[docs] Move dependencies/scripts from root into workspace (mui#16640)
* [docs] Move docs scripts into workspace * Fix size:snapshot * Remove unused classnames dependency * netlify -> cdn * Keep root docs:typescript* scripts * Fix hmr for docs:dev
1 parent b3218e7 commit b6182ce

File tree

608 files changed

+294
-279
lines changed

Some content is hidden

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

608 files changed

+294
-279
lines changed

.circleci/config.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ jobs:
109109
- install_js
110110
- run:
111111
name: Transpile TypeScript demos
112-
command: yarn docs:typescript:formatted --disable-cache
112+
command: yarn workspace docs typescript:transpile --disable-cache
113113
- run:
114114
name: Are the compiled TypeScript demos equivalent to the JavaScript demos?
115115
command: git add -A && git diff --exit-code --staged

.eslintignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/.git
2-
/.next
2+
/docs/.next
33
/coverage
44
/docs/export
55
/examples/create-react-app*/src/serviceWorker.js

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*.log
88
.DS_STORE
99
/.eslintcache
10-
/.next
10+
/docs/.next
1111
/.nyc_output
1212
/coverage
1313
/docs/export

babel.config.js

-55
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,3 @@
1-
const bpmr = require('babel-plugin-module-resolver');
2-
3-
function resolvePath(sourcePath, currentFile, opts) {
4-
if (sourcePath === 'markdown') {
5-
const base = currentFile.substring(__dirname.length).slice(0, -3);
6-
return `${__dirname}/docs/src/${base}/`;
7-
}
8-
9-
return bpmr.resolvePath(sourcePath, currentFile, opts);
10-
}
11-
121
let defaultPresets;
132

143
// We release a ES version of Material-UI.
@@ -88,50 +77,6 @@ module.exports = {
8877
],
8978
],
9079
},
91-
'docs-development': {
92-
presets: ['next/babel', '@zeit/next-typescript/babel'],
93-
plugins: [
94-
'babel-plugin-preval',
95-
[
96-
'babel-plugin-module-resolver',
97-
{
98-
alias: {
99-
...defaultAlias,
100-
'@material-ui/docs': './packages/material-ui-docs/src',
101-
docs: './docs',
102-
modules: './modules',
103-
pages: './pages',
104-
},
105-
transformFunctions: ['require', 'require.context'],
106-
resolvePath,
107-
},
108-
],
109-
],
110-
},
111-
'docs-production': {
112-
presets: ['next/babel', '@zeit/next-typescript/babel'],
113-
plugins: [
114-
'babel-plugin-preval',
115-
[
116-
'babel-plugin-module-resolver',
117-
{
118-
alias: {
119-
...defaultAlias,
120-
'@material-ui/docs': './packages/material-ui-docs/src',
121-
docs: './docs',
122-
modules: './modules',
123-
pages: './pages',
124-
},
125-
transformFunctions: ['require', 'require.context'],
126-
resolvePath,
127-
},
128-
],
129-
'babel-plugin-transform-react-constant-elements',
130-
'babel-plugin-transform-dev-warning',
131-
['babel-plugin-react-remove-properties', { properties: ['data-mui-test'] }],
132-
['babel-plugin-transform-react-remove-prop-types', { mode: 'remove' }],
133-
],
134-
},
13580
esm: {
13681
plugins: productionPlugins,
13782
},

docs/babel.config.js

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
const bpmr = require('babel-plugin-module-resolver');
2+
3+
function resolvePath(sourcePath, currentFile, opts) {
4+
if (sourcePath === 'markdown') {
5+
const base = currentFile.substring(__dirname.length).slice(0, -3);
6+
return `${__dirname}/docs/src/${base}/`;
7+
}
8+
9+
return bpmr.resolvePath(sourcePath, currentFile, opts);
10+
}
11+
12+
const alias = {
13+
'@material-ui/core': '../packages/material-ui/src',
14+
'@material-ui/docs': '../packages/material-ui-docs/src',
15+
'@material-ui/icons': '../packages/material-ui-icons/src',
16+
'@material-ui/lab': '../packages/material-ui-lab/src',
17+
'@material-ui/styles': '../packages/material-ui-styles/src',
18+
'@material-ui/system': '../packages/material-ui-system/src',
19+
'@material-ui/utils': '../packages/material-ui-utils/src',
20+
docs: './',
21+
modules: '../modules',
22+
pages: './pages',
23+
};
24+
25+
module.exports = {
26+
presets: [
27+
// TODO figure out how to make it work with dependencies that have this repo as a
28+
// peer,
29+
// false causes 'Attempted import error: 'KeyboardTimePicker' is not exported from '@material-ui/pickers'.'
30+
['next/babel', { 'preset-env': { modules: 'commonjs' } }],
31+
'@zeit/next-typescript/babel',
32+
],
33+
plugins: [
34+
'babel-plugin-optimize-clsx',
35+
// for IE 11 support
36+
'@babel/plugin-transform-object-assign',
37+
'babel-plugin-preval',
38+
[
39+
'babel-plugin-module-resolver',
40+
{
41+
alias,
42+
transformFunctions: ['require', 'require.context'],
43+
resolvePath,
44+
},
45+
],
46+
],
47+
ignore: [/@babel[\\|/]runtime/], // Fix a Windows issue.
48+
env: {
49+
production: {
50+
plugins: [
51+
'babel-plugin-transform-react-constant-elements',
52+
'babel-plugin-transform-dev-warning',
53+
['babel-plugin-react-remove-properties', { properties: ['data-mui-test'] }],
54+
['babel-plugin-transform-react-remove-prop-types', { mode: 'remove' }],
55+
],
56+
},
57+
},
58+
};
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

next.config.js docs/next.config.js

+11-1
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,14 @@ const webpack = require('webpack');
22
const pkg = require('./package.json');
33
const withTM = require('next-transpile-modules');
44
const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');
5-
const { findPages } = require('./docs/src/modules/utils/find');
5+
const { findPages } = require('./src/modules/utils/find');
66
const withTypescript = require('@zeit/next-typescript');
7+
const path = require('path');
78

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

11+
const workspaceRoot = path.join(__dirname, '../');
12+
1013
module.exports = withTypescript({
1114
webpack: (config, options) => {
1215
// Alias @material-ui/core peer dependency imports form the following modules to our sources.
@@ -55,6 +58,13 @@ module.exports = withTypescript({
5558
test: /\.(css|md)$/,
5659
loader: 'raw-loader',
5760
},
61+
// required to transpile ../packages/
62+
{
63+
test: /\.(js|mjs|jsx)$/,
64+
include: [workspaceRoot],
65+
exclude: /node_modules/,
66+
use: options.defaultLoaders.babel,
67+
},
5868
]),
5969
}),
6070
});

docs/package.json

+92-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,97 @@
55
"author": "Material-UI Team",
66
"license": "MIT",
77
"scripts": {
8-
"typescript": "tslint -p tsconfig.json \"src/pages/**/*.{ts,tsx}\""
8+
"build": "rimraf .next && cross-env NODE_ENV=production next build",
9+
"build-sw": "node ./scripts/buildServiceWorker.js",
10+
"dev": "rimraf ../node_modules/.cache/babel-loader && cross-env NODE_ENV=development node src/server.js",
11+
"deploy": "git push material-ui-docs master:latest",
12+
"export": "rimraf docs/export && next export -o export && yarn build-sw && cp -r cdn/. export",
13+
"icons": "rimraf static/icons/* && node ./scripts/buildIcons.js",
14+
"start": "next start",
15+
"typescript": "tslint -p tsconfig.json \"src/pages/**/*.{ts,tsx}\"",
16+
"typescript:transpile": "node scripts/formattedTSDemos",
17+
"typescript:transpile:dev": "node scripts/formattedTSDemos --watch"
18+
},
19+
"dependencies": {
20+
"@date-io/date-fns": "^1.0.0",
21+
"@emotion/core": "^10.0.0",
22+
"@emotion/styled": "^10.0.0",
23+
"@material-ui/core": "^4.1.2",
24+
"@material-ui/docs": "^4.0.0-beta.0",
25+
"@material-ui/icons": "^4.2.1",
26+
"@material-ui/lab": "^4.0.0-alpha.18",
27+
"@material-ui/pickers": "^3.1.1",
28+
"@material-ui/styles": "^4.1.2",
29+
"@material-ui/system": "^4.3.0",
30+
"@trendmicro/react-interpolate": "^0.5.5",
31+
"@types/autosuggest-highlight": "^3.1.0",
32+
"@types/react-autosuggest": "^9.3.7",
33+
"@types/react-dom": "^16.0.9",
34+
"@types/react-router-dom": "^4.3.1",
35+
"@types/react-select": "^2.0.14",
36+
"@types/react-swipeable-views": "^0.13.0",
37+
"@types/react-text-mask": "^5.4.2",
38+
"@types/react-virtualized": "^9.21.1",
39+
"@types/react-window": "^1.7.0",
40+
"@types/styled-components": "4.1.12",
41+
"@zeit/next-typescript": "^1.1.1",
42+
"address": "^1.0.3",
43+
"ast-types": "^0.12.4",
44+
"autoprefixer": "^9.0.0",
45+
"autosuggest-highlight": "^3.1.1",
46+
"clean-css": "^4.1.11",
47+
"clipboard-copy": "^3.0.0",
48+
"css-loader": "^2.0.0",
49+
"css-mediaquery": "^0.1.2",
50+
"date-fns": "^2.0.0-alpha.21",
51+
"doctrine": "^3.0.0",
52+
"downshift": "^3.0.0",
53+
"emotion-theming": "^10.0.5",
54+
"fg-loadcss": "^2.0.1",
55+
"final-form": "^4.11.0",
56+
"isomorphic-fetch": "^2.2.1",
57+
"json2mq": "^0.2.0",
58+
"jss-plugin-template": "10.0.0-alpha.17",
59+
"jss-rtl": "^0.2.1",
60+
"lodash": "^4.17.14",
61+
"lz-string": "^1.4.4",
62+
"markdown-to-jsx": "^6.8.3",
63+
"material-table": "^1.39.0",
64+
"material-ui-popup-state": "^1.0.1",
65+
"next": "8.1.0",
66+
"next-transpile-modules": "^2.3.1",
67+
"notistack": "^0.8.6",
68+
"postcss": "^7.0.0",
69+
"raw-loader": "^1.0.0",
70+
"react-autosuggest": "^9.3.2",
71+
"react-docgen": "^5.0.0-beta",
72+
"react-dom": "^16.8.5",
73+
"react-draggable": "^3.0.5",
74+
"react-final-form": "^4.0.2",
75+
"react-frame-component": "^4.0.2",
76+
"react-inspector": "^2.2.2",
77+
"react-number-format": "^4.0.0",
78+
"react-redux": "^7.0.3",
79+
"react-router": "^5.0.0",
80+
"react-router-dom": "^5.0.0",
81+
"react-select": "^2.0.0",
82+
"react-swipeable-views": "^0.13.0",
83+
"react-test-renderer": "^16.8.5",
84+
"react-text-mask": "^5.0.2",
85+
"react-virtualized": "^9.21.0",
86+
"react-window": "^1.7.1",
87+
"recast": "^0.17.0",
88+
"recharts": "^1.1.0",
89+
"redux": "^4.0.0",
90+
"redux-logger": "^3.0.6",
91+
"styled-components": "^4.1.1",
92+
"typescript-to-proptypes": "^1.1.0",
93+
"url-loader": "^1.0.1",
94+
"webfontloader": "^1.6.28"
95+
},
96+
"devDependencies": {
97+
"@babel/preset-typescript": "^7.1.0",
98+
"babel-plugin-unwrap-createstyles": "^4.1.0",
99+
"gm": "^1.23.0"
9100
}
10101
}

pages/_app.js docs/pages/_app.js

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

pages/components/about-the-lab.js docs/pages/components/about-the-lab.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import MarkdownDocs from 'docs/src/modules/components/MarkdownDocs';
55

66
const req = require.context('docs/src/pages/components/about-the-lab', false, /\.(md|js|tsx)$/);
77
const reqSource = require.context(
8-
'!raw-loader!../../docs/src/pages/components/about-the-lab',
8+
'!raw-loader!../../src/pages/components/about-the-lab',
99
false,
1010
/\.(js|tsx)$/,
1111
);

pages/components/app-bar.js docs/pages/components/app-bar.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import MarkdownDocs from 'docs/src/modules/components/MarkdownDocs';
55

66
const req = require.context('docs/src/pages/components/app-bar', false, /\.(md|js|tsx)$/);
77
const reqSource = require.context(
8-
'!raw-loader!../../docs/src/pages/components/app-bar',
8+
'!raw-loader!../../src/pages/components/app-bar',
99
false,
1010
/\.(js|tsx)$/,
1111
);

pages/components/autocomplete.js docs/pages/components/autocomplete.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import MarkdownDocs from 'docs/src/modules/components/MarkdownDocs';
55

66
const req = require.context('docs/src/pages/components/autocomplete', false, /\.(md|js|tsx)$/);
77
const reqSource = require.context(
8-
'!raw-loader!../../docs/src/pages/components/autocomplete',
8+
'!raw-loader!../../src/pages/components/autocomplete',
99
false,
1010
/\.(js|tsx)$/,
1111
);

pages/components/avatars.js docs/pages/components/avatars.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import MarkdownDocs from 'docs/src/modules/components/MarkdownDocs';
55

66
const req = require.context('docs/src/pages/components/avatars', false, /\.(md|js|tsx)$/);
77
const reqSource = require.context(
8-
'!raw-loader!../../docs/src/pages/components/avatars',
8+
'!raw-loader!../../src/pages/components/avatars',
99
false,
1010
/\.(js|tsx)$/,
1111
);

pages/components/badges.js docs/pages/components/badges.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import MarkdownDocs from 'docs/src/modules/components/MarkdownDocs';
55

66
const req = require.context('docs/src/pages/components/badges', false, /\.(md|js|tsx)$/);
77
const reqSource = require.context(
8-
'!raw-loader!../../docs/src/pages/components/badges',
8+
'!raw-loader!../../src/pages/components/badges',
99
false,
1010
/\.(js|tsx)$/,
1111
);

pages/components/bottom-navigation.js docs/pages/components/bottom-navigation.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import MarkdownDocs from 'docs/src/modules/components/MarkdownDocs';
55

66
const req = require.context('docs/src/pages/components/bottom-navigation', false, /\.(md|js|tsx)$/);
77
const reqSource = require.context(
8-
'!raw-loader!../../docs/src/pages/components/bottom-navigation',
8+
'!raw-loader!../../src/pages/components/bottom-navigation',
99
false,
1010
/\.(js|tsx)$/,
1111
);

pages/components/box.js docs/pages/components/box.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import MarkdownDocs from 'docs/src/modules/components/MarkdownDocs';
55

66
const req = require.context('docs/src/pages/components/box', false, /\.(md|js|tsx)$/);
77
const reqSource = require.context(
8-
'!raw-loader!../../docs/src/pages/components/box',
8+
'!raw-loader!../../src/pages/components/box',
99
false,
1010
/\.(js|tsx)$/,
1111
);

pages/components/breadcrumbs.js docs/pages/components/breadcrumbs.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import MarkdownDocs from 'docs/src/modules/components/MarkdownDocs';
55

66
const req = require.context('docs/src/pages/components/breadcrumbs', false, /\.(md|js|tsx)$/);
77
const reqSource = require.context(
8-
'!raw-loader!../../docs/src/pages/components/breadcrumbs',
8+
'!raw-loader!../../src/pages/components/breadcrumbs',
99
false,
1010
/\.(js|tsx)$/,
1111
);

pages/components/buttons.js docs/pages/components/buttons.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import MarkdownDocs from 'docs/src/modules/components/MarkdownDocs';
55

66
const req = require.context('docs/src/pages/components/buttons', false, /\.(md|js|tsx)$/);
77
const reqSource = require.context(
8-
'!raw-loader!../../docs/src/pages/components/buttons',
8+
'!raw-loader!../../src/pages/components/buttons',
99
false,
1010
/\.(js|tsx)$/,
1111
);

pages/components/cards.js docs/pages/components/cards.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import MarkdownDocs from 'docs/src/modules/components/MarkdownDocs';
55

66
const req = require.context('docs/src/pages/components/cards', false, /\.(md|js|tsx)$/);
77
const reqSource = require.context(
8-
'!raw-loader!../../docs/src/pages/components/cards',
8+
'!raw-loader!../../src/pages/components/cards',
99
false,
1010
/\.(js|tsx)$/,
1111
);

pages/components/checkboxes.js docs/pages/components/checkboxes.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import MarkdownDocs from 'docs/src/modules/components/MarkdownDocs';
55

66
const req = require.context('docs/src/pages/components/checkboxes', false, /\.(md|js|tsx)$/);
77
const reqSource = require.context(
8-
'!raw-loader!../../docs/src/pages/components/checkboxes',
8+
'!raw-loader!../../src/pages/components/checkboxes',
99
false,
1010
/\.(js|tsx)$/,
1111
);

pages/components/chips.js docs/pages/components/chips.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import MarkdownDocs from 'docs/src/modules/components/MarkdownDocs';
55

66
const req = require.context('docs/src/pages/components/chips', false, /\.(md|js|tsx)$/);
77
const reqSource = require.context(
8-
'!raw-loader!../../docs/src/pages/components/chips',
8+
'!raw-loader!../../src/pages/components/chips',
99
false,
1010
/\.(js|tsx)$/,
1111
);

pages/components/click-away-listener.js docs/pages/components/click-away-listener.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const req = require.context(
99
/\.(md|js|tsx)$/,
1010
);
1111
const reqSource = require.context(
12-
'!raw-loader!../../docs/src/pages/components/click-away-listener',
12+
'!raw-loader!../../src/pages/components/click-away-listener',
1313
false,
1414
/\.(js|tsx)$/,
1515
);

0 commit comments

Comments
 (0)