diff --git a/src/plugins/prerender-plugin.js b/src/plugins/prerender-plugin.js index 1359789..fded605 100644 --- a/src/plugins/prerender-plugin.js +++ b/src/plugins/prerender-plugin.js @@ -126,7 +126,7 @@ export function prerenderPlugin({ prerenderScript, renderTarget, additionalPrere config.build.rollupOptions.output ??= {}; config.build.rollupOptions.output.manualChunks = (id) => { if (id.includes(prerenderScript) || id.includes(preloadPolyfillId)) { - return "index"; + return 'index'; } }; @@ -240,10 +240,7 @@ export function prerenderPlugin({ prerenderScript, renderTarget, additionalPrere // Create a tmp dir to allow importing & consuming the built modules, // before Rollup writes them to the disk - const tmpDir = path.join( - viteConfig.root, - tmpDirRelative, - ); + const tmpDir = path.join(viteConfig.root, tmpDirRelative); try { await fs.rm(tmpDir, { recursive: true }); } catch (e) { @@ -300,7 +297,9 @@ export function prerenderPlugin({ prerenderScript, renderTarget, additionalPrere } `.replace(/^\t{5}/gm, ''); - const stack = StackTraceParse(e).find((s) => s.getFileName().includes(tmpDirRelative)); + const stack = StackTraceParse(e).find((s) => + s.getFileName().includes(tmpDirRelative), + ); const sourceMapContent = prerenderEntry.map; if (stack && sourceMapContent) { diff --git a/tests/fixtures/features/local-fetch/src/index.js b/tests/fixtures/features/local-fetch/src/index.js index ad16e4c..122a2f8 100644 --- a/tests/fixtures/features/local-fetch/src/index.js +++ b/tests/fixtures/features/local-fetch/src/index.js @@ -1,4 +1,4 @@ export async function prerender() { - const res = await fetch('/local-fetch-test.txt') + const res = await fetch('/local-fetch-test.txt'); return await res.text(); } diff --git a/tests/fixtures/source-maps/src/index.js b/tests/fixtures/source-maps/src/index.js index e40675e..7362910 100644 --- a/tests/fixtures/source-maps/src/index.js +++ b/tests/fixtures/source-maps/src/index.js @@ -1,7 +1,7 @@ -if (typeof window !== "undefined") { - const worker = new Worker(new URL("./worker.js", import.meta.url)); +if (typeof window !== 'undefined') { + const worker = new Worker(new URL('./worker.js', import.meta.url)); - worker.postMessage({ type: "init" }); + worker.postMessage({ type: 'init' }); } export async function prerender() { diff --git a/tests/fixtures/source-maps/src/worker.js b/tests/fixtures/source-maps/src/worker.js index 384aa0d..20cc227 100644 --- a/tests/fixtures/source-maps/src/worker.js +++ b/tests/fixtures/source-maps/src/worker.js @@ -1,3 +1,3 @@ addEventListener('message', (e) => { postMessage({ type: 'init' }); -}) +}); diff --git a/tests/prerender-api.test.js b/tests/prerender-api.test.js index 6132d31..bf6bf13 100644 --- a/tests/prerender-api.test.js +++ b/tests/prerender-api.test.js @@ -56,7 +56,10 @@ test('Should stringify returned `data` object', async () => { await viteBuild(env.tmp.path); const prerenderedHtml = await getOutputFile(env.tmp.path, 'index.html'); - assert.match(prerenderedHtml, ''); + assert.match( + prerenderedHtml, + '', + ); }); test('Should support `head.lang` property', async () => { diff --git a/tests/source-maps.test.js b/tests/source-maps.test.js index 78bfdd9..550d57e 100644 --- a/tests/source-maps.test.js +++ b/tests/source-maps.test.js @@ -26,14 +26,19 @@ test('Should strip sourcemaps by default', async () => { assert.not.ok(outDirAssets.find((f) => f.endsWith('.map'))); - - const outputChunk = path.join(outDir, outDirAssets.find((f) => /^index-.*\.js$/.test(f))); + const outputChunk = path.join( + outDir, + outDirAssets.find((f) => /^index-.*\.js$/.test(f)), + ); const outputChunkCode = await fs.readFile(outputChunk, 'utf-8'); - assert.is(outputChunkCode.match(/\/\/#\ssourceMappingURL=(.*)/), null) + assert.is(outputChunkCode.match(/\/\/#\ssourceMappingURL=(.*)/), null); - const outputAsset = path.join(outDir, outDirAssets.find((f) => /^worker-.*\.js$/.test(f))); + const outputAsset = path.join( + outDir, + outDirAssets.find((f) => /^worker-.*\.js$/.test(f)), + ); const outputAssetSource = await fs.readFile(outputAsset, 'utf-8'); - assert.is(outputAssetSource.match(/\/\/#\ssourceMappingURL=(.*)/), null) + assert.is(outputAssetSource.match(/\/\/#\ssourceMappingURL=(.*)/), null); }); test('Should preserve sourcemaps if user has enabled them', async () => { @@ -68,7 +73,7 @@ test('Should use sourcemaps to display error positioning when possible', async ( document.createElement('div'); export async function prerender() { return '

Simple Test Result

'; - }` + }`, ); let message = ''; @@ -83,4 +88,3 @@ test('Should use sourcemaps to display error positioning when possible', async ( }); test.run(); -