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): windows compatibility regression #2086

Merged
merged 3 commits into from
Dec 5, 2019
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
8 changes: 6 additions & 2 deletions packages/docusaurus/src/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,8 @@ export async function load(siteDir: string): Promise<Props> {
`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)}),`)
endiliey marked this conversation as resolved.
Show resolved Hide resolved
.join('\n')}\n];\n`,
);

Expand All @@ -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`,
);
Expand Down