GithubHelp home page GithubHelp logo

Comments (9)

chopin avatar chopin commented on August 29, 2024 1

Yes, using the script tag above worked nicely to me. Also, the compile error from the second trial disappeared too.

Thanks for pointing out the the braces not doubled. They might
have been the cause of the compile error. Anyway the problem solved now. Thanks again.

from transcrypt.

JennaSys avatar JennaSys commented on August 29, 2024

I mostly do dynamic imports using require() because it's clean and almost always just works. But I'm not sure if that's an option for you.

Trystero = require('trystero')
joinRoom = Trystero.joinRoom
joinRoom()

from transcrypt.

chopin avatar chopin commented on August 29, 2024

I mostly do dynamic imports using require()

Thanks for your response. I tried using require(), but an error was thrown in the browser:

Uncaught ReferenceError: require is not defined

In my knowledge, require() is a Node.js function, not Javascript. I think that it cannot be used in Python code for Transcrypt. Is there a way to use it?

from transcrypt.

JennaSys avatar JennaSys commented on August 29, 2024

I use the Parcel bundler with the Transcrypt plugin. I makes everything easier without having to get too deep into the JavaScript ecosystem. I did a write-up on using Parcel v2 with Transcrypt a while back. That should give you an idea of how to set it up, but I don't know if fits into your workflow.

from transcrypt.

chopin avatar chopin commented on August 29, 2024

Thanks for your comment. I took a look at Parcel, but it was too big for me. I am looking for an one-line-solution. I think that it is better to have an easy and simple way to import ES6 Javascript library in Transcrypt.

from transcrypt.

JennaSys avatar JennaSys commented on August 29, 2024

Somewhere in the Transcrypt docs it tells you how to bundle just using the JS rollup library too. It's something like this:

npx rollup ./__target__/app.js --o ./__target__/app.bundle.js --f cjs

from transcrypt.

chopin avatar chopin commented on August 29, 2024

I found an example code in Transcrypt document (https://www.transcrypt.org/docs/html/integration_javascript.html#code-encaps-fabric):

<head>
  <script type="module">import * as terminal_demo from "./__target__/terminal_demo.js";</script>
</head>

The example code shows that import command is included inside <script>..</script> tags. It looks better than using _ _ pragma _ _()

The relevant section of document doesn't mention how to import in case of module type. I hope that this section is updated to include this case 6.1.1. Three ways of integration with JavaScript libraries:

from transcrypt.

JennaSys avatar JennaSys commented on August 29, 2024

Did using the script tag as above work in your case?

I'm not sure if it impacts the issue, but I also just noticed the braces weren't doubled in the string of your pragma:

__pragma__('js', '{}', '''
import {{joinRoom}} from './../trystero-torrent_min.js';
''')

from transcrypt.

JennaSys avatar JennaSys commented on August 29, 2024

The relevant section of document doesn't mention how to import in case of module type. I hope that this section is updated to include this case 6.1.1. Three ways of integration with JavaScript libraries

As suggested, this section of the documentation has been updated.

from transcrypt.

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.