Git Product home page Git Product logo

Comments (19)

jakobrosenberg avatar jakobrosenberg commented on June 12, 2024 1

Here's the component

<script context="module">
  import { writable, get } from "svelte/store";
  import { page } from "@roxi/routify";

  const languages = {
    en: { short: "en", long: "english", default: true },
    fr: { short: "fr", long: "french" },
    de: { short: "de", long: "german" },
  };

  // let's use a store for reactivity
  const language = writable(languages["en"]);

  const urlTransform = {
    apply: (url) => {
      /**
       * external URL
       * if the selected language is not the default language,
       * we want to use the language as an URL prefix
       */
      const lang = get(language);
      const prefix = !lang.default ? `/${lang.short}` : "";
      return prefix + url;
    },
    remove: (url) => {
      /**
       * internal URL
       * if the first url fragment matches a language,
       * we're gonna strip the fragment
       */
      const [, urlPrefix, ...rest] = url.split("/");
      if (languages[urlPrefix]) {
        language.set(languages[urlPrefix]);
        return [, ...rest].join("/");
      } else return url;
    },
  };

  export { languages, language, urlTransform };
</script>

<script>
  import { goto, url } from "@roxi/routify";
  const handleChange = () => {
    $goto($page.path);
  };
</script>

<select bind:value={$language} on:change={handleChange}>
  {#each Object.values(languages) as lang}
    <option value={lang}>{lang.long}</option>
  {/each}
</select>

from svelte-windicss-preprocess.

alexanderniebuhr avatar alexanderniebuhr commented on June 12, 2024

will be fixed with next release

from svelte-windicss-preprocess.

alexanderniebuhr avatar alexanderniebuhr commented on June 12, 2024

@jakobrosenberg do you know if rollup and snowpack hangs, or if windicss-preprocess hangs??

from svelte-windicss-preprocess.

jakobrosenberg avatar jakobrosenberg commented on June 12, 2024

I'm not able to tell. I just know they hang indefinitely without logging any errors.

from svelte-windicss-preprocess.

alexanderniebuhr avatar alexanderniebuhr commented on June 12, 2024

can you share your project somehow? I can't reproduce currently with the examples in this repo

from svelte-windicss-preprocess.

jakobrosenberg avatar jakobrosenberg commented on June 12, 2024

I'll see if I can create a reproducible.

I've narrowed it down to this loop which seems to run indefinitely.

while (endBracket !== -1) {
let nextBracket = searchNotEscape(text.slice(index), '{');
if (endBracket < nextBracket || nextBracket === -1) {
level--;
index = endBracket + 1;
if (level == 0) return endBracket;
} else {
level++;
index = nextBracket + 1;
}
endBracket = searchNotEscape(text.slice(index), '}');
}

from svelte-windicss-preprocess.

jakobrosenberg avatar jakobrosenberg commented on June 12, 2024

It loops back and forth between these two:

image

image

from svelte-windicss-preprocess.

alexanderniebuhr avatar alexanderniebuhr commented on June 12, 2024

I have an idea.. might be issue because @apply is style, and ur text is apply with some other logic. So there might be a matching error. I have to debug this more. If you can, please show the part with apply: (url) =>

from svelte-windicss-preprocess.

alexanderniebuhr avatar alexanderniebuhr commented on June 12, 2024

thanks that help me.
Will Update the parser right now :) same as #46

from svelte-windicss-preprocess.

alexanderniebuhr avatar alexanderniebuhr commented on June 12, 2024

please try pre-Release of experimental parser https://github.com/windicss/svelte-windicss-preprocess/releases/tag/v3.0.0-beta.1

from svelte-windicss-preprocess.

trevyn avatar trevyn commented on June 12, 2024

I was also running into a hang with 2.3.1, and 3.0.0-beta.1 resolves it.

from svelte-windicss-preprocess.

jakobrosenberg avatar jakobrosenberg commented on June 12, 2024

I'm getting a bunch of warnings for Svelte's export let as well as this error:

[!] (plugin svelte) ParseError: Unexpected token
node_modules\@roxi\routify\runtime\Router.svelte
17:   export let config = {}
18:   let nodes
19:   let navigator window.routify = window.routify || {}
                    ^

This is the actual code on line 12-15:

  let nodes
  let navigator

  window.routify = window.routify || {}

from svelte-windicss-preprocess.

alexanderniebuhr avatar alexanderniebuhr commented on June 12, 2024

yes, working in that. Lead by missing semicolons, is a bug
idk, maybe fixed in https://github.com/windicss/svelte-windicss-preprocess/releases/tag/v3.0.0-beta.6

from svelte-windicss-preprocess.

jakobrosenberg avatar jakobrosenberg commented on June 12, 2024

That fixed it. Here's the next one 😎

[!] (plugin svelte) ParseError: Expected }
src\pages\index.svelte
14:   {#each nodes as node, index}
15:     {#await node.componentWithIndex then [Cmp, Index]}
16:       <div class="page even:{index even:% even:2} " class:un id="{node.title}">
                                       ^
17:         <div class="container">
18:           <svelte:component this="{Cmp}">

The actual code

{#each nodes as node, index}
  <!-- componentWithIndex also returns an `index.svelte` file if one exists -->
    {#await node.componentWithIndex then [Cmp, Index]}
      <div class="page" class:uneven={index % 2} id={node.title}>

from svelte-windicss-preprocess.

alexanderniebuhr avatar alexanderniebuhr commented on June 12, 2024

this is a hard one. However, I think with latest beta https://github.com/windicss/svelte-windicss-preprocess/releases/tag/v3.0.0-beta.7 should work. You have a good project with many cases to test. So please submit any issue.

Parser v3 should be stable soon...

from svelte-windicss-preprocess.

jakobrosenberg avatar jakobrosenberg commented on June 12, 2024

Unfortunately no changes with beta 7. Still getting the error described in my last post.

from svelte-windicss-preprocess.

alexanderniebuhr avatar alexanderniebuhr commented on June 12, 2024

sorry missed one change. beta.8 should finally fix it .. if not can you please post the output of console again

from svelte-windicss-preprocess.

jakobrosenberg avatar jakobrosenberg commented on June 12, 2024

Seems this is finally working. Thanks for all your work @alexanderniebuhr! 👍

from svelte-windicss-preprocess.

alexanderniebuhr avatar alexanderniebuhr commented on June 12, 2024

If you find any issue please let me know.

from svelte-windicss-preprocess.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.