Skip to content

Commit

Permalink
transpile lib with too recent syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
slorber committed May 14, 2021
1 parent dd8d650 commit 0410466
Showing 1 changed file with 10 additions and 1 deletion.
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

0 comments on commit 0410466

Please sign in to comment.