mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-04 04:37:28 +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$/;
|
const CSS_MODULE_REGEX = /\.module\.css$/;
|
||||||
export const clientDir = path.join(__dirname, '..', 'client');
|
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 {
|
export function excludeJS(modulePath: string): boolean {
|
||||||
// always transpile client dir
|
// always transpile client dir
|
||||||
if (modulePath.startsWith(clientDir)) {
|
if (modulePath.startsWith(clientDir)) {
|
||||||
|
@ -32,7 +40,8 @@ export function excludeJS(modulePath: string): boolean {
|
||||||
// Don't transpile node_modules except any docusaurus npm package
|
// Don't transpile node_modules except any docusaurus npm package
|
||||||
return (
|
return (
|
||||||
/node_modules/.test(modulePath) &&
|
/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