fix(v2): windows compatibility regression (#2086)

* Revert "perf(v2): replace unnecessary json stringify(string) with inline string (#2039)"

This reverts commit 3aa2ab6ab3.

* add comment

* Comment bois
This commit is contained in:
Endi 2019-12-05 12:43:59 +07:00 committed by GitHub
parent 4927f764e5
commit d592e3c470
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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)}),`)
.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`,
);