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

JS error /_addons/new_format_pack/web/editor.js:219 Uncaught (in promise) TypeError: Cannot read property '$$' of undefined #2

Closed
luc-vocab opened this issue Aug 8, 2021 · 5 comments

Comments

@luc-vocab
Copy link

luc-vocab commented Aug 8, 2021

I'm running into an issue with building this addon and trying to run it with Anki 2.1.46 on Linux. I'm new to Svelte so I could be doing something wrong. I did npm install in the web directory, then went up one directory and did bin/compile.sh, then bin/zip.sh

    function init(component, options, instance2, create_fragment2, not_equal, props, append_styles, dirty = [-1]) {
      const parent_component = current_component;
      set_current_component(component);
      const $$ = component.$$ = {
        fragment: null,
        ctx: null,
        props,
        update: noop,
        not_equal,
        bound: blank_object(),
        on_mount: [],
        on_destroy: [],
        on_disconnect: [],
        before_update: [],
        after_update: [],
        context: new Map(parent_component ? parent_component.$$.context : options.context || []),
        callbacks: blank_object(),
        dirty,
        skip_bound: false,
        root: options.target || parent_component.$$.root
      };

line 219 in this case is this:
root: options.target || parent_component.$$.root

@luc-vocab
Copy link
Author

Related: sveltejs/svelte#6584

@luc-vocab
Copy link
Author

"svelte": "3.39.0" in package.json fixes it.

@dae
Copy link
Contributor

dae commented Aug 9, 2021

Is this perhaps another example of problems with using Svelte across compilation units Henrik? I'm a bit worried this approach is not going to work for us if it's not a use case Svelte are trying to support.

@luc-vocab
Copy link
Author

@dae can you elaborate on what you're referring to ? I was a bit surprised to see that the example addon can be built without having access to anki's source code, I fully expected I would have to someone link to Anki's repository of Svelte components.

@hgiesel
Copy link
Owner

hgiesel commented Aug 9, 2021

This specific issue was because I was using a newer Svelte version in this add-on, then Anki uses. I've downgraded the Svelte that the add-on uses to svelte@~3.38.2, and it works. This would mean that Svelte add-ons need to stay in sync with Ankis Svelte version (at least somewhat).

The issue with compilation units still exists though. However it's more about reactivity. I've been thinking about writing an esbuild extension, that can alleviate this, at least for now.

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

3 participants