chore(v2): upgrade to Babel 7 (#1012)

* 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 9263aa693a.

* Fix prettier
This commit is contained in:
Fienny Angelina 2018-10-08 14:42:31 +08:00 committed by Endilie Yacop Sucipto
parent 2e9656917c
commit d052feec40
12 changed files with 727 additions and 472 deletions

View file

@ -1,3 +0,0 @@
{
"presets": ["env", "react"]
}

3
v2/babel.config.js Normal file
View file

@ -0,0 +1,3 @@
module.exports = {
presets: ['@babel/env', '@babel/react'],
};

3
v2/jest.transform.js Normal file
View file

@ -0,0 +1,3 @@
const babelConfig = require('./babel.config');
module.exports = require('babel-jest').createTransformer(babelConfig);

View file

@ -1,6 +1,6 @@
import toSlug from './toSlug'; import toSlug from './toSlug';
function anchors(md) { export default function anchors(md) {
const originalRender = md.renderer.rules.heading_open; const originalRender = md.renderer.rules.heading_open;
// eslint-disable-next-line // eslint-disable-next-line
@ -18,5 +18,3 @@ function anchors(md) {
return originalRender(tokens, idx, options, env); return originalRender(tokens, idx, options, env);
}; };
} }
module.exports = anchors;

View file

@ -51,8 +51,12 @@ module.exports = function createBaseConfig(props, isServer) {
.loader('babel-loader') .loader('babel-loader')
.options({ .options({
babelrc: false, babelrc: false,
presets: ['env', 'react'], presets: ['@babel/env', '@babel/react'],
plugins: [isServer ? 'dynamic-import-node' : 'syntax-dynamic-import'], plugins: [
isServer
? 'babel-plugin-transform-dynamic-import'
: '@babel/syntax-dynamic-import',
],
}); });
} }

View file

@ -32,6 +32,7 @@
"url": "https://github.com/facebook/Docusaurus/issues" "url": "https://github.com/facebook/Docusaurus/issues"
}, },
"devDependencies": { "devDependencies": {
"babel-core": "^7.0.0-bridge.0",
"eslint": "^4.19.1", "eslint": "^4.19.1",
"eslint-config-airbnb": "17.0.0", "eslint-config-airbnb": "17.0.0",
"eslint-config-prettier": "^2.9.0", "eslint-config-prettier": "^2.9.0",
@ -42,12 +43,14 @@
"prettier": "^1.13.7" "prettier": "^1.13.7"
}, },
"dependencies": { "dependencies": {
"babel-core": "^6.26.3", "@babel/core": "^7.0.0",
"babel-loader": "^7.1.5", "@babel/plugin-syntax-dynamic-import": "^7.0.0",
"babel-plugin-dynamic-import-node": "^2.0.0", "@babel/polyfill": "^7.0.0",
"babel-plugin-syntax-dynamic-import": "^6.18.0", "@babel/preset-env": "^7.0.0",
"babel-preset-env": "^1.7.0", "@babel/preset-react": "^7.0.0",
"babel-preset-react": "^6.24.1", "babel-jest": "^23.6.0",
"babel-loader": "^8.0.0",
"babel-plugin-transform-dynamic-import": "^2.1.0",
"chalk": "^2.4.1", "chalk": "^2.4.1",
"chokidar": "^2.0.4", "chokidar": "^2.0.4",
"classnames": "^2.2.6", "classnames": "^2.2.6",

View file

@ -8,5 +8,8 @@ module.exports = {
moduleNameMapper: { moduleNameMapper: {
'^@lib/(.*)$': '<rootDir>/lib/$1', '^@lib/(.*)$': '<rootDir>/lib/$1',
}, },
testPathIgnorePatterns: ['/node_modules/', '__fixtures__'], testPathIgnorePatterns: ['/node_modules/', '__fixtures__', 'v1'],
transform: {
'^.+\\.js$': '<rootDir>/jest.transform.js',
},
}; };

View file

@ -1,3 +1,4 @@
import '@babel/polyfill';
import path from 'path'; import path from 'path';
import loadDocs from '@lib/load/docs'; import loadDocs from '@lib/load/docs';
import loadSetup from '../../loadSetup'; import loadSetup from '../../loadSetup';

View file

@ -1,3 +1,4 @@
import '@babel/polyfill';
import path from 'path'; import path from 'path';
import processMetadata from '@lib/load/docs/metadata'; import processMetadata from '@lib/load/docs/metadata';
import loadSetup from '../../loadSetup'; import loadSetup from '../../loadSetup';

View file

@ -1,3 +1,4 @@
import '@babel/polyfill';
import path from 'path'; import path from 'path';
import load from '@lib/load'; import load from '@lib/load';

View file

@ -1,3 +1,4 @@
import '@babel/polyfill';
import {validate} from 'webpack'; import {validate} from 'webpack';
import path from 'path'; import path from 'path';
import Config from 'webpack-chain'; import Config from 'webpack-chain';

File diff suppressed because it is too large Load diff