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

fix: require babel dependencies directly #1575

Merged
merged 1 commit into from
Jun 14, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
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
9 changes: 6 additions & 3 deletions packages/docusaurus-1.x/lib/build-files.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,13 @@ require('@babel/register')({
only: [__dirname, `${process.cwd()}/core`],
plugins: [
require('./server/translate-plugin.js'),
'@babel/plugin-proposal-class-properties',
'@babel/plugin-proposal-object-rest-spread',
Copy link
Contributor

Choose a reason for hiding this comment

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

is the default really needed ?

Copy link

Choose a reason for hiding this comment

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

It seems to crash otherwise, something like "default is not a valid property for a plugin".

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 because the modules are coded to be used with es6 imports syntax when babel requires commonJS imports.

require('@babel/plugin-proposal-class-properties').default,
require('@babel/plugin-proposal-object-rest-spread').default,
],
presets: [
require('@babel/preset-react').default,
require('@babel/preset-env').default,
],
presets: ['@babel/react', '@babel/env'],
});

// initial check that required files are present
Expand Down
9 changes: 6 additions & 3 deletions packages/docusaurus-1.x/lib/start-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,13 @@ require('@babel/register')({
only: [__dirname, `${process.cwd()}/core`],
plugins: [
require('./server/translate-plugin.js'),
'@babel/plugin-proposal-class-properties',
'@babel/plugin-proposal-object-rest-spread',
require('@babel/plugin-proposal-class-properties').default,
require('@babel/plugin-proposal-object-rest-spread').default,
],
presets: [
require('@babel/preset-react').default,
require('@babel/preset-env').default,
],
presets: ['@babel/react', '@babel/env'],
});

const chalk = require('chalk');
Expand Down
9 changes: 6 additions & 3 deletions packages/docusaurus-1.x/lib/version.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,13 @@ require('@babel/register')({
only: [__dirname, `${process.cwd()}/core`],
plugins: [
require('./server/translate-plugin.js'),
'@babel/plugin-proposal-class-properties',
'@babel/plugin-proposal-object-rest-spread',
require('@babel/plugin-proposal-class-properties').default,
require('@babel/plugin-proposal-object-rest-spread').default,
],
presets: [
require('@babel/preset-react').default,
require('@babel/preset-env').default,
],
presets: ['@babel/react', '@babel/env'],
});

const program = require('commander');
Expand Down
9 changes: 6 additions & 3 deletions packages/docusaurus-1.x/lib/write-translations.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,13 @@ require('@babel/register')({
only: [__dirname, `${process.cwd()}/core`],
plugins: [
require('./server/translate-plugin.js'),
'@babel/plugin-proposal-class-properties',
'@babel/plugin-proposal-object-rest-spread',
require('@babel/plugin-proposal-class-properties').default,
require('@babel/plugin-proposal-object-rest-spread').default,
],
presets: [
require('@babel/preset-react').default,
require('@babel/preset-env').default,
],
presets: ['@babel/react', '@babel/env'],
});

const traverse = require('@babel/traverse').default;
Expand Down