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

chore(v2): upgrade to Babel 7 #1012

Merged
merged 5 commits into from
Oct 8, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
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;
2 changes: 1 addition & 1 deletion v2/lib/webpack/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ module.exports = function createBaseConfig(props, isServer) {
.loader('babel-loader')
.options({
babelrc: false,
presets: ['env', 'react'],
presets: ['@babel/env', '@babel/react'],
plugins: [isServer ? 'dynamic-import-node' : 'syntax-dynamic-import'],
Copy link
Contributor

@endiliey endiliey Oct 2, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Haven't really tried this out but i think the dynamic import node babel plugin is not compatible with babel 7.

See airbnb/babel-plugin-dynamic-import-node#64

Happening in CRA as well

facebook/create-react-app#4984

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fiennyangeln Can you verify this? What do we do about this then?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yangshun yes, the PR for babel 7 upgrade for that plugin is still open. How about using https://www.npmjs.com/package/babel-plugin-transform-dynamic-import instead?

});
}
Expand Down
13 changes: 8 additions & 5 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/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-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",
"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';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will it fails without this ? O.O

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes!

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