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(v2): transpile libs with too recent syntax with babel #4789

Merged
merged 1 commit into from
May 14, 2021
Merged
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
11 changes: 10 additions & 1 deletion packages/docusaurus/src/webpack/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,14 @@ const CSS_REGEX = /\.css$/;
const CSS_MODULE_REGEX = /\.module\.css$/;
export const clientDir = path.join(__dirname, '..', 'client');

const LibrariesToTranspile = [
'copy-text-to-clipboard', // contains optional catch binding, incompatible with recent versions of Edge
];

const LibrariesToTranspileRegex = new RegExp(
LibrariesToTranspile.map((libName) => `(node_modules/${libName})`).join('|'),
);

export function excludeJS(modulePath: string): boolean {
// always transpile client dir
if (modulePath.startsWith(clientDir)) {
Expand All @@ -32,7 +40,8 @@ export function excludeJS(modulePath: string): boolean {
// Don't transpile node_modules except any docusaurus npm package
return (
/node_modules/.test(modulePath) &&
!/(docusaurus)((?!node_modules).)*\.jsx?$/.test(modulePath)
!/(docusaurus)((?!node_modules).)*\.jsx?$/.test(modulePath) &&
!LibrariesToTranspileRegex.test(modulePath)
);
}

Expand Down