Skip to content

Commit

Permalink
chore(v2): upgrade to Babel 7 (#1012)
Browse files Browse the repository at this point in the history
* Upgrade babel in v2 folder

* Use babel-plugin-transform-dynamic-import instead of babel-plugin-dynamic-import-node

* Remove not needed import polyfill by changing the order of import

* Revert "Remove not needed import polyfill by changing the order of import"

This reverts commit 9263aa6.

* Fix prettier
  • Loading branch information
fiennyangeln authored and endiliey committed Oct 8, 2018
1 parent 2e96569 commit d052fee
Show file tree
Hide file tree
Showing 12 changed files with 727 additions and 472 deletions.
3 changes: 0 additions & 3 deletions v2/.babelrc

This file was deleted.

3 changes: 3 additions & 0 deletions v2/babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
presets: ['@babel/env', '@babel/react'],
};
3 changes: 3 additions & 0 deletions v2/jest.transform.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const babelConfig = require('./babel.config');

module.exports = require('babel-jest').createTransformer(babelConfig);
4 changes: 1 addition & 3 deletions v2/lib/theme/Markdown/anchors.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import toSlug from './toSlug';

function anchors(md) {
export default function anchors(md) {
const originalRender = md.renderer.rules.heading_open;

// eslint-disable-next-line
Expand All @@ -18,5 +18,3 @@ function anchors(md) {
return originalRender(tokens, idx, options, env);
};
}

module.exports = anchors;
8 changes: 6 additions & 2 deletions v2/lib/webpack/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,12 @@ module.exports = function createBaseConfig(props, isServer) {
.loader('babel-loader')
.options({
babelrc: false,
presets: ['env', 'react'],
plugins: [isServer ? 'dynamic-import-node' : 'syntax-dynamic-import'],
presets: ['@babel/env', '@babel/react'],
plugins: [
isServer
? 'babel-plugin-transform-dynamic-import'
: '@babel/syntax-dynamic-import',
],
});
}

Expand Down
15 changes: 9 additions & 6 deletions v2/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"url": "https://github.com/facebook/Docusaurus/issues"
},
"devDependencies": {
"babel-core": "^7.0.0-bridge.0",
"eslint": "^4.19.1",
"eslint-config-airbnb": "17.0.0",
"eslint-config-prettier": "^2.9.0",
Expand All @@ -42,12 +43,14 @@
"prettier": "^1.13.7"
},
"dependencies": {
"babel-core": "^6.26.3",
"babel-loader": "^7.1.5",
"babel-plugin-dynamic-import-node": "^2.0.0",
"babel-plugin-syntax-dynamic-import": "^6.18.0",
"babel-preset-env": "^1.7.0",
"babel-preset-react": "^6.24.1",
"@babel/core": "^7.0.0",
"@babel/plugin-syntax-dynamic-import": "^7.0.0",
"@babel/polyfill": "^7.0.0",
"@babel/preset-env": "^7.0.0",
"@babel/preset-react": "^7.0.0",
"babel-jest": "^23.6.0",
"babel-loader": "^8.0.0",
"babel-plugin-transform-dynamic-import": "^2.1.0",
"chalk": "^2.4.1",
"chokidar": "^2.0.4",
"classnames": "^2.2.6",
Expand Down
5 changes: 4 additions & 1 deletion v2/test/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,8 @@ module.exports = {
moduleNameMapper: {
'^@lib/(.*)$': '<rootDir>/lib/$1',
},
testPathIgnorePatterns: ['/node_modules/', '__fixtures__'],
testPathIgnorePatterns: ['/node_modules/', '__fixtures__', 'v1'],
transform: {
'^.+\\.js$': '<rootDir>/jest.transform.js',
},
};
1 change: 1 addition & 0 deletions v2/test/load/docs/index.test.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import '@babel/polyfill';
import path from 'path';
import loadDocs from '@lib/load/docs';
import loadSetup from '../../loadSetup';
Expand Down
1 change: 1 addition & 0 deletions v2/test/load/docs/metadata.test.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import '@babel/polyfill';
import path from 'path';
import processMetadata from '@lib/load/docs/metadata';
import loadSetup from '../../loadSetup';
Expand Down
1 change: 1 addition & 0 deletions v2/test/loadSetup.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import '@babel/polyfill';
import path from 'path';
import load from '@lib/load';

Expand Down
1 change: 1 addition & 0 deletions v2/test/webpack/utils.test.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import '@babel/polyfill';
import {validate} from 'webpack';
import path from 'path';
import Config from 'webpack-chain';
Expand Down
Loading

0 comments on commit d052fee

Please sign in to comment.