From d592e3c47070bb19e771a045b39d49dae3554dd4 Mon Sep 17 00:00:00 2001 From: Endi Date: Thu, 5 Dec 2019 12:43:59 +0700 Subject: [PATCH] fix(v2): windows compatibility regression (#2086) * Revert "perf(v2): replace unnecessary json stringify(string) with inline string (#2039)" This reverts commit 3aa2ab6ab3e4b2fb9e19f1b6603333a321a5bf7d. * add comment * Comment bois --- packages/docusaurus/src/server/index.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/docusaurus/src/server/index.ts b/packages/docusaurus/src/server/index.ts index 0afbea7315..62a1ee2e04 100644 --- a/packages/docusaurus/src/server/index.ts +++ b/packages/docusaurus/src/server/index.ts @@ -129,7 +129,8 @@ export async function load(siteDir: string): Promise { `export default [\n${clientModules // import() is async so we use require() because client modules can have // CSS and the order matters for loading CSS. - .map(module => ` require("${module}"),`) + // We need to JSON.stringify so that if its on windows, backslash are escaped. + .map(module => ` require(${JSON.stringify(module)}),`) .join('\n')}\n];\n`, ); @@ -152,7 +153,10 @@ ${Object.keys(registry) .sort() .map( key => - ` '${key}': [${registry[key].loader}, "${registry[key].modulePath}", require.resolveWeak("${registry[key].modulePath}")],`, + // We need to JSON.stringify so that if its on windows, backslash are escaped. + ` '${key}': [${registry[key].loader}, ${JSON.stringify( + registry[key].modulePath, + )}, require.resolveWeak(${JSON.stringify(registry[key].modulePath)})],`, ) .join('\n')}};\n`, );