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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 0 additions & 55 deletions
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

Lines changed: 58 additions & 0 deletions
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 renamed to docs/next.config.js

Lines changed: 11 additions & 1 deletion
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
});

0 commit comments

Comments
 (0)