GithubHelp home page GithubHelp logo

Vite related issue about stylo HOT 9 CLOSED

peterpeterparker avatar peterpeterparker commented on August 25, 2024
Vite related issue

from stylo.

Comments (9)

peterpeterparker avatar peterpeterparker commented on August 25, 2024 1

I needed a coffee, I think it works as following:

import { defineCustomElements } from '@papyrs/stylo/dist/components/stylo-editor';
defineCustomElements();

However doing so it won't work without installing in addition @stencil/core as a dependency.

There are several issues open at Ionic and Stencil about it. Until these are solved there is no cleaner way to import it in vite projects I think.

ionic-team/ionic-framework#23823

ionic-team/stencil#2826

ionic-team/stencil#2959

from stylo.

wobsoriano avatar wobsoriano commented on August 25, 2024

For now the working solution is to import via unpkg

import "https://unpkg.com/@papyrs/[email protected]/dist/stylo/stylo.esm.js";

or

<script type="module" src="https://unpkg.com/@papyrs/[email protected]/dist/stylo/stylo.esm.js"></script>

Had to change stylo@alpha to [email protected] as it's returning 404

from stylo.

peterpeterparker avatar peterpeterparker commented on August 25, 2024

I think import '@papyrs/stylo' won't work with vite. On the contrary, if I reckon correctly, using the custom elements will - should.

import { defineCustomElements } from '@papyrs/stylo/dist/loader';
defineCustomElements();

from stylo.

wobsoriano avatar wobsoriano commented on August 25, 2024

Same error
Screen Shot 2022-02-10 at 2 56 31 PM

Screen Shot 2022-02-10 at 2 56 40 PM

I think import '@papyrs/stylo' won't work with vite. On the contrary, if I reckon correctly, using the custom elements will - should.

import { defineCustomElements } from '@papyrs/stylo/dist/loader';
defineCustomElements();

from stylo.

peterpeterparker avatar peterpeterparker commented on August 25, 2024

In a svelteki app I wasn't able to load the component as displayed above. As a workaround, I did as following:

onMount(async () => {
    const {defineCustomElement} = await import(/* @vite-ignore */ '@papyrs/stylo/dist/components/stylo-editor');
    defineCustomElement();
  });

from stylo.

peterpeterparker avatar peterpeterparker commented on August 25, 2024

Another tricks, if you are looking to import plugins, these can be imported as following:

import {h1, h2, h3, ul} from '@papyrs/stylo/dist/stylo/index.esm';

from stylo.

peterpeterparker avatar peterpeterparker commented on August 25, 2024

also could load another component as following:

const {DeckgoDoc} = await import('@deckdeckgo/core/dist/components/deckgo-doc');
    customElements.get('deckgo-doc') || customElements.define('deckgo-doc', DeckgoDoc);
    ```

from stylo.

peterpeterparker avatar peterpeterparker commented on August 25, 2024

in call case I needed @stencil/core as a dependency and super important with the same version because there is a breaking change in v2.9.0 ionic-team/ionic-framework#24153

from stylo.

peterpeterparker avatar peterpeterparker commented on August 25, 2024

This has been solved thanks to an improvement in StencilJS and released in v0.0.38

See https://github.com/papyrs/stylo/releases/tag/v0.0.38

from stylo.

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.