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

unicode routes with style tag don't load #7086

Closed
luminr opened this issue Dec 29, 2021 · 5 comments
Closed

unicode routes with style tag don't load #7086

luminr opened this issue Dec 29, 2021 · 5 comments

Comments

@luminr
Copy link

luminr commented Dec 29, 2021

Describe the bug

Hi. Routes with non-latin character in their names (e.g. あ.svelte) don't compile if they have root-level style tags.

Reproduction

https://stackblitz.com/edit/sveltekit-p8qavo?file=src%2Froutes%2Findex.svelte

Logs

[plugin:vite-plugin-svelte] Failed to execute 'btoa' on 'WorkerGlobalScope': The string to be encoded contains characters outside of the Latin1 range.
/home/projects/sveltekit-p8qavo/src/routes/文.svelte
    at SourceMap.toUrl (file:///home/projects/sveltekit-p8qavo/node_modules/svelte/compiler.mjs:24897:72)
    at dom (file:///home/projects/sveltekit-p8qavo/node_modules/svelte/compiler.mjs:24967:56)
    at Module.compile (file:///home/projects/sveltekit-p8qavo/node_modules/svelte/compiler.mjs:31358:15)
    at compileSvelte2 (file:///home/projects/sveltekit-p8qavo/node_modules/@sveltejs/vite-plugin-svelte/dist/index.js:324:37)
    at async TransformContext.transform (file:///home/projects/sveltekit-p8qavo/node_modules/@sveltejs/vite-plugin-svelte/dist/index.js:1471:27)
    at async Object.transform (/home/projects/sveltekit-p8qavo/node_modules/vite/dist/node/chunks/dep-e0fe87f8.js:42396:30)
    at async doTransform (/home/projects/sveltekit-p8qavo/node_modules/vite/dist/node/chunks/dep-e0fe87f8.js:56801:29

System Info

System:
    OS: Windows 10 10.0.22000
    CPU: -
    Memory: -
  Binaries:
    Node: 17.1.0 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.15 - C:\Program Files\nodejs\yarn.CMD
    npm: 8.1.2 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Edge: Spartan (44.22000.120.0), Chromium (96.0.1054.62)
    Internet Explorer: 11.0.22000.120
  npmPackages:
    @sveltejs/adapter-auto: next => 1.0.0-next.5
    @sveltejs/adapter-vercel: next => 1.0.0-next.32
    @sveltejs/kit: next => 1.0.0-next.206
    svelte: ^3.44.0 => 3.44.3

Severity

serious, but I can work around it

Additional Information

No response

@benmccann
Copy link
Member

The stack trace shows the issue is in node_modules/svelte/compiler.mjs, so this would be a bug in the Svelte compiler

@benmccann benmccann transferred this issue from sveltejs/kit Dec 31, 2021
@benmccann
Copy link
Member

Seems like it might be referring to this line?

return 'data:application/json;charset=utf-8;base64,' + b64enc(this.toString());

@james-camilleri
Copy link

Hey, I've just run into this issue myself with Svelte version 3.46.4, in SvelteKit. Pages with non-Latin characters in the URL blow up as soon as you add a style tag. It seems the btoa function is being used to generate a source map hash, and it doesn't like non ASCII characters. Had a workaround been discovered? Or is there a fix? I suppose this is more likely to be encountered in SvelteKit since the routes are Svelte components that need to be compiled.

@codelpap

This comment was marked as duplicate.

@Conduitry
Copy link
Member

Duplicate of #6714.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants