mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-03 12:17:20 +02:00
fix(v2): transpile libs with too recent syntax with babel (#4789)
This commit is contained in:
parent
dd8d650900
commit
c8812cf3b5
1 changed files with 10 additions and 1 deletions
|
@ -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)) {
|
||||
|
@ -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)
|
||||
);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue