svelte-preprocess icon indicating copy to clipboard operation
svelte-preprocess copied to clipboard

Race condition - occasional CSS parsing error during repeated build

Open coldino opened this issue 3 years ago • 1 comments

Describe the bug Repeating the same build sometimes reports an error parsing valid CSS, while completing successfully other times.

Logs

vite v2.4.4 building SSR bundle for production...
✓ 45 modules transformed.
[vite-plugin-svelte] Unexpected input
file: D:/Work/tmp/src/routes/testing/countdown.svelte
 8: </div>
 9:
10: <style>@font-face{font-family:Fatherland Faker;src:url(/fonts/Fatherland Faker.otf)}.cd{font-family:Fatherland Faker;vertical-align:150%}</style>
                                                       ^
> Unexpected input

Stacktrace:

ParseError: Unexpected input at error (file:///D:/Work/tmp/node_modules/svelte/compiler.mjs:17695:19) at Parser$1.error (file:///D:/Work/tmp/node_modules/svelte/compiler.mjs:17771:9) at Object.read_style [as read] (file:///D:/Work/tmp/node_modules/svelte/compiler.mjs:14106:20) at tag (file:///D:/Work/tmp/node_modules/svelte/compiler.mjs:16854:33) at new Parser$1 (file:///D:/Work/tmp/node_modules/svelte/compiler.mjs:17730:21) at parse$3 (file:///D:/Work/tmp/node_modules/svelte/compiler.mjs:17862:20) at compile (file:///D:/Work/tmp/node_modules/svelte/compiler.mjs:31276:17) at compileSvelte (file:///D:/Work/tmp/node_modules/@sveltejs/vite-plugin-svelte/dist/index.js:301:20) at async Object.transform (file:///D:/Work/tmp/node_modules/@sveltejs/vite-plugin-svelte/dist/index.js:1151:27) at async ModuleLoader.addModuleSource (D:\Work\tmp\node_modules\rollup\dist\shared\rollup.js:19706:30)

To Reproduce Although this is currently in a medium-sized project, I have nothing complex in my setup. The file in question is small with plain CSS (originally had lang="postcss" but removing this changed nothing).

Config is very simple:

	preprocess: [
		preprocess({
			postcss: true,
		}),
	],

And I've been able to switch out my Netlify adapter for the static adapter without any change in behaviour.

I'm simply clearing cache and rebuilding repeatedly to trigger the issue:

rm -rf .svelte-kit/ build/ functions/ .netlify/ node_modules/.vite/ && npm run build

If necessary I can try to cut this down a simple repro, but I have a strong feeling that this is a timing/race condition issue so it's likely to go away with a different size project.

Expected behavior Consistent build behaviour.

Information about your project:

  • Your operating system: Windows 10, up-to-date. No WSL or Docker involved.

  • svelte-preprocess version: 4.8.0 (happened on a slightly older version too - updated to test)

  • Whether your project uses Webpack or Rollup: Standard new SvelteKit build using Vite.

coldino avatar Aug 24 '21 22:08 coldino

Obviously this may not be related to svelte-preprocess but this is my first port of call.

coldino avatar Aug 24 '21 22:08 coldino

This doesn't seem related to svelte-preprocess. Closing 🙏

kaisermann avatar Dec 10 '22 14:12 kaisermann