diff --git a/.changeset/pink-turtles-switch.md b/.changeset/pink-turtles-switch.md new file mode 100644 index 00000000..9ad4e30e --- /dev/null +++ b/.changeset/pink-turtles-switch.md @@ -0,0 +1,5 @@ +--- +'wmr': patch +--- + +First script tag in HTML should be assumed to have prerender(), not last diff --git a/packages/wmr/src/lib/prerender.js b/packages/wmr/src/lib/prerender.js index 5d5699aa..8f78f6d9 100644 --- a/packages/wmr/src/lib/prerender.js +++ b/packages/wmr/src/lib/prerender.js @@ -70,7 +70,7 @@ async function workerCode({ cwd, out, publicPath, customRoutes }) { // Grab the generated HTML file, which we'll use as a template: const tpl = await fs.readFile(path.resolve(cwd, out, 'index.html'), 'utf-8'); - // The first script in the file that is not external is assumed to have a + // The last script in the file that is not external is assumed to have a // `prerender` export let script; const SCRIPT_TAG = /]*?)?\s+src=(['"]?)([^>]*?)\1(?:\s[^>]*?)?>/g; @@ -103,7 +103,7 @@ async function workerCode({ cwd, out, publicPath, customRoutes }) { // const App = m.default || m[Object.keys(m)[0]]; if (typeof doPrerender !== 'function') { - throw Error(`No prerender() function was exported by the first